babylon.module.d.ts 5.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674
  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/Meshes/instancedMesh" {
  19238. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19239. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19240. import { Camera } from "babylonjs/Cameras/camera";
  19241. import { Node } from "babylonjs/node";
  19242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19243. import { Mesh } from "babylonjs/Meshes/mesh";
  19244. import { Material } from "babylonjs/Materials/material";
  19245. import { Skeleton } from "babylonjs/Bones/skeleton";
  19246. import { Light } from "babylonjs/Lights/light";
  19247. /**
  19248. * Creates an instance based on a source mesh.
  19249. */
  19250. export class InstancedMesh extends AbstractMesh {
  19251. private _sourceMesh;
  19252. private _currentLOD;
  19253. /** @hidden */
  19254. _indexInSourceMeshInstanceArray: number;
  19255. constructor(name: string, source: Mesh);
  19256. /**
  19257. * Returns the string "InstancedMesh".
  19258. */
  19259. getClassName(): string;
  19260. /** Gets the list of lights affecting that mesh */
  19261. readonly lightSources: Light[];
  19262. _resyncLightSources(): void;
  19263. _resyncLighSource(light: Light): void;
  19264. _removeLightSource(light: Light, dispose: boolean): void;
  19265. /**
  19266. * If the source mesh receives shadows
  19267. */
  19268. readonly receiveShadows: boolean;
  19269. /**
  19270. * The material of the source mesh
  19271. */
  19272. readonly material: Nullable<Material>;
  19273. /**
  19274. * Visibility of the source mesh
  19275. */
  19276. readonly visibility: number;
  19277. /**
  19278. * Skeleton of the source mesh
  19279. */
  19280. readonly skeleton: Nullable<Skeleton>;
  19281. /**
  19282. * Rendering ground id of the source mesh
  19283. */
  19284. renderingGroupId: number;
  19285. /**
  19286. * Returns the total number of vertices (integer).
  19287. */
  19288. getTotalVertices(): number;
  19289. /**
  19290. * Returns a positive integer : the total number of indices in this mesh geometry.
  19291. * @returns the numner of indices or zero if the mesh has no geometry.
  19292. */
  19293. getTotalIndices(): number;
  19294. /**
  19295. * The source mesh of the instance
  19296. */
  19297. readonly sourceMesh: Mesh;
  19298. /**
  19299. * Is this node ready to be used/rendered
  19300. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19301. * @return {boolean} is it ready
  19302. */
  19303. isReady(completeCheck?: boolean): boolean;
  19304. /**
  19305. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19306. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19307. * @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.
  19308. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19309. */
  19310. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19311. /**
  19312. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19313. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19314. * The `data` are either a numeric array either a Float32Array.
  19315. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19316. * 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).
  19317. * Note that a new underlying VertexBuffer object is created each call.
  19318. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19319. *
  19320. * Possible `kind` values :
  19321. * - VertexBuffer.PositionKind
  19322. * - VertexBuffer.UVKind
  19323. * - VertexBuffer.UV2Kind
  19324. * - VertexBuffer.UV3Kind
  19325. * - VertexBuffer.UV4Kind
  19326. * - VertexBuffer.UV5Kind
  19327. * - VertexBuffer.UV6Kind
  19328. * - VertexBuffer.ColorKind
  19329. * - VertexBuffer.MatricesIndicesKind
  19330. * - VertexBuffer.MatricesIndicesExtraKind
  19331. * - VertexBuffer.MatricesWeightsKind
  19332. * - VertexBuffer.MatricesWeightsExtraKind
  19333. *
  19334. * Returns the Mesh.
  19335. */
  19336. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19337. /**
  19338. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19339. * If the mesh has no geometry, it is simply returned as it is.
  19340. * The `data` are either a numeric array either a Float32Array.
  19341. * No new underlying VertexBuffer object is created.
  19342. * 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.
  19343. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19344. *
  19345. * Possible `kind` values :
  19346. * - VertexBuffer.PositionKind
  19347. * - VertexBuffer.UVKind
  19348. * - VertexBuffer.UV2Kind
  19349. * - VertexBuffer.UV3Kind
  19350. * - VertexBuffer.UV4Kind
  19351. * - VertexBuffer.UV5Kind
  19352. * - VertexBuffer.UV6Kind
  19353. * - VertexBuffer.ColorKind
  19354. * - VertexBuffer.MatricesIndicesKind
  19355. * - VertexBuffer.MatricesIndicesExtraKind
  19356. * - VertexBuffer.MatricesWeightsKind
  19357. * - VertexBuffer.MatricesWeightsExtraKind
  19358. *
  19359. * Returns the Mesh.
  19360. */
  19361. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19362. /**
  19363. * Sets the mesh indices.
  19364. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19365. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19366. * This method creates a new index buffer each call.
  19367. * Returns the Mesh.
  19368. */
  19369. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19370. /**
  19371. * Boolean : True if the mesh owns the requested kind of data.
  19372. */
  19373. isVerticesDataPresent(kind: string): boolean;
  19374. /**
  19375. * Returns an array of indices (IndicesArray).
  19376. */
  19377. getIndices(): Nullable<IndicesArray>;
  19378. readonly _positions: Nullable<Vector3[]>;
  19379. /**
  19380. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19381. * This means the mesh underlying bounding box and sphere are recomputed.
  19382. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19383. * @returns the current mesh
  19384. */
  19385. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19386. /** @hidden */
  19387. _preActivate(): InstancedMesh;
  19388. /** @hidden */
  19389. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19390. /** @hidden */
  19391. _postActivate(): void;
  19392. getWorldMatrix(): Matrix;
  19393. readonly isAnInstance: boolean;
  19394. /**
  19395. * Returns the current associated LOD AbstractMesh.
  19396. */
  19397. getLOD(camera: Camera): AbstractMesh;
  19398. /** @hidden */
  19399. _syncSubMeshes(): InstancedMesh;
  19400. /** @hidden */
  19401. _generatePointsArray(): boolean;
  19402. /**
  19403. * Creates a new InstancedMesh from the current mesh.
  19404. * - name (string) : the cloned mesh name
  19405. * - newParent (optional Node) : the optional Node to parent the clone to.
  19406. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19407. *
  19408. * Returns the clone.
  19409. */
  19410. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19411. /**
  19412. * Disposes the InstancedMesh.
  19413. * Returns nothing.
  19414. */
  19415. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19416. }
  19417. }
  19418. declare module "babylonjs/Materials/shaderMaterial" {
  19419. import { Scene } from "babylonjs/scene";
  19420. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19422. import { Mesh } from "babylonjs/Meshes/mesh";
  19423. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19425. import { Texture } from "babylonjs/Materials/Textures/texture";
  19426. import { Material } from "babylonjs/Materials/material";
  19427. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19428. /**
  19429. * Defines the options associated with the creation of a shader material.
  19430. */
  19431. export interface IShaderMaterialOptions {
  19432. /**
  19433. * Does the material work in alpha blend mode
  19434. */
  19435. needAlphaBlending: boolean;
  19436. /**
  19437. * Does the material work in alpha test mode
  19438. */
  19439. needAlphaTesting: boolean;
  19440. /**
  19441. * The list of attribute names used in the shader
  19442. */
  19443. attributes: string[];
  19444. /**
  19445. * The list of unifrom names used in the shader
  19446. */
  19447. uniforms: string[];
  19448. /**
  19449. * The list of UBO names used in the shader
  19450. */
  19451. uniformBuffers: string[];
  19452. /**
  19453. * The list of sampler names used in the shader
  19454. */
  19455. samplers: string[];
  19456. /**
  19457. * The list of defines used in the shader
  19458. */
  19459. defines: string[];
  19460. }
  19461. /**
  19462. * 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.
  19463. *
  19464. * This returned material effects how the mesh will look based on the code in the shaders.
  19465. *
  19466. * @see http://doc.babylonjs.com/how_to/shader_material
  19467. */
  19468. export class ShaderMaterial extends Material {
  19469. private _shaderPath;
  19470. private _options;
  19471. private _textures;
  19472. private _textureArrays;
  19473. private _floats;
  19474. private _ints;
  19475. private _floatsArrays;
  19476. private _colors3;
  19477. private _colors3Arrays;
  19478. private _colors4;
  19479. private _colors4Arrays;
  19480. private _vectors2;
  19481. private _vectors3;
  19482. private _vectors4;
  19483. private _matrices;
  19484. private _matrices3x3;
  19485. private _matrices2x2;
  19486. private _vectors2Arrays;
  19487. private _vectors3Arrays;
  19488. private _vectors4Arrays;
  19489. private _cachedWorldViewMatrix;
  19490. private _cachedWorldViewProjectionMatrix;
  19491. private _renderId;
  19492. /**
  19493. * Instantiate a new shader material.
  19494. * 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.
  19495. * This returned material effects how the mesh will look based on the code in the shaders.
  19496. * @see http://doc.babylonjs.com/how_to/shader_material
  19497. * @param name Define the name of the material in the scene
  19498. * @param scene Define the scene the material belongs to
  19499. * @param shaderPath Defines the route to the shader code in one of three ways:
  19500. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19501. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19502. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19503. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19504. * @param options Define the options used to create the shader
  19505. */
  19506. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19507. /**
  19508. * Gets the options used to compile the shader.
  19509. * They can be modified to trigger a new compilation
  19510. */
  19511. readonly options: IShaderMaterialOptions;
  19512. /**
  19513. * Gets the current class name of the material e.g. "ShaderMaterial"
  19514. * Mainly use in serialization.
  19515. * @returns the class name
  19516. */
  19517. getClassName(): string;
  19518. /**
  19519. * Specifies if the material will require alpha blending
  19520. * @returns a boolean specifying if alpha blending is needed
  19521. */
  19522. needAlphaBlending(): boolean;
  19523. /**
  19524. * Specifies if this material should be rendered in alpha test mode
  19525. * @returns a boolean specifying if an alpha test is needed.
  19526. */
  19527. needAlphaTesting(): boolean;
  19528. private _checkUniform;
  19529. /**
  19530. * Set a texture in the shader.
  19531. * @param name Define the name of the uniform samplers as defined in the shader
  19532. * @param texture Define the texture to bind to this sampler
  19533. * @return the material itself allowing "fluent" like uniform updates
  19534. */
  19535. setTexture(name: string, texture: Texture): ShaderMaterial;
  19536. /**
  19537. * Set a texture array in the shader.
  19538. * @param name Define the name of the uniform sampler array as defined in the shader
  19539. * @param textures Define the list of textures to bind to this sampler
  19540. * @return the material itself allowing "fluent" like uniform updates
  19541. */
  19542. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19543. /**
  19544. * Set a float in the shader.
  19545. * @param name Define the name of the uniform as defined in the shader
  19546. * @param value Define the value to give to the uniform
  19547. * @return the material itself allowing "fluent" like uniform updates
  19548. */
  19549. setFloat(name: string, value: number): ShaderMaterial;
  19550. /**
  19551. * Set a int in the shader.
  19552. * @param name Define the name of the uniform as defined in the shader
  19553. * @param value Define the value to give to the uniform
  19554. * @return the material itself allowing "fluent" like uniform updates
  19555. */
  19556. setInt(name: string, value: number): ShaderMaterial;
  19557. /**
  19558. * Set an array of floats in the shader.
  19559. * @param name Define the name of the uniform as defined in the shader
  19560. * @param value Define the value to give to the uniform
  19561. * @return the material itself allowing "fluent" like uniform updates
  19562. */
  19563. setFloats(name: string, value: number[]): ShaderMaterial;
  19564. /**
  19565. * Set a vec3 in the shader from a Color3.
  19566. * @param name Define the name of the uniform as defined in the shader
  19567. * @param value Define the value to give to the uniform
  19568. * @return the material itself allowing "fluent" like uniform updates
  19569. */
  19570. setColor3(name: string, value: Color3): ShaderMaterial;
  19571. /**
  19572. * Set a vec3 array in the shader from a Color3 array.
  19573. * @param name Define the name of the uniform as defined in the shader
  19574. * @param value Define the value to give to the uniform
  19575. * @return the material itself allowing "fluent" like uniform updates
  19576. */
  19577. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19578. /**
  19579. * Set a vec4 in the shader from a Color4.
  19580. * @param name Define the name of the uniform as defined in the shader
  19581. * @param value Define the value to give to the uniform
  19582. * @return the material itself allowing "fluent" like uniform updates
  19583. */
  19584. setColor4(name: string, value: Color4): ShaderMaterial;
  19585. /**
  19586. * Set a vec4 array in the shader from a Color4 array.
  19587. * @param name Define the name of the uniform as defined in the shader
  19588. * @param value Define the value to give to the uniform
  19589. * @return the material itself allowing "fluent" like uniform updates
  19590. */
  19591. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19592. /**
  19593. * Set a vec2 in the shader from a Vector2.
  19594. * @param name Define the name of the uniform as defined in the shader
  19595. * @param value Define the value to give to the uniform
  19596. * @return the material itself allowing "fluent" like uniform updates
  19597. */
  19598. setVector2(name: string, value: Vector2): ShaderMaterial;
  19599. /**
  19600. * Set a vec3 in the shader from a Vector3.
  19601. * @param name Define the name of the uniform as defined in the shader
  19602. * @param value Define the value to give to the uniform
  19603. * @return the material itself allowing "fluent" like uniform updates
  19604. */
  19605. setVector3(name: string, value: Vector3): ShaderMaterial;
  19606. /**
  19607. * Set a vec4 in the shader from a Vector4.
  19608. * @param name Define the name of the uniform as defined in the shader
  19609. * @param value Define the value to give to the uniform
  19610. * @return the material itself allowing "fluent" like uniform updates
  19611. */
  19612. setVector4(name: string, value: Vector4): ShaderMaterial;
  19613. /**
  19614. * Set a mat4 in the shader from a Matrix.
  19615. * @param name Define the name of the uniform as defined in the shader
  19616. * @param value Define the value to give to the uniform
  19617. * @return the material itself allowing "fluent" like uniform updates
  19618. */
  19619. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19620. /**
  19621. * Set a mat3 in the shader from a Float32Array.
  19622. * @param name Define the name of the uniform as defined in the shader
  19623. * @param value Define the value to give to the uniform
  19624. * @return the material itself allowing "fluent" like uniform updates
  19625. */
  19626. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19627. /**
  19628. * Set a mat2 in the shader from a Float32Array.
  19629. * @param name Define the name of the uniform as defined in the shader
  19630. * @param value Define the value to give to the uniform
  19631. * @return the material itself allowing "fluent" like uniform updates
  19632. */
  19633. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19634. /**
  19635. * Set a vec2 array in the shader from a number array.
  19636. * @param name Define the name of the uniform as defined in the shader
  19637. * @param value Define the value to give to the uniform
  19638. * @return the material itself allowing "fluent" like uniform updates
  19639. */
  19640. setArray2(name: string, value: number[]): ShaderMaterial;
  19641. /**
  19642. * Set a vec3 array in the shader from a number array.
  19643. * @param name Define the name of the uniform as defined in the shader
  19644. * @param value Define the value to give to the uniform
  19645. * @return the material itself allowing "fluent" like uniform updates
  19646. */
  19647. setArray3(name: string, value: number[]): ShaderMaterial;
  19648. /**
  19649. * Set a vec4 array in the shader from a number array.
  19650. * @param name Define the name of the uniform as defined in the shader
  19651. * @param value Define the value to give to the uniform
  19652. * @return the material itself allowing "fluent" like uniform updates
  19653. */
  19654. setArray4(name: string, value: number[]): ShaderMaterial;
  19655. private _checkCache;
  19656. /**
  19657. * Specifies that the submesh is ready to be used
  19658. * @param mesh defines the mesh to check
  19659. * @param subMesh defines which submesh to check
  19660. * @param useInstances specifies that instances should be used
  19661. * @returns a boolean indicating that the submesh is ready or not
  19662. */
  19663. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19664. /**
  19665. * Checks if the material is ready to render the requested mesh
  19666. * @param mesh Define the mesh to render
  19667. * @param useInstances Define whether or not the material is used with instances
  19668. * @returns true if ready, otherwise false
  19669. */
  19670. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19671. /**
  19672. * Binds the world matrix to the material
  19673. * @param world defines the world transformation matrix
  19674. */
  19675. bindOnlyWorldMatrix(world: Matrix): void;
  19676. /**
  19677. * Binds the material to the mesh
  19678. * @param world defines the world transformation matrix
  19679. * @param mesh defines the mesh to bind the material to
  19680. */
  19681. bind(world: Matrix, mesh?: Mesh): void;
  19682. /**
  19683. * Gets the active textures from the material
  19684. * @returns an array of textures
  19685. */
  19686. getActiveTextures(): BaseTexture[];
  19687. /**
  19688. * Specifies if the material uses a texture
  19689. * @param texture defines the texture to check against the material
  19690. * @returns a boolean specifying if the material uses the texture
  19691. */
  19692. hasTexture(texture: BaseTexture): boolean;
  19693. /**
  19694. * Makes a duplicate of the material, and gives it a new name
  19695. * @param name defines the new name for the duplicated material
  19696. * @returns the cloned material
  19697. */
  19698. clone(name: string): ShaderMaterial;
  19699. /**
  19700. * Disposes the material
  19701. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19702. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19703. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19704. */
  19705. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19706. /**
  19707. * Serializes this material in a JSON representation
  19708. * @returns the serialized material object
  19709. */
  19710. serialize(): any;
  19711. /**
  19712. * Creates a shader material from parsed shader material data
  19713. * @param source defines the JSON represnetation of the material
  19714. * @param scene defines the hosting scene
  19715. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19716. * @returns a new material
  19717. */
  19718. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19719. }
  19720. }
  19721. declare module "babylonjs/Shaders/color.fragment" {
  19722. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19723. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19724. /** @hidden */
  19725. export var colorPixelShader: {
  19726. name: string;
  19727. shader: string;
  19728. };
  19729. }
  19730. declare module "babylonjs/Shaders/color.vertex" {
  19731. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19732. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19733. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19734. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19735. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19736. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19737. /** @hidden */
  19738. export var colorVertexShader: {
  19739. name: string;
  19740. shader: string;
  19741. };
  19742. }
  19743. declare module "babylonjs/Meshes/linesMesh" {
  19744. import { Nullable } from "babylonjs/types";
  19745. import { Scene } from "babylonjs/scene";
  19746. import { Color3 } from "babylonjs/Maths/math.color";
  19747. import { Node } from "babylonjs/node";
  19748. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19749. import { Mesh } from "babylonjs/Meshes/mesh";
  19750. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19751. import { Effect } from "babylonjs/Materials/effect";
  19752. import { Material } from "babylonjs/Materials/material";
  19753. import "babylonjs/Shaders/color.fragment";
  19754. import "babylonjs/Shaders/color.vertex";
  19755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19756. /**
  19757. * Line mesh
  19758. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19759. */
  19760. export class LinesMesh extends Mesh {
  19761. /**
  19762. * If vertex color should be applied to the mesh
  19763. */
  19764. readonly useVertexColor?: boolean | undefined;
  19765. /**
  19766. * If vertex alpha should be applied to the mesh
  19767. */
  19768. readonly useVertexAlpha?: boolean | undefined;
  19769. /**
  19770. * Color of the line (Default: White)
  19771. */
  19772. color: Color3;
  19773. /**
  19774. * Alpha of the line (Default: 1)
  19775. */
  19776. alpha: number;
  19777. /**
  19778. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19779. * This margin is expressed in world space coordinates, so its value may vary.
  19780. * Default value is 0.1
  19781. */
  19782. intersectionThreshold: number;
  19783. private _colorShader;
  19784. private color4;
  19785. /**
  19786. * Creates a new LinesMesh
  19787. * @param name defines the name
  19788. * @param scene defines the hosting scene
  19789. * @param parent defines the parent mesh if any
  19790. * @param source defines the optional source LinesMesh used to clone data from
  19791. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19792. * When false, achieved by calling a clone(), also passing False.
  19793. * This will make creation of children, recursive.
  19794. * @param useVertexColor defines if this LinesMesh supports vertex color
  19795. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19796. */
  19797. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19798. /**
  19799. * If vertex color should be applied to the mesh
  19800. */
  19801. useVertexColor?: boolean | undefined,
  19802. /**
  19803. * If vertex alpha should be applied to the mesh
  19804. */
  19805. useVertexAlpha?: boolean | undefined);
  19806. private _addClipPlaneDefine;
  19807. private _removeClipPlaneDefine;
  19808. isReady(): boolean;
  19809. /**
  19810. * Returns the string "LineMesh"
  19811. */
  19812. getClassName(): string;
  19813. /**
  19814. * @hidden
  19815. */
  19816. /**
  19817. * @hidden
  19818. */
  19819. material: Material;
  19820. /**
  19821. * @hidden
  19822. */
  19823. readonly checkCollisions: boolean;
  19824. /** @hidden */
  19825. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19826. /** @hidden */
  19827. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19828. /**
  19829. * Disposes of the line mesh
  19830. * @param doNotRecurse If children should be disposed
  19831. */
  19832. dispose(doNotRecurse?: boolean): void;
  19833. /**
  19834. * Returns a new LineMesh object cloned from the current one.
  19835. */
  19836. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19837. /**
  19838. * Creates a new InstancedLinesMesh object from the mesh model.
  19839. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19840. * @param name defines the name of the new instance
  19841. * @returns a new InstancedLinesMesh
  19842. */
  19843. createInstance(name: string): InstancedLinesMesh;
  19844. }
  19845. /**
  19846. * Creates an instance based on a source LinesMesh
  19847. */
  19848. export class InstancedLinesMesh extends InstancedMesh {
  19849. /**
  19850. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19851. * This margin is expressed in world space coordinates, so its value may vary.
  19852. * Initilized with the intersectionThreshold value of the source LinesMesh
  19853. */
  19854. intersectionThreshold: number;
  19855. constructor(name: string, source: LinesMesh);
  19856. /**
  19857. * Returns the string "InstancedLinesMesh".
  19858. */
  19859. getClassName(): string;
  19860. }
  19861. }
  19862. declare module "babylonjs/Shaders/line.fragment" {
  19863. /** @hidden */
  19864. export var linePixelShader: {
  19865. name: string;
  19866. shader: string;
  19867. };
  19868. }
  19869. declare module "babylonjs/Shaders/line.vertex" {
  19870. /** @hidden */
  19871. export var lineVertexShader: {
  19872. name: string;
  19873. shader: string;
  19874. };
  19875. }
  19876. declare module "babylonjs/Rendering/edgesRenderer" {
  19877. import { Nullable } from "babylonjs/types";
  19878. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19880. import { Vector3 } from "babylonjs/Maths/math.vector";
  19881. import { IDisposable } from "babylonjs/scene";
  19882. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19883. import "babylonjs/Shaders/line.fragment";
  19884. import "babylonjs/Shaders/line.vertex";
  19885. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19886. module "babylonjs/Meshes/abstractMesh" {
  19887. interface AbstractMesh {
  19888. /**
  19889. * Gets the edgesRenderer associated with the mesh
  19890. */
  19891. edgesRenderer: Nullable<EdgesRenderer>;
  19892. }
  19893. }
  19894. module "babylonjs/Meshes/linesMesh" {
  19895. interface LinesMesh {
  19896. /**
  19897. * Enables the edge rendering mode on the mesh.
  19898. * This mode makes the mesh edges visible
  19899. * @param epsilon defines the maximal distance between two angles to detect a face
  19900. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19901. * @returns the currentAbstractMesh
  19902. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19903. */
  19904. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19905. }
  19906. }
  19907. module "babylonjs/Meshes/linesMesh" {
  19908. interface InstancedLinesMesh {
  19909. /**
  19910. * Enables the edge rendering mode on the mesh.
  19911. * This mode makes the mesh edges visible
  19912. * @param epsilon defines the maximal distance between two angles to detect a face
  19913. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19914. * @returns the current InstancedLinesMesh
  19915. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19916. */
  19917. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19918. }
  19919. }
  19920. /**
  19921. * Defines the minimum contract an Edges renderer should follow.
  19922. */
  19923. export interface IEdgesRenderer extends IDisposable {
  19924. /**
  19925. * Gets or sets a boolean indicating if the edgesRenderer is active
  19926. */
  19927. isEnabled: boolean;
  19928. /**
  19929. * Renders the edges of the attached mesh,
  19930. */
  19931. render(): void;
  19932. /**
  19933. * Checks wether or not the edges renderer is ready to render.
  19934. * @return true if ready, otherwise false.
  19935. */
  19936. isReady(): boolean;
  19937. }
  19938. /**
  19939. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19940. */
  19941. export class EdgesRenderer implements IEdgesRenderer {
  19942. /**
  19943. * Define the size of the edges with an orthographic camera
  19944. */
  19945. edgesWidthScalerForOrthographic: number;
  19946. /**
  19947. * Define the size of the edges with a perspective camera
  19948. */
  19949. edgesWidthScalerForPerspective: number;
  19950. protected _source: AbstractMesh;
  19951. protected _linesPositions: number[];
  19952. protected _linesNormals: number[];
  19953. protected _linesIndices: number[];
  19954. protected _epsilon: number;
  19955. protected _indicesCount: number;
  19956. protected _lineShader: ShaderMaterial;
  19957. protected _ib: DataBuffer;
  19958. protected _buffers: {
  19959. [key: string]: Nullable<VertexBuffer>;
  19960. };
  19961. protected _checkVerticesInsteadOfIndices: boolean;
  19962. private _meshRebuildObserver;
  19963. private _meshDisposeObserver;
  19964. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19965. isEnabled: boolean;
  19966. /**
  19967. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19968. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19969. * @param source Mesh used to create edges
  19970. * @param epsilon sum of angles in adjacency to check for edge
  19971. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19972. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19973. */
  19974. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19975. protected _prepareRessources(): void;
  19976. /** @hidden */
  19977. _rebuild(): void;
  19978. /**
  19979. * Releases the required resources for the edges renderer
  19980. */
  19981. dispose(): void;
  19982. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19983. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19984. /**
  19985. * Checks if the pair of p0 and p1 is en edge
  19986. * @param faceIndex
  19987. * @param edge
  19988. * @param faceNormals
  19989. * @param p0
  19990. * @param p1
  19991. * @private
  19992. */
  19993. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19994. /**
  19995. * push line into the position, normal and index buffer
  19996. * @protected
  19997. */
  19998. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19999. /**
  20000. * Generates lines edges from adjacencjes
  20001. * @private
  20002. */
  20003. _generateEdgesLines(): void;
  20004. /**
  20005. * Checks wether or not the edges renderer is ready to render.
  20006. * @return true if ready, otherwise false.
  20007. */
  20008. isReady(): boolean;
  20009. /**
  20010. * Renders the edges of the attached mesh,
  20011. */
  20012. render(): void;
  20013. }
  20014. /**
  20015. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20016. */
  20017. export class LineEdgesRenderer extends EdgesRenderer {
  20018. /**
  20019. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20020. * @param source LineMesh used to generate edges
  20021. * @param epsilon not important (specified angle for edge detection)
  20022. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20023. */
  20024. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20025. /**
  20026. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20027. */
  20028. _generateEdgesLines(): void;
  20029. }
  20030. }
  20031. declare module "babylonjs/Rendering/renderingGroup" {
  20032. import { SmartArray } from "babylonjs/Misc/smartArray";
  20033. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20035. import { Nullable } from "babylonjs/types";
  20036. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20037. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20038. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20039. import { Material } from "babylonjs/Materials/material";
  20040. import { Scene } from "babylonjs/scene";
  20041. /**
  20042. * This represents the object necessary to create a rendering group.
  20043. * This is exclusively used and created by the rendering manager.
  20044. * To modify the behavior, you use the available helpers in your scene or meshes.
  20045. * @hidden
  20046. */
  20047. export class RenderingGroup {
  20048. index: number;
  20049. private static _zeroVector;
  20050. private _scene;
  20051. private _opaqueSubMeshes;
  20052. private _transparentSubMeshes;
  20053. private _alphaTestSubMeshes;
  20054. private _depthOnlySubMeshes;
  20055. private _particleSystems;
  20056. private _spriteManagers;
  20057. private _opaqueSortCompareFn;
  20058. private _alphaTestSortCompareFn;
  20059. private _transparentSortCompareFn;
  20060. private _renderOpaque;
  20061. private _renderAlphaTest;
  20062. private _renderTransparent;
  20063. /** @hidden */
  20064. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20065. onBeforeTransparentRendering: () => void;
  20066. /**
  20067. * Set the opaque sort comparison function.
  20068. * If null the sub meshes will be render in the order they were created
  20069. */
  20070. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20071. /**
  20072. * Set the alpha test sort comparison function.
  20073. * If null the sub meshes will be render in the order they were created
  20074. */
  20075. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20076. /**
  20077. * Set the transparent sort comparison function.
  20078. * If null the sub meshes will be render in the order they were created
  20079. */
  20080. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20081. /**
  20082. * Creates a new rendering group.
  20083. * @param index The rendering group index
  20084. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20085. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20086. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20087. */
  20088. 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>);
  20089. /**
  20090. * Render all the sub meshes contained in the group.
  20091. * @param customRenderFunction Used to override the default render behaviour of the group.
  20092. * @returns true if rendered some submeshes.
  20093. */
  20094. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20095. /**
  20096. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20097. * @param subMeshes The submeshes to render
  20098. */
  20099. private renderOpaqueSorted;
  20100. /**
  20101. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20102. * @param subMeshes The submeshes to render
  20103. */
  20104. private renderAlphaTestSorted;
  20105. /**
  20106. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20107. * @param subMeshes The submeshes to render
  20108. */
  20109. private renderTransparentSorted;
  20110. /**
  20111. * Renders the submeshes in a specified order.
  20112. * @param subMeshes The submeshes to sort before render
  20113. * @param sortCompareFn The comparison function use to sort
  20114. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20115. * @param transparent Specifies to activate blending if true
  20116. */
  20117. private static renderSorted;
  20118. /**
  20119. * Renders the submeshes in the order they were dispatched (no sort applied).
  20120. * @param subMeshes The submeshes to render
  20121. */
  20122. private static renderUnsorted;
  20123. /**
  20124. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20125. * are rendered back to front if in the same alpha index.
  20126. *
  20127. * @param a The first submesh
  20128. * @param b The second submesh
  20129. * @returns The result of the comparison
  20130. */
  20131. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20132. /**
  20133. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20134. * are rendered back to front.
  20135. *
  20136. * @param a The first submesh
  20137. * @param b The second submesh
  20138. * @returns The result of the comparison
  20139. */
  20140. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20141. /**
  20142. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20143. * are rendered front to back (prevent overdraw).
  20144. *
  20145. * @param a The first submesh
  20146. * @param b The second submesh
  20147. * @returns The result of the comparison
  20148. */
  20149. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20150. /**
  20151. * Resets the different lists of submeshes to prepare a new frame.
  20152. */
  20153. prepare(): void;
  20154. dispose(): void;
  20155. /**
  20156. * Inserts the submesh in its correct queue depending on its material.
  20157. * @param subMesh The submesh to dispatch
  20158. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20159. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20160. */
  20161. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20162. dispatchSprites(spriteManager: ISpriteManager): void;
  20163. dispatchParticles(particleSystem: IParticleSystem): void;
  20164. private _renderParticles;
  20165. private _renderSprites;
  20166. }
  20167. }
  20168. declare module "babylonjs/Rendering/renderingManager" {
  20169. import { Nullable } from "babylonjs/types";
  20170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20171. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20172. import { SmartArray } from "babylonjs/Misc/smartArray";
  20173. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20174. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20175. import { Material } from "babylonjs/Materials/material";
  20176. import { Scene } from "babylonjs/scene";
  20177. import { Camera } from "babylonjs/Cameras/camera";
  20178. /**
  20179. * Interface describing the different options available in the rendering manager
  20180. * regarding Auto Clear between groups.
  20181. */
  20182. export interface IRenderingManagerAutoClearSetup {
  20183. /**
  20184. * Defines whether or not autoclear is enable.
  20185. */
  20186. autoClear: boolean;
  20187. /**
  20188. * Defines whether or not to autoclear the depth buffer.
  20189. */
  20190. depth: boolean;
  20191. /**
  20192. * Defines whether or not to autoclear the stencil buffer.
  20193. */
  20194. stencil: boolean;
  20195. }
  20196. /**
  20197. * This class is used by the onRenderingGroupObservable
  20198. */
  20199. export class RenderingGroupInfo {
  20200. /**
  20201. * The Scene that being rendered
  20202. */
  20203. scene: Scene;
  20204. /**
  20205. * The camera currently used for the rendering pass
  20206. */
  20207. camera: Nullable<Camera>;
  20208. /**
  20209. * The ID of the renderingGroup being processed
  20210. */
  20211. renderingGroupId: number;
  20212. }
  20213. /**
  20214. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20215. * It is enable to manage the different groups as well as the different necessary sort functions.
  20216. * This should not be used directly aside of the few static configurations
  20217. */
  20218. export class RenderingManager {
  20219. /**
  20220. * The max id used for rendering groups (not included)
  20221. */
  20222. static MAX_RENDERINGGROUPS: number;
  20223. /**
  20224. * The min id used for rendering groups (included)
  20225. */
  20226. static MIN_RENDERINGGROUPS: number;
  20227. /**
  20228. * Used to globally prevent autoclearing scenes.
  20229. */
  20230. static AUTOCLEAR: boolean;
  20231. /**
  20232. * @hidden
  20233. */
  20234. _useSceneAutoClearSetup: boolean;
  20235. private _scene;
  20236. private _renderingGroups;
  20237. private _depthStencilBufferAlreadyCleaned;
  20238. private _autoClearDepthStencil;
  20239. private _customOpaqueSortCompareFn;
  20240. private _customAlphaTestSortCompareFn;
  20241. private _customTransparentSortCompareFn;
  20242. private _renderingGroupInfo;
  20243. /**
  20244. * Instantiates a new rendering group for a particular scene
  20245. * @param scene Defines the scene the groups belongs to
  20246. */
  20247. constructor(scene: Scene);
  20248. private _clearDepthStencilBuffer;
  20249. /**
  20250. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20251. * @hidden
  20252. */
  20253. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20254. /**
  20255. * Resets the different information of the group to prepare a new frame
  20256. * @hidden
  20257. */
  20258. reset(): void;
  20259. /**
  20260. * Dispose and release the group and its associated resources.
  20261. * @hidden
  20262. */
  20263. dispose(): void;
  20264. /**
  20265. * Clear the info related to rendering groups preventing retention points during dispose.
  20266. */
  20267. freeRenderingGroups(): void;
  20268. private _prepareRenderingGroup;
  20269. /**
  20270. * Add a sprite manager to the rendering manager in order to render it this frame.
  20271. * @param spriteManager Define the sprite manager to render
  20272. */
  20273. dispatchSprites(spriteManager: ISpriteManager): void;
  20274. /**
  20275. * Add a particle system to the rendering manager in order to render it this frame.
  20276. * @param particleSystem Define the particle system to render
  20277. */
  20278. dispatchParticles(particleSystem: IParticleSystem): void;
  20279. /**
  20280. * Add a submesh to the manager in order to render it this frame
  20281. * @param subMesh The submesh to dispatch
  20282. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20283. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20284. */
  20285. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20286. /**
  20287. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20288. * This allowed control for front to back rendering or reversly depending of the special needs.
  20289. *
  20290. * @param renderingGroupId The rendering group id corresponding to its index
  20291. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20292. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20293. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20294. */
  20295. 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;
  20296. /**
  20297. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20298. *
  20299. * @param renderingGroupId The rendering group id corresponding to its index
  20300. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20301. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20302. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20303. */
  20304. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20305. /**
  20306. * Gets the current auto clear configuration for one rendering group of the rendering
  20307. * manager.
  20308. * @param index the rendering group index to get the information for
  20309. * @returns The auto clear setup for the requested rendering group
  20310. */
  20311. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20312. }
  20313. }
  20314. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20315. import { Observable } from "babylonjs/Misc/observable";
  20316. import { SmartArray } from "babylonjs/Misc/smartArray";
  20317. import { Nullable } from "babylonjs/types";
  20318. import { Camera } from "babylonjs/Cameras/camera";
  20319. import { Scene } from "babylonjs/scene";
  20320. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20321. import { Color4 } from "babylonjs/Maths/math.color";
  20322. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20324. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20325. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20326. import { Texture } from "babylonjs/Materials/Textures/texture";
  20327. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20328. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20329. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20330. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20331. import { Engine } from "babylonjs/Engines/engine";
  20332. /**
  20333. * This Helps creating a texture that will be created from a camera in your scene.
  20334. * It is basically a dynamic texture that could be used to create special effects for instance.
  20335. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20336. */
  20337. export class RenderTargetTexture extends Texture {
  20338. isCube: boolean;
  20339. /**
  20340. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20341. */
  20342. static readonly REFRESHRATE_RENDER_ONCE: number;
  20343. /**
  20344. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20345. */
  20346. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20347. /**
  20348. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20349. * the central point of your effect and can save a lot of performances.
  20350. */
  20351. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20352. /**
  20353. * Use this predicate to dynamically define the list of mesh you want to render.
  20354. * If set, the renderList property will be overwritten.
  20355. */
  20356. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20357. private _renderList;
  20358. /**
  20359. * Use this list to define the list of mesh you want to render.
  20360. */
  20361. renderList: Nullable<Array<AbstractMesh>>;
  20362. private _hookArray;
  20363. /**
  20364. * Define if particles should be rendered in your texture.
  20365. */
  20366. renderParticles: boolean;
  20367. /**
  20368. * Define if sprites should be rendered in your texture.
  20369. */
  20370. renderSprites: boolean;
  20371. /**
  20372. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20373. */
  20374. coordinatesMode: number;
  20375. /**
  20376. * Define the camera used to render the texture.
  20377. */
  20378. activeCamera: Nullable<Camera>;
  20379. /**
  20380. * Override the render function of the texture with your own one.
  20381. */
  20382. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20383. /**
  20384. * Define if camera post processes should be use while rendering the texture.
  20385. */
  20386. useCameraPostProcesses: boolean;
  20387. /**
  20388. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20389. */
  20390. ignoreCameraViewport: boolean;
  20391. private _postProcessManager;
  20392. private _postProcesses;
  20393. private _resizeObserver;
  20394. /**
  20395. * An event triggered when the texture is unbind.
  20396. */
  20397. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20398. /**
  20399. * An event triggered when the texture is unbind.
  20400. */
  20401. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20402. private _onAfterUnbindObserver;
  20403. /**
  20404. * Set a after unbind callback in the texture.
  20405. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20406. */
  20407. onAfterUnbind: () => void;
  20408. /**
  20409. * An event triggered before rendering the texture
  20410. */
  20411. onBeforeRenderObservable: Observable<number>;
  20412. private _onBeforeRenderObserver;
  20413. /**
  20414. * Set a before render callback in the texture.
  20415. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20416. */
  20417. onBeforeRender: (faceIndex: number) => void;
  20418. /**
  20419. * An event triggered after rendering the texture
  20420. */
  20421. onAfterRenderObservable: Observable<number>;
  20422. private _onAfterRenderObserver;
  20423. /**
  20424. * Set a after render callback in the texture.
  20425. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20426. */
  20427. onAfterRender: (faceIndex: number) => void;
  20428. /**
  20429. * An event triggered after the texture clear
  20430. */
  20431. onClearObservable: Observable<Engine>;
  20432. private _onClearObserver;
  20433. /**
  20434. * Set a clear callback in the texture.
  20435. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20436. */
  20437. onClear: (Engine: Engine) => void;
  20438. /**
  20439. * An event triggered when the texture is resized.
  20440. */
  20441. onResizeObservable: Observable<RenderTargetTexture>;
  20442. /**
  20443. * Define the clear color of the Render Target if it should be different from the scene.
  20444. */
  20445. clearColor: Color4;
  20446. protected _size: number | {
  20447. width: number;
  20448. height: number;
  20449. };
  20450. protected _initialSizeParameter: number | {
  20451. width: number;
  20452. height: number;
  20453. } | {
  20454. ratio: number;
  20455. };
  20456. protected _sizeRatio: Nullable<number>;
  20457. /** @hidden */
  20458. _generateMipMaps: boolean;
  20459. protected _renderingManager: RenderingManager;
  20460. /** @hidden */
  20461. _waitingRenderList: string[];
  20462. protected _doNotChangeAspectRatio: boolean;
  20463. protected _currentRefreshId: number;
  20464. protected _refreshRate: number;
  20465. protected _textureMatrix: Matrix;
  20466. protected _samples: number;
  20467. protected _renderTargetOptions: RenderTargetCreationOptions;
  20468. /**
  20469. * Gets render target creation options that were used.
  20470. */
  20471. readonly renderTargetOptions: RenderTargetCreationOptions;
  20472. protected _engine: Engine;
  20473. protected _onRatioRescale(): void;
  20474. /**
  20475. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20476. * It must define where the camera used to render the texture is set
  20477. */
  20478. boundingBoxPosition: Vector3;
  20479. private _boundingBoxSize;
  20480. /**
  20481. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20482. * When defined, the cubemap will switch to local mode
  20483. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20484. * @example https://www.babylonjs-playground.com/#RNASML
  20485. */
  20486. boundingBoxSize: Vector3;
  20487. /**
  20488. * In case the RTT has been created with a depth texture, get the associated
  20489. * depth texture.
  20490. * Otherwise, return null.
  20491. */
  20492. depthStencilTexture: Nullable<InternalTexture>;
  20493. /**
  20494. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20495. * or used a shadow, depth texture...
  20496. * @param name The friendly name of the texture
  20497. * @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)
  20498. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20499. * @param generateMipMaps True if mip maps need to be generated after render.
  20500. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20501. * @param type The type of the buffer in the RTT (int, half float, float...)
  20502. * @param isCube True if a cube texture needs to be created
  20503. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20504. * @param generateDepthBuffer True to generate a depth buffer
  20505. * @param generateStencilBuffer True to generate a stencil buffer
  20506. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20507. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20508. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20509. */
  20510. constructor(name: string, size: number | {
  20511. width: number;
  20512. height: number;
  20513. } | {
  20514. ratio: number;
  20515. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20516. /**
  20517. * Creates a depth stencil texture.
  20518. * This is only available in WebGL 2 or with the depth texture extension available.
  20519. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20520. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20521. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20522. */
  20523. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20524. private _processSizeParameter;
  20525. /**
  20526. * Define the number of samples to use in case of MSAA.
  20527. * It defaults to one meaning no MSAA has been enabled.
  20528. */
  20529. samples: number;
  20530. /**
  20531. * Resets the refresh counter of the texture and start bak from scratch.
  20532. * Could be useful to regenerate the texture if it is setup to render only once.
  20533. */
  20534. resetRefreshCounter(): void;
  20535. /**
  20536. * Define the refresh rate of the texture or the rendering frequency.
  20537. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20538. */
  20539. refreshRate: number;
  20540. /**
  20541. * Adds a post process to the render target rendering passes.
  20542. * @param postProcess define the post process to add
  20543. */
  20544. addPostProcess(postProcess: PostProcess): void;
  20545. /**
  20546. * Clear all the post processes attached to the render target
  20547. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20548. */
  20549. clearPostProcesses(dispose?: boolean): void;
  20550. /**
  20551. * Remove one of the post process from the list of attached post processes to the texture
  20552. * @param postProcess define the post process to remove from the list
  20553. */
  20554. removePostProcess(postProcess: PostProcess): void;
  20555. /** @hidden */
  20556. _shouldRender(): boolean;
  20557. /**
  20558. * Gets the actual render size of the texture.
  20559. * @returns the width of the render size
  20560. */
  20561. getRenderSize(): number;
  20562. /**
  20563. * Gets the actual render width of the texture.
  20564. * @returns the width of the render size
  20565. */
  20566. getRenderWidth(): number;
  20567. /**
  20568. * Gets the actual render height of the texture.
  20569. * @returns the height of the render size
  20570. */
  20571. getRenderHeight(): number;
  20572. /**
  20573. * Get if the texture can be rescaled or not.
  20574. */
  20575. readonly canRescale: boolean;
  20576. /**
  20577. * Resize the texture using a ratio.
  20578. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20579. */
  20580. scale(ratio: number): void;
  20581. /**
  20582. * Get the texture reflection matrix used to rotate/transform the reflection.
  20583. * @returns the reflection matrix
  20584. */
  20585. getReflectionTextureMatrix(): Matrix;
  20586. /**
  20587. * Resize the texture to a new desired size.
  20588. * Be carrefull as it will recreate all the data in the new texture.
  20589. * @param size Define the new size. It can be:
  20590. * - a number for squared texture,
  20591. * - an object containing { width: number, height: number }
  20592. * - or an object containing a ratio { ratio: number }
  20593. */
  20594. resize(size: number | {
  20595. width: number;
  20596. height: number;
  20597. } | {
  20598. ratio: number;
  20599. }): void;
  20600. /**
  20601. * Renders all the objects from the render list into the texture.
  20602. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20603. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20604. */
  20605. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20606. private _bestReflectionRenderTargetDimension;
  20607. /**
  20608. * @hidden
  20609. * @param faceIndex face index to bind to if this is a cubetexture
  20610. */
  20611. _bindFrameBuffer(faceIndex?: number): void;
  20612. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20613. private renderToTarget;
  20614. /**
  20615. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20616. * This allowed control for front to back rendering or reversly depending of the special needs.
  20617. *
  20618. * @param renderingGroupId The rendering group id corresponding to its index
  20619. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20620. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20621. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20622. */
  20623. 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;
  20624. /**
  20625. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20626. *
  20627. * @param renderingGroupId The rendering group id corresponding to its index
  20628. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20629. */
  20630. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20631. /**
  20632. * Clones the texture.
  20633. * @returns the cloned texture
  20634. */
  20635. clone(): RenderTargetTexture;
  20636. /**
  20637. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20638. * @returns The JSON representation of the texture
  20639. */
  20640. serialize(): any;
  20641. /**
  20642. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20643. */
  20644. disposeFramebufferObjects(): void;
  20645. /**
  20646. * Dispose the texture and release its associated resources.
  20647. */
  20648. dispose(): void;
  20649. /** @hidden */
  20650. _rebuild(): void;
  20651. /**
  20652. * Clear the info related to rendering groups preventing retention point in material dispose.
  20653. */
  20654. freeRenderingGroups(): void;
  20655. /**
  20656. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20657. * @returns the view count
  20658. */
  20659. getViewCount(): number;
  20660. }
  20661. }
  20662. declare module "babylonjs/Materials/material" {
  20663. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20664. import { SmartArray } from "babylonjs/Misc/smartArray";
  20665. import { Observable } from "babylonjs/Misc/observable";
  20666. import { Nullable } from "babylonjs/types";
  20667. import { Scene } from "babylonjs/scene";
  20668. import { Matrix } from "babylonjs/Maths/math.vector";
  20669. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20671. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20672. import { Effect } from "babylonjs/Materials/effect";
  20673. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20674. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20675. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20676. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20677. import { Mesh } from "babylonjs/Meshes/mesh";
  20678. import { Animation } from "babylonjs/Animations/animation";
  20679. /**
  20680. * Base class for the main features of a material in Babylon.js
  20681. */
  20682. export class Material implements IAnimatable {
  20683. /**
  20684. * Returns the triangle fill mode
  20685. */
  20686. static readonly TriangleFillMode: number;
  20687. /**
  20688. * Returns the wireframe mode
  20689. */
  20690. static readonly WireFrameFillMode: number;
  20691. /**
  20692. * Returns the point fill mode
  20693. */
  20694. static readonly PointFillMode: number;
  20695. /**
  20696. * Returns the point list draw mode
  20697. */
  20698. static readonly PointListDrawMode: number;
  20699. /**
  20700. * Returns the line list draw mode
  20701. */
  20702. static readonly LineListDrawMode: number;
  20703. /**
  20704. * Returns the line loop draw mode
  20705. */
  20706. static readonly LineLoopDrawMode: number;
  20707. /**
  20708. * Returns the line strip draw mode
  20709. */
  20710. static readonly LineStripDrawMode: number;
  20711. /**
  20712. * Returns the triangle strip draw mode
  20713. */
  20714. static readonly TriangleStripDrawMode: number;
  20715. /**
  20716. * Returns the triangle fan draw mode
  20717. */
  20718. static readonly TriangleFanDrawMode: number;
  20719. /**
  20720. * Stores the clock-wise side orientation
  20721. */
  20722. static readonly ClockWiseSideOrientation: number;
  20723. /**
  20724. * Stores the counter clock-wise side orientation
  20725. */
  20726. static readonly CounterClockWiseSideOrientation: number;
  20727. /**
  20728. * The dirty texture flag value
  20729. */
  20730. static readonly TextureDirtyFlag: number;
  20731. /**
  20732. * The dirty light flag value
  20733. */
  20734. static readonly LightDirtyFlag: number;
  20735. /**
  20736. * The dirty fresnel flag value
  20737. */
  20738. static readonly FresnelDirtyFlag: number;
  20739. /**
  20740. * The dirty attribute flag value
  20741. */
  20742. static readonly AttributesDirtyFlag: number;
  20743. /**
  20744. * The dirty misc flag value
  20745. */
  20746. static readonly MiscDirtyFlag: number;
  20747. /**
  20748. * The all dirty flag value
  20749. */
  20750. static readonly AllDirtyFlag: number;
  20751. /**
  20752. * The ID of the material
  20753. */
  20754. id: string;
  20755. /**
  20756. * Gets or sets the unique id of the material
  20757. */
  20758. uniqueId: number;
  20759. /**
  20760. * The name of the material
  20761. */
  20762. name: string;
  20763. /**
  20764. * Gets or sets user defined metadata
  20765. */
  20766. metadata: any;
  20767. /**
  20768. * For internal use only. Please do not use.
  20769. */
  20770. reservedDataStore: any;
  20771. /**
  20772. * Specifies if the ready state should be checked on each call
  20773. */
  20774. checkReadyOnEveryCall: boolean;
  20775. /**
  20776. * Specifies if the ready state should be checked once
  20777. */
  20778. checkReadyOnlyOnce: boolean;
  20779. /**
  20780. * The state of the material
  20781. */
  20782. state: string;
  20783. /**
  20784. * The alpha value of the material
  20785. */
  20786. protected _alpha: number;
  20787. /**
  20788. * List of inspectable custom properties (used by the Inspector)
  20789. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20790. */
  20791. inspectableCustomProperties: IInspectable[];
  20792. /**
  20793. * Sets the alpha value of the material
  20794. */
  20795. /**
  20796. * Gets the alpha value of the material
  20797. */
  20798. alpha: number;
  20799. /**
  20800. * Specifies if back face culling is enabled
  20801. */
  20802. protected _backFaceCulling: boolean;
  20803. /**
  20804. * Sets the back-face culling state
  20805. */
  20806. /**
  20807. * Gets the back-face culling state
  20808. */
  20809. backFaceCulling: boolean;
  20810. /**
  20811. * Stores the value for side orientation
  20812. */
  20813. sideOrientation: number;
  20814. /**
  20815. * Callback triggered when the material is compiled
  20816. */
  20817. onCompiled: Nullable<(effect: Effect) => void>;
  20818. /**
  20819. * Callback triggered when an error occurs
  20820. */
  20821. onError: Nullable<(effect: Effect, errors: string) => void>;
  20822. /**
  20823. * Callback triggered to get the render target textures
  20824. */
  20825. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20826. /**
  20827. * Gets a boolean indicating that current material needs to register RTT
  20828. */
  20829. readonly hasRenderTargetTextures: boolean;
  20830. /**
  20831. * Specifies if the material should be serialized
  20832. */
  20833. doNotSerialize: boolean;
  20834. /**
  20835. * @hidden
  20836. */
  20837. _storeEffectOnSubMeshes: boolean;
  20838. /**
  20839. * Stores the animations for the material
  20840. */
  20841. animations: Nullable<Array<Animation>>;
  20842. /**
  20843. * An event triggered when the material is disposed
  20844. */
  20845. onDisposeObservable: Observable<Material>;
  20846. /**
  20847. * An observer which watches for dispose events
  20848. */
  20849. private _onDisposeObserver;
  20850. private _onUnBindObservable;
  20851. /**
  20852. * Called during a dispose event
  20853. */
  20854. onDispose: () => void;
  20855. private _onBindObservable;
  20856. /**
  20857. * An event triggered when the material is bound
  20858. */
  20859. readonly onBindObservable: Observable<AbstractMesh>;
  20860. /**
  20861. * An observer which watches for bind events
  20862. */
  20863. private _onBindObserver;
  20864. /**
  20865. * Called during a bind event
  20866. */
  20867. onBind: (Mesh: AbstractMesh) => void;
  20868. /**
  20869. * An event triggered when the material is unbound
  20870. */
  20871. readonly onUnBindObservable: Observable<Material>;
  20872. /**
  20873. * Stores the value of the alpha mode
  20874. */
  20875. private _alphaMode;
  20876. /**
  20877. * Sets the value of the alpha mode.
  20878. *
  20879. * | Value | Type | Description |
  20880. * | --- | --- | --- |
  20881. * | 0 | ALPHA_DISABLE | |
  20882. * | 1 | ALPHA_ADD | |
  20883. * | 2 | ALPHA_COMBINE | |
  20884. * | 3 | ALPHA_SUBTRACT | |
  20885. * | 4 | ALPHA_MULTIPLY | |
  20886. * | 5 | ALPHA_MAXIMIZED | |
  20887. * | 6 | ALPHA_ONEONE | |
  20888. * | 7 | ALPHA_PREMULTIPLIED | |
  20889. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20890. * | 9 | ALPHA_INTERPOLATE | |
  20891. * | 10 | ALPHA_SCREENMODE | |
  20892. *
  20893. */
  20894. /**
  20895. * Gets the value of the alpha mode
  20896. */
  20897. alphaMode: number;
  20898. /**
  20899. * Stores the state of the need depth pre-pass value
  20900. */
  20901. private _needDepthPrePass;
  20902. /**
  20903. * Sets the need depth pre-pass value
  20904. */
  20905. /**
  20906. * Gets the depth pre-pass value
  20907. */
  20908. needDepthPrePass: boolean;
  20909. /**
  20910. * Specifies if depth writing should be disabled
  20911. */
  20912. disableDepthWrite: boolean;
  20913. /**
  20914. * Specifies if depth writing should be forced
  20915. */
  20916. forceDepthWrite: boolean;
  20917. /**
  20918. * Specifies if there should be a separate pass for culling
  20919. */
  20920. separateCullingPass: boolean;
  20921. /**
  20922. * Stores the state specifing if fog should be enabled
  20923. */
  20924. private _fogEnabled;
  20925. /**
  20926. * Sets the state for enabling fog
  20927. */
  20928. /**
  20929. * Gets the value of the fog enabled state
  20930. */
  20931. fogEnabled: boolean;
  20932. /**
  20933. * Stores the size of points
  20934. */
  20935. pointSize: number;
  20936. /**
  20937. * Stores the z offset value
  20938. */
  20939. zOffset: number;
  20940. /**
  20941. * Gets a value specifying if wireframe mode is enabled
  20942. */
  20943. /**
  20944. * Sets the state of wireframe mode
  20945. */
  20946. wireframe: boolean;
  20947. /**
  20948. * Gets the value specifying if point clouds are enabled
  20949. */
  20950. /**
  20951. * Sets the state of point cloud mode
  20952. */
  20953. pointsCloud: boolean;
  20954. /**
  20955. * Gets the material fill mode
  20956. */
  20957. /**
  20958. * Sets the material fill mode
  20959. */
  20960. fillMode: number;
  20961. /**
  20962. * @hidden
  20963. * Stores the effects for the material
  20964. */
  20965. _effect: Nullable<Effect>;
  20966. /**
  20967. * @hidden
  20968. * Specifies if the material was previously ready
  20969. */
  20970. _wasPreviouslyReady: boolean;
  20971. /**
  20972. * Specifies if uniform buffers should be used
  20973. */
  20974. private _useUBO;
  20975. /**
  20976. * Stores a reference to the scene
  20977. */
  20978. private _scene;
  20979. /**
  20980. * Stores the fill mode state
  20981. */
  20982. private _fillMode;
  20983. /**
  20984. * Specifies if the depth write state should be cached
  20985. */
  20986. private _cachedDepthWriteState;
  20987. /**
  20988. * Stores the uniform buffer
  20989. */
  20990. protected _uniformBuffer: UniformBuffer;
  20991. /** @hidden */
  20992. _indexInSceneMaterialArray: number;
  20993. /** @hidden */
  20994. meshMap: Nullable<{
  20995. [id: string]: AbstractMesh | undefined;
  20996. }>;
  20997. /**
  20998. * Creates a material instance
  20999. * @param name defines the name of the material
  21000. * @param scene defines the scene to reference
  21001. * @param doNotAdd specifies if the material should be added to the scene
  21002. */
  21003. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21004. /**
  21005. * Returns a string representation of the current material
  21006. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21007. * @returns a string with material information
  21008. */
  21009. toString(fullDetails?: boolean): string;
  21010. /**
  21011. * Gets the class name of the material
  21012. * @returns a string with the class name of the material
  21013. */
  21014. getClassName(): string;
  21015. /**
  21016. * Specifies if updates for the material been locked
  21017. */
  21018. readonly isFrozen: boolean;
  21019. /**
  21020. * Locks updates for the material
  21021. */
  21022. freeze(): void;
  21023. /**
  21024. * Unlocks updates for the material
  21025. */
  21026. unfreeze(): void;
  21027. /**
  21028. * Specifies if the material is ready to be used
  21029. * @param mesh defines the mesh to check
  21030. * @param useInstances specifies if instances should be used
  21031. * @returns a boolean indicating if the material is ready to be used
  21032. */
  21033. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21034. /**
  21035. * Specifies that the submesh is ready to be used
  21036. * @param mesh defines the mesh to check
  21037. * @param subMesh defines which submesh to check
  21038. * @param useInstances specifies that instances should be used
  21039. * @returns a boolean indicating that the submesh is ready or not
  21040. */
  21041. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21042. /**
  21043. * Returns the material effect
  21044. * @returns the effect associated with the material
  21045. */
  21046. getEffect(): Nullable<Effect>;
  21047. /**
  21048. * Returns the current scene
  21049. * @returns a Scene
  21050. */
  21051. getScene(): Scene;
  21052. /**
  21053. * Specifies if the material will require alpha blending
  21054. * @returns a boolean specifying if alpha blending is needed
  21055. */
  21056. needAlphaBlending(): boolean;
  21057. /**
  21058. * Specifies if the mesh will require alpha blending
  21059. * @param mesh defines the mesh to check
  21060. * @returns a boolean specifying if alpha blending is needed for the mesh
  21061. */
  21062. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21063. /**
  21064. * Specifies if this material should be rendered in alpha test mode
  21065. * @returns a boolean specifying if an alpha test is needed.
  21066. */
  21067. needAlphaTesting(): boolean;
  21068. /**
  21069. * Gets the texture used for the alpha test
  21070. * @returns the texture to use for alpha testing
  21071. */
  21072. getAlphaTestTexture(): Nullable<BaseTexture>;
  21073. /**
  21074. * Marks the material to indicate that it needs to be re-calculated
  21075. */
  21076. markDirty(): void;
  21077. /** @hidden */
  21078. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21079. /**
  21080. * Binds the material to the mesh
  21081. * @param world defines the world transformation matrix
  21082. * @param mesh defines the mesh to bind the material to
  21083. */
  21084. bind(world: Matrix, mesh?: Mesh): void;
  21085. /**
  21086. * Binds the submesh to the material
  21087. * @param world defines the world transformation matrix
  21088. * @param mesh defines the mesh containing the submesh
  21089. * @param subMesh defines the submesh to bind the material to
  21090. */
  21091. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21092. /**
  21093. * Binds the world matrix to the material
  21094. * @param world defines the world transformation matrix
  21095. */
  21096. bindOnlyWorldMatrix(world: Matrix): void;
  21097. /**
  21098. * Binds the scene's uniform buffer to the effect.
  21099. * @param effect defines the effect to bind to the scene uniform buffer
  21100. * @param sceneUbo defines the uniform buffer storing scene data
  21101. */
  21102. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21103. /**
  21104. * Binds the view matrix to the effect
  21105. * @param effect defines the effect to bind the view matrix to
  21106. */
  21107. bindView(effect: Effect): void;
  21108. /**
  21109. * Binds the view projection matrix to the effect
  21110. * @param effect defines the effect to bind the view projection matrix to
  21111. */
  21112. bindViewProjection(effect: Effect): void;
  21113. /**
  21114. * Specifies if material alpha testing should be turned on for the mesh
  21115. * @param mesh defines the mesh to check
  21116. */
  21117. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21118. /**
  21119. * Processes to execute after binding the material to a mesh
  21120. * @param mesh defines the rendered mesh
  21121. */
  21122. protected _afterBind(mesh?: Mesh): void;
  21123. /**
  21124. * Unbinds the material from the mesh
  21125. */
  21126. unbind(): void;
  21127. /**
  21128. * Gets the active textures from the material
  21129. * @returns an array of textures
  21130. */
  21131. getActiveTextures(): BaseTexture[];
  21132. /**
  21133. * Specifies if the material uses a texture
  21134. * @param texture defines the texture to check against the material
  21135. * @returns a boolean specifying if the material uses the texture
  21136. */
  21137. hasTexture(texture: BaseTexture): boolean;
  21138. /**
  21139. * Makes a duplicate of the material, and gives it a new name
  21140. * @param name defines the new name for the duplicated material
  21141. * @returns the cloned material
  21142. */
  21143. clone(name: string): Nullable<Material>;
  21144. /**
  21145. * Gets the meshes bound to the material
  21146. * @returns an array of meshes bound to the material
  21147. */
  21148. getBindedMeshes(): AbstractMesh[];
  21149. /**
  21150. * Force shader compilation
  21151. * @param mesh defines the mesh associated with this material
  21152. * @param onCompiled defines a function to execute once the material is compiled
  21153. * @param options defines the options to configure the compilation
  21154. * @param onError defines a function to execute if the material fails compiling
  21155. */
  21156. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21157. clipPlane: boolean;
  21158. }>, onError?: (reason: string) => void): void;
  21159. /**
  21160. * Force shader compilation
  21161. * @param mesh defines the mesh that will use this material
  21162. * @param options defines additional options for compiling the shaders
  21163. * @returns a promise that resolves when the compilation completes
  21164. */
  21165. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21166. clipPlane: boolean;
  21167. }>): Promise<void>;
  21168. private static readonly _AllDirtyCallBack;
  21169. private static readonly _ImageProcessingDirtyCallBack;
  21170. private static readonly _TextureDirtyCallBack;
  21171. private static readonly _FresnelDirtyCallBack;
  21172. private static readonly _MiscDirtyCallBack;
  21173. private static readonly _LightsDirtyCallBack;
  21174. private static readonly _AttributeDirtyCallBack;
  21175. private static _FresnelAndMiscDirtyCallBack;
  21176. private static _TextureAndMiscDirtyCallBack;
  21177. private static readonly _DirtyCallbackArray;
  21178. private static readonly _RunDirtyCallBacks;
  21179. /**
  21180. * Marks a define in the material to indicate that it needs to be re-computed
  21181. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21182. */
  21183. markAsDirty(flag: number): void;
  21184. /**
  21185. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21186. * @param func defines a function which checks material defines against the submeshes
  21187. */
  21188. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21189. /**
  21190. * Indicates that we need to re-calculated for all submeshes
  21191. */
  21192. protected _markAllSubMeshesAsAllDirty(): void;
  21193. /**
  21194. * Indicates that image processing needs to be re-calculated for all submeshes
  21195. */
  21196. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21197. /**
  21198. * Indicates that textures need to be re-calculated for all submeshes
  21199. */
  21200. protected _markAllSubMeshesAsTexturesDirty(): void;
  21201. /**
  21202. * Indicates that fresnel needs to be re-calculated for all submeshes
  21203. */
  21204. protected _markAllSubMeshesAsFresnelDirty(): void;
  21205. /**
  21206. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21207. */
  21208. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21209. /**
  21210. * Indicates that lights need to be re-calculated for all submeshes
  21211. */
  21212. protected _markAllSubMeshesAsLightsDirty(): void;
  21213. /**
  21214. * Indicates that attributes need to be re-calculated for all submeshes
  21215. */
  21216. protected _markAllSubMeshesAsAttributesDirty(): void;
  21217. /**
  21218. * Indicates that misc needs to be re-calculated for all submeshes
  21219. */
  21220. protected _markAllSubMeshesAsMiscDirty(): void;
  21221. /**
  21222. * Indicates that textures and misc need to be re-calculated for all submeshes
  21223. */
  21224. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21225. /**
  21226. * Disposes the material
  21227. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21228. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21229. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21230. */
  21231. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21232. /** @hidden */
  21233. private releaseVertexArrayObject;
  21234. /**
  21235. * Serializes this material
  21236. * @returns the serialized material object
  21237. */
  21238. serialize(): any;
  21239. /**
  21240. * Creates a material from parsed material data
  21241. * @param parsedMaterial defines parsed material data
  21242. * @param scene defines the hosting scene
  21243. * @param rootUrl defines the root URL to use to load textures
  21244. * @returns a new material
  21245. */
  21246. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21247. }
  21248. }
  21249. declare module "babylonjs/Materials/multiMaterial" {
  21250. import { Nullable } from "babylonjs/types";
  21251. import { Scene } from "babylonjs/scene";
  21252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21253. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21255. import { Material } from "babylonjs/Materials/material";
  21256. /**
  21257. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21258. * separate meshes. This can be use to improve performances.
  21259. * @see http://doc.babylonjs.com/how_to/multi_materials
  21260. */
  21261. export class MultiMaterial extends Material {
  21262. private _subMaterials;
  21263. /**
  21264. * Gets or Sets the list of Materials used within the multi material.
  21265. * They need to be ordered according to the submeshes order in the associated mesh
  21266. */
  21267. subMaterials: Nullable<Material>[];
  21268. /**
  21269. * Function used to align with Node.getChildren()
  21270. * @returns the list of Materials used within the multi material
  21271. */
  21272. getChildren(): Nullable<Material>[];
  21273. /**
  21274. * Instantiates a new Multi Material
  21275. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21276. * separate meshes. This can be use to improve performances.
  21277. * @see http://doc.babylonjs.com/how_to/multi_materials
  21278. * @param name Define the name in the scene
  21279. * @param scene Define the scene the material belongs to
  21280. */
  21281. constructor(name: string, scene: Scene);
  21282. private _hookArray;
  21283. /**
  21284. * Get one of the submaterial by its index in the submaterials array
  21285. * @param index The index to look the sub material at
  21286. * @returns The Material if the index has been defined
  21287. */
  21288. getSubMaterial(index: number): Nullable<Material>;
  21289. /**
  21290. * Get the list of active textures for the whole sub materials list.
  21291. * @returns All the textures that will be used during the rendering
  21292. */
  21293. getActiveTextures(): BaseTexture[];
  21294. /**
  21295. * Gets the current class name of the material e.g. "MultiMaterial"
  21296. * Mainly use in serialization.
  21297. * @returns the class name
  21298. */
  21299. getClassName(): string;
  21300. /**
  21301. * Checks if the material is ready to render the requested sub mesh
  21302. * @param mesh Define the mesh the submesh belongs to
  21303. * @param subMesh Define the sub mesh to look readyness for
  21304. * @param useInstances Define whether or not the material is used with instances
  21305. * @returns true if ready, otherwise false
  21306. */
  21307. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21308. /**
  21309. * Clones the current material and its related sub materials
  21310. * @param name Define the name of the newly cloned material
  21311. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21312. * @returns the cloned material
  21313. */
  21314. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21315. /**
  21316. * Serializes the materials into a JSON representation.
  21317. * @returns the JSON representation
  21318. */
  21319. serialize(): any;
  21320. /**
  21321. * Dispose the material and release its associated resources
  21322. * @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)
  21323. * @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)
  21324. * @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)
  21325. */
  21326. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21327. /**
  21328. * Creates a MultiMaterial from parsed MultiMaterial data.
  21329. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21330. * @param scene defines the hosting scene
  21331. * @returns a new MultiMaterial
  21332. */
  21333. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21334. }
  21335. }
  21336. declare module "babylonjs/Meshes/subMesh" {
  21337. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21338. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21339. import { Engine } from "babylonjs/Engines/engine";
  21340. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21341. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21342. import { Effect } from "babylonjs/Materials/effect";
  21343. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21344. import { Plane } from "babylonjs/Maths/math.plane";
  21345. import { Collider } from "babylonjs/Collisions/collider";
  21346. import { Material } from "babylonjs/Materials/material";
  21347. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21349. import { Mesh } from "babylonjs/Meshes/mesh";
  21350. import { Ray } from "babylonjs/Culling/ray";
  21351. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21352. /**
  21353. * Base class for submeshes
  21354. */
  21355. export class BaseSubMesh {
  21356. /** @hidden */
  21357. _materialDefines: Nullable<MaterialDefines>;
  21358. /** @hidden */
  21359. _materialEffect: Nullable<Effect>;
  21360. /**
  21361. * Gets associated effect
  21362. */
  21363. readonly effect: Nullable<Effect>;
  21364. /**
  21365. * Sets associated effect (effect used to render this submesh)
  21366. * @param effect defines the effect to associate with
  21367. * @param defines defines the set of defines used to compile this effect
  21368. */
  21369. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21370. }
  21371. /**
  21372. * Defines a subdivision inside a mesh
  21373. */
  21374. export class SubMesh extends BaseSubMesh implements ICullable {
  21375. /** the material index to use */
  21376. materialIndex: number;
  21377. /** vertex index start */
  21378. verticesStart: number;
  21379. /** vertices count */
  21380. verticesCount: number;
  21381. /** index start */
  21382. indexStart: number;
  21383. /** indices count */
  21384. indexCount: number;
  21385. /** @hidden */
  21386. _linesIndexCount: number;
  21387. private _mesh;
  21388. private _renderingMesh;
  21389. private _boundingInfo;
  21390. private _linesIndexBuffer;
  21391. /** @hidden */
  21392. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21393. /** @hidden */
  21394. _trianglePlanes: Plane[];
  21395. /** @hidden */
  21396. _lastColliderTransformMatrix: Nullable<Matrix>;
  21397. /** @hidden */
  21398. _renderId: number;
  21399. /** @hidden */
  21400. _alphaIndex: number;
  21401. /** @hidden */
  21402. _distanceToCamera: number;
  21403. /** @hidden */
  21404. _id: number;
  21405. private _currentMaterial;
  21406. /**
  21407. * Add a new submesh to a mesh
  21408. * @param materialIndex defines the material index to use
  21409. * @param verticesStart defines vertex index start
  21410. * @param verticesCount defines vertices count
  21411. * @param indexStart defines index start
  21412. * @param indexCount defines indices count
  21413. * @param mesh defines the parent mesh
  21414. * @param renderingMesh defines an optional rendering mesh
  21415. * @param createBoundingBox defines if bounding box should be created for this submesh
  21416. * @returns the new submesh
  21417. */
  21418. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21419. /**
  21420. * Creates a new submesh
  21421. * @param materialIndex defines the material index to use
  21422. * @param verticesStart defines vertex index start
  21423. * @param verticesCount defines vertices count
  21424. * @param indexStart defines index start
  21425. * @param indexCount defines indices count
  21426. * @param mesh defines the parent mesh
  21427. * @param renderingMesh defines an optional rendering mesh
  21428. * @param createBoundingBox defines if bounding box should be created for this submesh
  21429. */
  21430. constructor(
  21431. /** the material index to use */
  21432. materialIndex: number,
  21433. /** vertex index start */
  21434. verticesStart: number,
  21435. /** vertices count */
  21436. verticesCount: number,
  21437. /** index start */
  21438. indexStart: number,
  21439. /** indices count */
  21440. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21441. /**
  21442. * Returns true if this submesh covers the entire parent mesh
  21443. * @ignorenaming
  21444. */
  21445. readonly IsGlobal: boolean;
  21446. /**
  21447. * Returns the submesh BoudingInfo object
  21448. * @returns current bounding info (or mesh's one if the submesh is global)
  21449. */
  21450. getBoundingInfo(): BoundingInfo;
  21451. /**
  21452. * Sets the submesh BoundingInfo
  21453. * @param boundingInfo defines the new bounding info to use
  21454. * @returns the SubMesh
  21455. */
  21456. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21457. /**
  21458. * Returns the mesh of the current submesh
  21459. * @return the parent mesh
  21460. */
  21461. getMesh(): AbstractMesh;
  21462. /**
  21463. * Returns the rendering mesh of the submesh
  21464. * @returns the rendering mesh (could be different from parent mesh)
  21465. */
  21466. getRenderingMesh(): Mesh;
  21467. /**
  21468. * Returns the submesh material
  21469. * @returns null or the current material
  21470. */
  21471. getMaterial(): Nullable<Material>;
  21472. /**
  21473. * Sets a new updated BoundingInfo object to the submesh
  21474. * @param data defines an optional position array to use to determine the bounding info
  21475. * @returns the SubMesh
  21476. */
  21477. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21478. /** @hidden */
  21479. _checkCollision(collider: Collider): boolean;
  21480. /**
  21481. * Updates the submesh BoundingInfo
  21482. * @param world defines the world matrix to use to update the bounding info
  21483. * @returns the submesh
  21484. */
  21485. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21486. /**
  21487. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21488. * @param frustumPlanes defines the frustum planes
  21489. * @returns true if the submesh is intersecting with the frustum
  21490. */
  21491. isInFrustum(frustumPlanes: Plane[]): boolean;
  21492. /**
  21493. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21494. * @param frustumPlanes defines the frustum planes
  21495. * @returns true if the submesh is inside the frustum
  21496. */
  21497. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21498. /**
  21499. * Renders the submesh
  21500. * @param enableAlphaMode defines if alpha needs to be used
  21501. * @returns the submesh
  21502. */
  21503. render(enableAlphaMode: boolean): SubMesh;
  21504. /**
  21505. * @hidden
  21506. */
  21507. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21508. /**
  21509. * Checks if the submesh intersects with a ray
  21510. * @param ray defines the ray to test
  21511. * @returns true is the passed ray intersects the submesh bounding box
  21512. */
  21513. canIntersects(ray: Ray): boolean;
  21514. /**
  21515. * Intersects current submesh with a ray
  21516. * @param ray defines the ray to test
  21517. * @param positions defines mesh's positions array
  21518. * @param indices defines mesh's indices array
  21519. * @param fastCheck defines if only bounding info should be used
  21520. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21521. * @returns intersection info or null if no intersection
  21522. */
  21523. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21524. /** @hidden */
  21525. private _intersectLines;
  21526. /** @hidden */
  21527. private _intersectUnIndexedLines;
  21528. /** @hidden */
  21529. private _intersectTriangles;
  21530. /** @hidden */
  21531. private _intersectUnIndexedTriangles;
  21532. /** @hidden */
  21533. _rebuild(): void;
  21534. /**
  21535. * Creates a new submesh from the passed mesh
  21536. * @param newMesh defines the new hosting mesh
  21537. * @param newRenderingMesh defines an optional rendering mesh
  21538. * @returns the new submesh
  21539. */
  21540. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21541. /**
  21542. * Release associated resources
  21543. */
  21544. dispose(): void;
  21545. /**
  21546. * Gets the class name
  21547. * @returns the string "SubMesh".
  21548. */
  21549. getClassName(): string;
  21550. /**
  21551. * Creates a new submesh from indices data
  21552. * @param materialIndex the index of the main mesh material
  21553. * @param startIndex the index where to start the copy in the mesh indices array
  21554. * @param indexCount the number of indices to copy then from the startIndex
  21555. * @param mesh the main mesh to create the submesh from
  21556. * @param renderingMesh the optional rendering mesh
  21557. * @returns a new submesh
  21558. */
  21559. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21560. }
  21561. }
  21562. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21563. /**
  21564. * Class used to represent data loading progression
  21565. */
  21566. export class SceneLoaderFlags {
  21567. private static _ForceFullSceneLoadingForIncremental;
  21568. private static _ShowLoadingScreen;
  21569. private static _CleanBoneMatrixWeights;
  21570. private static _loggingLevel;
  21571. /**
  21572. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21573. */
  21574. static ForceFullSceneLoadingForIncremental: boolean;
  21575. /**
  21576. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21577. */
  21578. static ShowLoadingScreen: boolean;
  21579. /**
  21580. * Defines the current logging level (while loading the scene)
  21581. * @ignorenaming
  21582. */
  21583. static loggingLevel: number;
  21584. /**
  21585. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21586. */
  21587. static CleanBoneMatrixWeights: boolean;
  21588. }
  21589. }
  21590. declare module "babylonjs/Meshes/geometry" {
  21591. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21592. import { Scene } from "babylonjs/scene";
  21593. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21594. import { Engine } from "babylonjs/Engines/engine";
  21595. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21596. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21597. import { Effect } from "babylonjs/Materials/effect";
  21598. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21599. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21600. import { Mesh } from "babylonjs/Meshes/mesh";
  21601. /**
  21602. * Class used to store geometry data (vertex buffers + index buffer)
  21603. */
  21604. export class Geometry implements IGetSetVerticesData {
  21605. /**
  21606. * Gets or sets the ID of the geometry
  21607. */
  21608. id: string;
  21609. /**
  21610. * Gets or sets the unique ID of the geometry
  21611. */
  21612. uniqueId: number;
  21613. /**
  21614. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21615. */
  21616. delayLoadState: number;
  21617. /**
  21618. * Gets the file containing the data to load when running in delay load state
  21619. */
  21620. delayLoadingFile: Nullable<string>;
  21621. /**
  21622. * Callback called when the geometry is updated
  21623. */
  21624. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21625. private _scene;
  21626. private _engine;
  21627. private _meshes;
  21628. private _totalVertices;
  21629. /** @hidden */
  21630. _indices: IndicesArray;
  21631. /** @hidden */
  21632. _vertexBuffers: {
  21633. [key: string]: VertexBuffer;
  21634. };
  21635. private _isDisposed;
  21636. private _extend;
  21637. private _boundingBias;
  21638. /** @hidden */
  21639. _delayInfo: Array<string>;
  21640. private _indexBuffer;
  21641. private _indexBufferIsUpdatable;
  21642. /** @hidden */
  21643. _boundingInfo: Nullable<BoundingInfo>;
  21644. /** @hidden */
  21645. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21646. /** @hidden */
  21647. _softwareSkinningFrameId: number;
  21648. private _vertexArrayObjects;
  21649. private _updatable;
  21650. /** @hidden */
  21651. _positions: Nullable<Vector3[]>;
  21652. /**
  21653. * 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
  21654. */
  21655. /**
  21656. * 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
  21657. */
  21658. boundingBias: Vector2;
  21659. /**
  21660. * Static function used to attach a new empty geometry to a mesh
  21661. * @param mesh defines the mesh to attach the geometry to
  21662. * @returns the new Geometry
  21663. */
  21664. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21665. /**
  21666. * Creates a new geometry
  21667. * @param id defines the unique ID
  21668. * @param scene defines the hosting scene
  21669. * @param vertexData defines the VertexData used to get geometry data
  21670. * @param updatable defines if geometry must be updatable (false by default)
  21671. * @param mesh defines the mesh that will be associated with the geometry
  21672. */
  21673. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21674. /**
  21675. * Gets the current extend of the geometry
  21676. */
  21677. readonly extend: {
  21678. minimum: Vector3;
  21679. maximum: Vector3;
  21680. };
  21681. /**
  21682. * Gets the hosting scene
  21683. * @returns the hosting Scene
  21684. */
  21685. getScene(): Scene;
  21686. /**
  21687. * Gets the hosting engine
  21688. * @returns the hosting Engine
  21689. */
  21690. getEngine(): Engine;
  21691. /**
  21692. * Defines if the geometry is ready to use
  21693. * @returns true if the geometry is ready to be used
  21694. */
  21695. isReady(): boolean;
  21696. /**
  21697. * Gets a value indicating that the geometry should not be serialized
  21698. */
  21699. readonly doNotSerialize: boolean;
  21700. /** @hidden */
  21701. _rebuild(): void;
  21702. /**
  21703. * Affects all geometry data in one call
  21704. * @param vertexData defines the geometry data
  21705. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21706. */
  21707. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21708. /**
  21709. * Set specific vertex data
  21710. * @param kind defines the data kind (Position, normal, etc...)
  21711. * @param data defines the vertex data to use
  21712. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21713. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21714. */
  21715. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21716. /**
  21717. * Removes a specific vertex data
  21718. * @param kind defines the data kind (Position, normal, etc...)
  21719. */
  21720. removeVerticesData(kind: string): void;
  21721. /**
  21722. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21723. * @param buffer defines the vertex buffer to use
  21724. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21725. */
  21726. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21727. /**
  21728. * Update a specific vertex buffer
  21729. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21730. * It will do nothing if the buffer is not updatable
  21731. * @param kind defines the data kind (Position, normal, etc...)
  21732. * @param data defines the data to use
  21733. * @param offset defines the offset in the target buffer where to store the data
  21734. * @param useBytes set to true if the offset is in bytes
  21735. */
  21736. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21737. /**
  21738. * Update a specific vertex buffer
  21739. * This function will create a new buffer if the current one is not updatable
  21740. * @param kind defines the data kind (Position, normal, etc...)
  21741. * @param data defines the data to use
  21742. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21743. */
  21744. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21745. private _updateBoundingInfo;
  21746. /** @hidden */
  21747. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21748. /**
  21749. * Gets total number of vertices
  21750. * @returns the total number of vertices
  21751. */
  21752. getTotalVertices(): number;
  21753. /**
  21754. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21755. * @param kind defines the data kind (Position, normal, etc...)
  21756. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21757. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21758. * @returns a float array containing vertex data
  21759. */
  21760. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21761. /**
  21762. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21763. * @param kind defines the data kind (Position, normal, etc...)
  21764. * @returns true if the vertex buffer with the specified kind is updatable
  21765. */
  21766. isVertexBufferUpdatable(kind: string): boolean;
  21767. /**
  21768. * Gets a specific vertex buffer
  21769. * @param kind defines the data kind (Position, normal, etc...)
  21770. * @returns a VertexBuffer
  21771. */
  21772. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21773. /**
  21774. * Returns all vertex buffers
  21775. * @return an object holding all vertex buffers indexed by kind
  21776. */
  21777. getVertexBuffers(): Nullable<{
  21778. [key: string]: VertexBuffer;
  21779. }>;
  21780. /**
  21781. * Gets a boolean indicating if specific vertex buffer is present
  21782. * @param kind defines the data kind (Position, normal, etc...)
  21783. * @returns true if data is present
  21784. */
  21785. isVerticesDataPresent(kind: string): boolean;
  21786. /**
  21787. * Gets a list of all attached data kinds (Position, normal, etc...)
  21788. * @returns a list of string containing all kinds
  21789. */
  21790. getVerticesDataKinds(): string[];
  21791. /**
  21792. * Update index buffer
  21793. * @param indices defines the indices to store in the index buffer
  21794. * @param offset defines the offset in the target buffer where to store the data
  21795. * @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)
  21796. */
  21797. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21798. /**
  21799. * Creates a new index buffer
  21800. * @param indices defines the indices to store in the index buffer
  21801. * @param totalVertices defines the total number of vertices (could be null)
  21802. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21803. */
  21804. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21805. /**
  21806. * Return the total number of indices
  21807. * @returns the total number of indices
  21808. */
  21809. getTotalIndices(): number;
  21810. /**
  21811. * Gets the index buffer array
  21812. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21813. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21814. * @returns the index buffer array
  21815. */
  21816. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21817. /**
  21818. * Gets the index buffer
  21819. * @return the index buffer
  21820. */
  21821. getIndexBuffer(): Nullable<DataBuffer>;
  21822. /** @hidden */
  21823. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21824. /**
  21825. * Release the associated resources for a specific mesh
  21826. * @param mesh defines the source mesh
  21827. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21828. */
  21829. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21830. /**
  21831. * Apply current geometry to a given mesh
  21832. * @param mesh defines the mesh to apply geometry to
  21833. */
  21834. applyToMesh(mesh: Mesh): void;
  21835. private _updateExtend;
  21836. private _applyToMesh;
  21837. private notifyUpdate;
  21838. /**
  21839. * Load the geometry if it was flagged as delay loaded
  21840. * @param scene defines the hosting scene
  21841. * @param onLoaded defines a callback called when the geometry is loaded
  21842. */
  21843. load(scene: Scene, onLoaded?: () => void): void;
  21844. private _queueLoad;
  21845. /**
  21846. * Invert the geometry to move from a right handed system to a left handed one.
  21847. */
  21848. toLeftHanded(): void;
  21849. /** @hidden */
  21850. _resetPointsArrayCache(): void;
  21851. /** @hidden */
  21852. _generatePointsArray(): boolean;
  21853. /**
  21854. * Gets a value indicating if the geometry is disposed
  21855. * @returns true if the geometry was disposed
  21856. */
  21857. isDisposed(): boolean;
  21858. private _disposeVertexArrayObjects;
  21859. /**
  21860. * Free all associated resources
  21861. */
  21862. dispose(): void;
  21863. /**
  21864. * Clone the current geometry into a new geometry
  21865. * @param id defines the unique ID of the new geometry
  21866. * @returns a new geometry object
  21867. */
  21868. copy(id: string): Geometry;
  21869. /**
  21870. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21871. * @return a JSON representation of the current geometry data (without the vertices data)
  21872. */
  21873. serialize(): any;
  21874. private toNumberArray;
  21875. /**
  21876. * Serialize all vertices data into a JSON oject
  21877. * @returns a JSON representation of the current geometry data
  21878. */
  21879. serializeVerticeData(): any;
  21880. /**
  21881. * Extracts a clone of a mesh geometry
  21882. * @param mesh defines the source mesh
  21883. * @param id defines the unique ID of the new geometry object
  21884. * @returns the new geometry object
  21885. */
  21886. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21887. /**
  21888. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21889. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21890. * Be aware Math.random() could cause collisions, but:
  21891. * "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"
  21892. * @returns a string containing a new GUID
  21893. */
  21894. static RandomId(): string;
  21895. /** @hidden */
  21896. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21897. private static _CleanMatricesWeights;
  21898. /**
  21899. * Create a new geometry from persisted data (Using .babylon file format)
  21900. * @param parsedVertexData defines the persisted data
  21901. * @param scene defines the hosting scene
  21902. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21903. * @returns the new geometry object
  21904. */
  21905. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21906. }
  21907. }
  21908. declare module "babylonjs/Meshes/mesh.vertexData" {
  21909. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21910. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21911. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21912. import { Geometry } from "babylonjs/Meshes/geometry";
  21913. import { Mesh } from "babylonjs/Meshes/mesh";
  21914. /**
  21915. * Define an interface for all classes that will get and set the data on vertices
  21916. */
  21917. export interface IGetSetVerticesData {
  21918. /**
  21919. * Gets a boolean indicating if specific vertex data is present
  21920. * @param kind defines the vertex data kind to use
  21921. * @returns true is data kind is present
  21922. */
  21923. isVerticesDataPresent(kind: string): boolean;
  21924. /**
  21925. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21926. * @param kind defines the data kind (Position, normal, etc...)
  21927. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21928. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21929. * @returns a float array containing vertex data
  21930. */
  21931. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21932. /**
  21933. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21934. * @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.
  21935. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21936. * @returns the indices array or an empty array if the mesh has no geometry
  21937. */
  21938. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21939. /**
  21940. * Set specific vertex data
  21941. * @param kind defines the data kind (Position, normal, etc...)
  21942. * @param data defines the vertex data to use
  21943. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21944. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21945. */
  21946. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21947. /**
  21948. * Update a specific associated vertex buffer
  21949. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21950. * - VertexBuffer.PositionKind
  21951. * - VertexBuffer.UVKind
  21952. * - VertexBuffer.UV2Kind
  21953. * - VertexBuffer.UV3Kind
  21954. * - VertexBuffer.UV4Kind
  21955. * - VertexBuffer.UV5Kind
  21956. * - VertexBuffer.UV6Kind
  21957. * - VertexBuffer.ColorKind
  21958. * - VertexBuffer.MatricesIndicesKind
  21959. * - VertexBuffer.MatricesIndicesExtraKind
  21960. * - VertexBuffer.MatricesWeightsKind
  21961. * - VertexBuffer.MatricesWeightsExtraKind
  21962. * @param data defines the data source
  21963. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21964. * @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)
  21965. */
  21966. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21967. /**
  21968. * Creates a new index buffer
  21969. * @param indices defines the indices to store in the index buffer
  21970. * @param totalVertices defines the total number of vertices (could be null)
  21971. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21972. */
  21973. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21974. }
  21975. /**
  21976. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21977. */
  21978. export class VertexData {
  21979. /**
  21980. * Mesh side orientation : usually the external or front surface
  21981. */
  21982. static readonly FRONTSIDE: number;
  21983. /**
  21984. * Mesh side orientation : usually the internal or back surface
  21985. */
  21986. static readonly BACKSIDE: number;
  21987. /**
  21988. * Mesh side orientation : both internal and external or front and back surfaces
  21989. */
  21990. static readonly DOUBLESIDE: number;
  21991. /**
  21992. * Mesh side orientation : by default, `FRONTSIDE`
  21993. */
  21994. static readonly DEFAULTSIDE: number;
  21995. /**
  21996. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21997. */
  21998. positions: Nullable<FloatArray>;
  21999. /**
  22000. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22001. */
  22002. normals: Nullable<FloatArray>;
  22003. /**
  22004. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22005. */
  22006. tangents: Nullable<FloatArray>;
  22007. /**
  22008. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22009. */
  22010. uvs: Nullable<FloatArray>;
  22011. /**
  22012. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22013. */
  22014. uvs2: Nullable<FloatArray>;
  22015. /**
  22016. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22017. */
  22018. uvs3: Nullable<FloatArray>;
  22019. /**
  22020. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22021. */
  22022. uvs4: Nullable<FloatArray>;
  22023. /**
  22024. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22025. */
  22026. uvs5: Nullable<FloatArray>;
  22027. /**
  22028. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22029. */
  22030. uvs6: Nullable<FloatArray>;
  22031. /**
  22032. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22033. */
  22034. colors: Nullable<FloatArray>;
  22035. /**
  22036. * 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).
  22037. */
  22038. matricesIndices: Nullable<FloatArray>;
  22039. /**
  22040. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22041. */
  22042. matricesWeights: Nullable<FloatArray>;
  22043. /**
  22044. * An array extending the number of possible indices
  22045. */
  22046. matricesIndicesExtra: Nullable<FloatArray>;
  22047. /**
  22048. * An array extending the number of possible weights when the number of indices is extended
  22049. */
  22050. matricesWeightsExtra: Nullable<FloatArray>;
  22051. /**
  22052. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22053. */
  22054. indices: Nullable<IndicesArray>;
  22055. /**
  22056. * Uses the passed data array to set the set the values for the specified kind of data
  22057. * @param data a linear array of floating numbers
  22058. * @param kind the type of data that is being set, eg positions, colors etc
  22059. */
  22060. set(data: FloatArray, kind: string): void;
  22061. /**
  22062. * Associates the vertexData to the passed Mesh.
  22063. * Sets it as updatable or not (default `false`)
  22064. * @param mesh the mesh the vertexData is applied to
  22065. * @param updatable when used and having the value true allows new data to update the vertexData
  22066. * @returns the VertexData
  22067. */
  22068. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22069. /**
  22070. * Associates the vertexData to the passed Geometry.
  22071. * Sets it as updatable or not (default `false`)
  22072. * @param geometry the geometry the vertexData is applied to
  22073. * @param updatable when used and having the value true allows new data to update the vertexData
  22074. * @returns VertexData
  22075. */
  22076. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22077. /**
  22078. * Updates the associated mesh
  22079. * @param mesh the mesh to be updated
  22080. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22081. * @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
  22082. * @returns VertexData
  22083. */
  22084. updateMesh(mesh: Mesh): VertexData;
  22085. /**
  22086. * Updates the associated geometry
  22087. * @param geometry the geometry to be updated
  22088. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22089. * @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
  22090. * @returns VertexData.
  22091. */
  22092. updateGeometry(geometry: Geometry): VertexData;
  22093. private _applyTo;
  22094. private _update;
  22095. /**
  22096. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22097. * @param matrix the transforming matrix
  22098. * @returns the VertexData
  22099. */
  22100. transform(matrix: Matrix): VertexData;
  22101. /**
  22102. * Merges the passed VertexData into the current one
  22103. * @param other the VertexData to be merged into the current one
  22104. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22105. * @returns the modified VertexData
  22106. */
  22107. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22108. private _mergeElement;
  22109. private _validate;
  22110. /**
  22111. * Serializes the VertexData
  22112. * @returns a serialized object
  22113. */
  22114. serialize(): any;
  22115. /**
  22116. * Extracts the vertexData from a mesh
  22117. * @param mesh the mesh from which to extract the VertexData
  22118. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22119. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22120. * @returns the object VertexData associated to the passed mesh
  22121. */
  22122. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22123. /**
  22124. * Extracts the vertexData from the geometry
  22125. * @param geometry the geometry from which to extract the VertexData
  22126. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22127. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22128. * @returns the object VertexData associated to the passed mesh
  22129. */
  22130. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22131. private static _ExtractFrom;
  22132. /**
  22133. * Creates the VertexData for a Ribbon
  22134. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22135. * * pathArray array of paths, each of which an array of successive Vector3
  22136. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22137. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22138. * * 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
  22139. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22140. * * 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)
  22141. * * 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)
  22142. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22143. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22144. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22145. * @returns the VertexData of the ribbon
  22146. */
  22147. static CreateRibbon(options: {
  22148. pathArray: Vector3[][];
  22149. closeArray?: boolean;
  22150. closePath?: boolean;
  22151. offset?: number;
  22152. sideOrientation?: number;
  22153. frontUVs?: Vector4;
  22154. backUVs?: Vector4;
  22155. invertUV?: boolean;
  22156. uvs?: Vector2[];
  22157. colors?: Color4[];
  22158. }): VertexData;
  22159. /**
  22160. * Creates the VertexData for a box
  22161. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22162. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22163. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22164. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22165. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22166. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22167. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22168. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22169. * * 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)
  22170. * * 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)
  22171. * @returns the VertexData of the box
  22172. */
  22173. static CreateBox(options: {
  22174. size?: number;
  22175. width?: number;
  22176. height?: number;
  22177. depth?: number;
  22178. faceUV?: Vector4[];
  22179. faceColors?: Color4[];
  22180. sideOrientation?: number;
  22181. frontUVs?: Vector4;
  22182. backUVs?: Vector4;
  22183. }): VertexData;
  22184. /**
  22185. * Creates the VertexData for a tiled box
  22186. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22187. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22188. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22189. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22190. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22191. * @returns the VertexData of the box
  22192. */
  22193. static CreateTiledBox(options: {
  22194. pattern?: number;
  22195. width?: number;
  22196. height?: number;
  22197. depth?: number;
  22198. tileSize?: number;
  22199. tileWidth?: number;
  22200. tileHeight?: number;
  22201. alignHorizontal?: number;
  22202. alignVertical?: number;
  22203. faceUV?: Vector4[];
  22204. faceColors?: Color4[];
  22205. sideOrientation?: number;
  22206. }): VertexData;
  22207. /**
  22208. * Creates the VertexData for a tiled plane
  22209. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22210. * * pattern a limited pattern arrangement depending on the number
  22211. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22212. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22213. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22214. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22215. * * 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)
  22216. * * 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)
  22217. * @returns the VertexData of the tiled plane
  22218. */
  22219. static CreateTiledPlane(options: {
  22220. pattern?: number;
  22221. tileSize?: number;
  22222. tileWidth?: number;
  22223. tileHeight?: number;
  22224. size?: number;
  22225. width?: number;
  22226. height?: number;
  22227. alignHorizontal?: number;
  22228. alignVertical?: number;
  22229. sideOrientation?: number;
  22230. frontUVs?: Vector4;
  22231. backUVs?: Vector4;
  22232. }): VertexData;
  22233. /**
  22234. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22235. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22236. * * segments sets the number of horizontal strips optional, default 32
  22237. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22238. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22239. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22240. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22241. * * 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
  22242. * * 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
  22243. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22244. * * 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)
  22245. * * 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)
  22246. * @returns the VertexData of the ellipsoid
  22247. */
  22248. static CreateSphere(options: {
  22249. segments?: number;
  22250. diameter?: number;
  22251. diameterX?: number;
  22252. diameterY?: number;
  22253. diameterZ?: number;
  22254. arc?: number;
  22255. slice?: number;
  22256. sideOrientation?: number;
  22257. frontUVs?: Vector4;
  22258. backUVs?: Vector4;
  22259. }): VertexData;
  22260. /**
  22261. * Creates the VertexData for a cylinder, cone or prism
  22262. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22263. * * height sets the height (y direction) of the cylinder, optional, default 2
  22264. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22265. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22266. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22267. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22268. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22269. * * 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
  22270. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22271. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22272. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22273. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22274. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22275. * * 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)
  22276. * * 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)
  22277. * @returns the VertexData of the cylinder, cone or prism
  22278. */
  22279. static CreateCylinder(options: {
  22280. height?: number;
  22281. diameterTop?: number;
  22282. diameterBottom?: number;
  22283. diameter?: number;
  22284. tessellation?: number;
  22285. subdivisions?: number;
  22286. arc?: number;
  22287. faceColors?: Color4[];
  22288. faceUV?: Vector4[];
  22289. hasRings?: boolean;
  22290. enclose?: boolean;
  22291. sideOrientation?: number;
  22292. frontUVs?: Vector4;
  22293. backUVs?: Vector4;
  22294. }): VertexData;
  22295. /**
  22296. * Creates the VertexData for a torus
  22297. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22298. * * diameter the diameter of the torus, optional default 1
  22299. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22300. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22301. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22302. * * 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)
  22303. * * 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)
  22304. * @returns the VertexData of the torus
  22305. */
  22306. static CreateTorus(options: {
  22307. diameter?: number;
  22308. thickness?: number;
  22309. tessellation?: number;
  22310. sideOrientation?: number;
  22311. frontUVs?: Vector4;
  22312. backUVs?: Vector4;
  22313. }): VertexData;
  22314. /**
  22315. * Creates the VertexData of the LineSystem
  22316. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22317. * - lines an array of lines, each line being an array of successive Vector3
  22318. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22319. * @returns the VertexData of the LineSystem
  22320. */
  22321. static CreateLineSystem(options: {
  22322. lines: Vector3[][];
  22323. colors?: Nullable<Color4[][]>;
  22324. }): VertexData;
  22325. /**
  22326. * Create the VertexData for a DashedLines
  22327. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22328. * - points an array successive Vector3
  22329. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22330. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22331. * - dashNb the intended total number of dashes, optional, default 200
  22332. * @returns the VertexData for the DashedLines
  22333. */
  22334. static CreateDashedLines(options: {
  22335. points: Vector3[];
  22336. dashSize?: number;
  22337. gapSize?: number;
  22338. dashNb?: number;
  22339. }): VertexData;
  22340. /**
  22341. * Creates the VertexData for a Ground
  22342. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22343. * - width the width (x direction) of the ground, optional, default 1
  22344. * - height the height (z direction) of the ground, optional, default 1
  22345. * - subdivisions the number of subdivisions per side, optional, default 1
  22346. * @returns the VertexData of the Ground
  22347. */
  22348. static CreateGround(options: {
  22349. width?: number;
  22350. height?: number;
  22351. subdivisions?: number;
  22352. subdivisionsX?: number;
  22353. subdivisionsY?: number;
  22354. }): VertexData;
  22355. /**
  22356. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22357. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22358. * * xmin the ground minimum X coordinate, optional, default -1
  22359. * * zmin the ground minimum Z coordinate, optional, default -1
  22360. * * xmax the ground maximum X coordinate, optional, default 1
  22361. * * zmax the ground maximum Z coordinate, optional, default 1
  22362. * * 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}
  22363. * * 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}
  22364. * @returns the VertexData of the TiledGround
  22365. */
  22366. static CreateTiledGround(options: {
  22367. xmin: number;
  22368. zmin: number;
  22369. xmax: number;
  22370. zmax: number;
  22371. subdivisions?: {
  22372. w: number;
  22373. h: number;
  22374. };
  22375. precision?: {
  22376. w: number;
  22377. h: number;
  22378. };
  22379. }): VertexData;
  22380. /**
  22381. * Creates the VertexData of the Ground designed from a heightmap
  22382. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22383. * * width the width (x direction) of the ground
  22384. * * height the height (z direction) of the ground
  22385. * * subdivisions the number of subdivisions per side
  22386. * * minHeight the minimum altitude on the ground, optional, default 0
  22387. * * maxHeight the maximum altitude on the ground, optional default 1
  22388. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22389. * * buffer the array holding the image color data
  22390. * * bufferWidth the width of image
  22391. * * bufferHeight the height of image
  22392. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22393. * @returns the VertexData of the Ground designed from a heightmap
  22394. */
  22395. static CreateGroundFromHeightMap(options: {
  22396. width: number;
  22397. height: number;
  22398. subdivisions: number;
  22399. minHeight: number;
  22400. maxHeight: number;
  22401. colorFilter: Color3;
  22402. buffer: Uint8Array;
  22403. bufferWidth: number;
  22404. bufferHeight: number;
  22405. alphaFilter: number;
  22406. }): VertexData;
  22407. /**
  22408. * Creates the VertexData for a Plane
  22409. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22410. * * size sets the width and height of the plane to the value of size, optional default 1
  22411. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22412. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22413. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22414. * * 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)
  22415. * * 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)
  22416. * @returns the VertexData of the box
  22417. */
  22418. static CreatePlane(options: {
  22419. size?: number;
  22420. width?: number;
  22421. height?: number;
  22422. sideOrientation?: number;
  22423. frontUVs?: Vector4;
  22424. backUVs?: Vector4;
  22425. }): VertexData;
  22426. /**
  22427. * Creates the VertexData of the Disc or regular Polygon
  22428. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22429. * * radius the radius of the disc, optional default 0.5
  22430. * * tessellation the number of polygon sides, optional, default 64
  22431. * * 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
  22432. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22433. * * 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)
  22434. * * 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)
  22435. * @returns the VertexData of the box
  22436. */
  22437. static CreateDisc(options: {
  22438. radius?: number;
  22439. tessellation?: number;
  22440. arc?: number;
  22441. sideOrientation?: number;
  22442. frontUVs?: Vector4;
  22443. backUVs?: Vector4;
  22444. }): VertexData;
  22445. /**
  22446. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22447. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22448. * @param polygon a mesh built from polygonTriangulation.build()
  22449. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22450. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22451. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22452. * @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)
  22453. * @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)
  22454. * @returns the VertexData of the Polygon
  22455. */
  22456. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22457. /**
  22458. * Creates the VertexData of the IcoSphere
  22459. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22460. * * radius the radius of the IcoSphere, optional default 1
  22461. * * radiusX allows stretching in the x direction, optional, default radius
  22462. * * radiusY allows stretching in the y direction, optional, default radius
  22463. * * radiusZ allows stretching in the z direction, optional, default radius
  22464. * * flat when true creates a flat shaded mesh, optional, default true
  22465. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22467. * * 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)
  22468. * * 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)
  22469. * @returns the VertexData of the IcoSphere
  22470. */
  22471. static CreateIcoSphere(options: {
  22472. radius?: number;
  22473. radiusX?: number;
  22474. radiusY?: number;
  22475. radiusZ?: number;
  22476. flat?: boolean;
  22477. subdivisions?: number;
  22478. sideOrientation?: number;
  22479. frontUVs?: Vector4;
  22480. backUVs?: Vector4;
  22481. }): VertexData;
  22482. /**
  22483. * Creates the VertexData for a Polyhedron
  22484. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22485. * * type provided types are:
  22486. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22487. * * 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)
  22488. * * size the size of the IcoSphere, optional default 1
  22489. * * sizeX allows stretching in the x direction, optional, default size
  22490. * * sizeY allows stretching in the y direction, optional, default size
  22491. * * sizeZ allows stretching in the z direction, optional, default size
  22492. * * 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
  22493. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22494. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22495. * * flat when true creates a flat shaded mesh, optional, default true
  22496. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22498. * * 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)
  22499. * * 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)
  22500. * @returns the VertexData of the Polyhedron
  22501. */
  22502. static CreatePolyhedron(options: {
  22503. type?: number;
  22504. size?: number;
  22505. sizeX?: number;
  22506. sizeY?: number;
  22507. sizeZ?: number;
  22508. custom?: any;
  22509. faceUV?: Vector4[];
  22510. faceColors?: Color4[];
  22511. flat?: boolean;
  22512. sideOrientation?: number;
  22513. frontUVs?: Vector4;
  22514. backUVs?: Vector4;
  22515. }): VertexData;
  22516. /**
  22517. * Creates the VertexData for a TorusKnot
  22518. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22519. * * radius the radius of the torus knot, optional, default 2
  22520. * * tube the thickness of the tube, optional, default 0.5
  22521. * * radialSegments the number of sides on each tube segments, optional, default 32
  22522. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22523. * * p the number of windings around the z axis, optional, default 2
  22524. * * q the number of windings around the x axis, optional, default 3
  22525. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22526. * * 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)
  22527. * * 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)
  22528. * @returns the VertexData of the Torus Knot
  22529. */
  22530. static CreateTorusKnot(options: {
  22531. radius?: number;
  22532. tube?: number;
  22533. radialSegments?: number;
  22534. tubularSegments?: number;
  22535. p?: number;
  22536. q?: number;
  22537. sideOrientation?: number;
  22538. frontUVs?: Vector4;
  22539. backUVs?: Vector4;
  22540. }): VertexData;
  22541. /**
  22542. * Compute normals for given positions and indices
  22543. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22544. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22545. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22546. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22547. * * facetNormals : optional array of facet normals (vector3)
  22548. * * facetPositions : optional array of facet positions (vector3)
  22549. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22550. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22551. * * bInfo : optional bounding info, required for facetPartitioning computation
  22552. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22553. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22554. * * useRightHandedSystem: optional boolean to for right handed system computation
  22555. * * depthSort : optional boolean to enable the facet depth sort computation
  22556. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22557. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22558. */
  22559. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22560. facetNormals?: any;
  22561. facetPositions?: any;
  22562. facetPartitioning?: any;
  22563. ratio?: number;
  22564. bInfo?: any;
  22565. bbSize?: Vector3;
  22566. subDiv?: any;
  22567. useRightHandedSystem?: boolean;
  22568. depthSort?: boolean;
  22569. distanceTo?: Vector3;
  22570. depthSortedFacets?: any;
  22571. }): void;
  22572. /** @hidden */
  22573. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22574. /**
  22575. * Applies VertexData created from the imported parameters to the geometry
  22576. * @param parsedVertexData the parsed data from an imported file
  22577. * @param geometry the geometry to apply the VertexData to
  22578. */
  22579. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22580. }
  22581. }
  22582. declare module "babylonjs/Morph/morphTarget" {
  22583. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22584. import { Observable } from "babylonjs/Misc/observable";
  22585. import { Nullable, FloatArray } from "babylonjs/types";
  22586. import { Scene } from "babylonjs/scene";
  22587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22588. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22589. /**
  22590. * Defines a target to use with MorphTargetManager
  22591. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22592. */
  22593. export class MorphTarget implements IAnimatable {
  22594. /** defines the name of the target */
  22595. name: string;
  22596. /**
  22597. * Gets or sets the list of animations
  22598. */
  22599. animations: import("babylonjs/Animations/animation").Animation[];
  22600. private _scene;
  22601. private _positions;
  22602. private _normals;
  22603. private _tangents;
  22604. private _uvs;
  22605. private _influence;
  22606. /**
  22607. * Observable raised when the influence changes
  22608. */
  22609. onInfluenceChanged: Observable<boolean>;
  22610. /** @hidden */
  22611. _onDataLayoutChanged: Observable<void>;
  22612. /**
  22613. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22614. */
  22615. influence: number;
  22616. /**
  22617. * Gets or sets the id of the morph Target
  22618. */
  22619. id: string;
  22620. private _animationPropertiesOverride;
  22621. /**
  22622. * Gets or sets the animation properties override
  22623. */
  22624. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22625. /**
  22626. * Creates a new MorphTarget
  22627. * @param name defines the name of the target
  22628. * @param influence defines the influence to use
  22629. * @param scene defines the scene the morphtarget belongs to
  22630. */
  22631. constructor(
  22632. /** defines the name of the target */
  22633. name: string, influence?: number, scene?: Nullable<Scene>);
  22634. /**
  22635. * Gets a boolean defining if the target contains position data
  22636. */
  22637. readonly hasPositions: boolean;
  22638. /**
  22639. * Gets a boolean defining if the target contains normal data
  22640. */
  22641. readonly hasNormals: boolean;
  22642. /**
  22643. * Gets a boolean defining if the target contains tangent data
  22644. */
  22645. readonly hasTangents: boolean;
  22646. /**
  22647. * Gets a boolean defining if the target contains texture coordinates data
  22648. */
  22649. readonly hasUVs: boolean;
  22650. /**
  22651. * Affects position data to this target
  22652. * @param data defines the position data to use
  22653. */
  22654. setPositions(data: Nullable<FloatArray>): void;
  22655. /**
  22656. * Gets the position data stored in this target
  22657. * @returns a FloatArray containing the position data (or null if not present)
  22658. */
  22659. getPositions(): Nullable<FloatArray>;
  22660. /**
  22661. * Affects normal data to this target
  22662. * @param data defines the normal data to use
  22663. */
  22664. setNormals(data: Nullable<FloatArray>): void;
  22665. /**
  22666. * Gets the normal data stored in this target
  22667. * @returns a FloatArray containing the normal data (or null if not present)
  22668. */
  22669. getNormals(): Nullable<FloatArray>;
  22670. /**
  22671. * Affects tangent data to this target
  22672. * @param data defines the tangent data to use
  22673. */
  22674. setTangents(data: Nullable<FloatArray>): void;
  22675. /**
  22676. * Gets the tangent data stored in this target
  22677. * @returns a FloatArray containing the tangent data (or null if not present)
  22678. */
  22679. getTangents(): Nullable<FloatArray>;
  22680. /**
  22681. * Affects texture coordinates data to this target
  22682. * @param data defines the texture coordinates data to use
  22683. */
  22684. setUVs(data: Nullable<FloatArray>): void;
  22685. /**
  22686. * Gets the texture coordinates data stored in this target
  22687. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22688. */
  22689. getUVs(): Nullable<FloatArray>;
  22690. /**
  22691. * Serializes the current target into a Serialization object
  22692. * @returns the serialized object
  22693. */
  22694. serialize(): any;
  22695. /**
  22696. * Returns the string "MorphTarget"
  22697. * @returns "MorphTarget"
  22698. */
  22699. getClassName(): string;
  22700. /**
  22701. * Creates a new target from serialized data
  22702. * @param serializationObject defines the serialized data to use
  22703. * @returns a new MorphTarget
  22704. */
  22705. static Parse(serializationObject: any): MorphTarget;
  22706. /**
  22707. * Creates a MorphTarget from mesh data
  22708. * @param mesh defines the source mesh
  22709. * @param name defines the name to use for the new target
  22710. * @param influence defines the influence to attach to the target
  22711. * @returns a new MorphTarget
  22712. */
  22713. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22714. }
  22715. }
  22716. declare module "babylonjs/Morph/morphTargetManager" {
  22717. import { Nullable } from "babylonjs/types";
  22718. import { Scene } from "babylonjs/scene";
  22719. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22720. /**
  22721. * This class is used to deform meshes using morphing between different targets
  22722. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22723. */
  22724. export class MorphTargetManager {
  22725. private _targets;
  22726. private _targetInfluenceChangedObservers;
  22727. private _targetDataLayoutChangedObservers;
  22728. private _activeTargets;
  22729. private _scene;
  22730. private _influences;
  22731. private _supportsNormals;
  22732. private _supportsTangents;
  22733. private _supportsUVs;
  22734. private _vertexCount;
  22735. private _uniqueId;
  22736. private _tempInfluences;
  22737. /**
  22738. * Gets or sets a boolean indicating if normals must be morphed
  22739. */
  22740. enableNormalMorphing: boolean;
  22741. /**
  22742. * Gets or sets a boolean indicating if tangents must be morphed
  22743. */
  22744. enableTangentMorphing: boolean;
  22745. /**
  22746. * Gets or sets a boolean indicating if UV must be morphed
  22747. */
  22748. enableUVMorphing: boolean;
  22749. /**
  22750. * Creates a new MorphTargetManager
  22751. * @param scene defines the current scene
  22752. */
  22753. constructor(scene?: Nullable<Scene>);
  22754. /**
  22755. * Gets the unique ID of this manager
  22756. */
  22757. readonly uniqueId: number;
  22758. /**
  22759. * Gets the number of vertices handled by this manager
  22760. */
  22761. readonly vertexCount: number;
  22762. /**
  22763. * Gets a boolean indicating if this manager supports morphing of normals
  22764. */
  22765. readonly supportsNormals: boolean;
  22766. /**
  22767. * Gets a boolean indicating if this manager supports morphing of tangents
  22768. */
  22769. readonly supportsTangents: boolean;
  22770. /**
  22771. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22772. */
  22773. readonly supportsUVs: boolean;
  22774. /**
  22775. * Gets the number of targets stored in this manager
  22776. */
  22777. readonly numTargets: number;
  22778. /**
  22779. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22780. */
  22781. readonly numInfluencers: number;
  22782. /**
  22783. * Gets the list of influences (one per target)
  22784. */
  22785. readonly influences: Float32Array;
  22786. /**
  22787. * Gets the active target at specified index. An active target is a target with an influence > 0
  22788. * @param index defines the index to check
  22789. * @returns the requested target
  22790. */
  22791. getActiveTarget(index: number): MorphTarget;
  22792. /**
  22793. * Gets the target at specified index
  22794. * @param index defines the index to check
  22795. * @returns the requested target
  22796. */
  22797. getTarget(index: number): MorphTarget;
  22798. /**
  22799. * Add a new target to this manager
  22800. * @param target defines the target to add
  22801. */
  22802. addTarget(target: MorphTarget): void;
  22803. /**
  22804. * Removes a target from the manager
  22805. * @param target defines the target to remove
  22806. */
  22807. removeTarget(target: MorphTarget): void;
  22808. /**
  22809. * Serializes the current manager into a Serialization object
  22810. * @returns the serialized object
  22811. */
  22812. serialize(): any;
  22813. private _syncActiveTargets;
  22814. /**
  22815. * Syncrhonize the targets with all the meshes using this morph target manager
  22816. */
  22817. synchronize(): void;
  22818. /**
  22819. * Creates a new MorphTargetManager from serialized data
  22820. * @param serializationObject defines the serialized data
  22821. * @param scene defines the hosting scene
  22822. * @returns the new MorphTargetManager
  22823. */
  22824. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22825. }
  22826. }
  22827. declare module "babylonjs/Meshes/meshLODLevel" {
  22828. import { Mesh } from "babylonjs/Meshes/mesh";
  22829. import { Nullable } from "babylonjs/types";
  22830. /**
  22831. * Class used to represent a specific level of detail of a mesh
  22832. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22833. */
  22834. export class MeshLODLevel {
  22835. /** Defines the distance where this level should start being displayed */
  22836. distance: number;
  22837. /** Defines the mesh to use to render this level */
  22838. mesh: Nullable<Mesh>;
  22839. /**
  22840. * Creates a new LOD level
  22841. * @param distance defines the distance where this level should star being displayed
  22842. * @param mesh defines the mesh to use to render this level
  22843. */
  22844. constructor(
  22845. /** Defines the distance where this level should start being displayed */
  22846. distance: number,
  22847. /** Defines the mesh to use to render this level */
  22848. mesh: Nullable<Mesh>);
  22849. }
  22850. }
  22851. declare module "babylonjs/Meshes/groundMesh" {
  22852. import { Scene } from "babylonjs/scene";
  22853. import { Vector3 } from "babylonjs/Maths/math.vector";
  22854. import { Mesh } from "babylonjs/Meshes/mesh";
  22855. /**
  22856. * Mesh representing the gorund
  22857. */
  22858. export class GroundMesh extends Mesh {
  22859. /** If octree should be generated */
  22860. generateOctree: boolean;
  22861. private _heightQuads;
  22862. /** @hidden */
  22863. _subdivisionsX: number;
  22864. /** @hidden */
  22865. _subdivisionsY: number;
  22866. /** @hidden */
  22867. _width: number;
  22868. /** @hidden */
  22869. _height: number;
  22870. /** @hidden */
  22871. _minX: number;
  22872. /** @hidden */
  22873. _maxX: number;
  22874. /** @hidden */
  22875. _minZ: number;
  22876. /** @hidden */
  22877. _maxZ: number;
  22878. constructor(name: string, scene: Scene);
  22879. /**
  22880. * "GroundMesh"
  22881. * @returns "GroundMesh"
  22882. */
  22883. getClassName(): string;
  22884. /**
  22885. * The minimum of x and y subdivisions
  22886. */
  22887. readonly subdivisions: number;
  22888. /**
  22889. * X subdivisions
  22890. */
  22891. readonly subdivisionsX: number;
  22892. /**
  22893. * Y subdivisions
  22894. */
  22895. readonly subdivisionsY: number;
  22896. /**
  22897. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22898. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22899. * @param chunksCount the number of subdivisions for x and y
  22900. * @param octreeBlocksSize (Default: 32)
  22901. */
  22902. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22903. /**
  22904. * Returns a height (y) value in the Worl system :
  22905. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22906. * @param x x coordinate
  22907. * @param z z coordinate
  22908. * @returns the ground y position if (x, z) are outside the ground surface.
  22909. */
  22910. getHeightAtCoordinates(x: number, z: number): number;
  22911. /**
  22912. * Returns a normalized vector (Vector3) orthogonal to the ground
  22913. * at the ground coordinates (x, z) expressed in the World system.
  22914. * @param x x coordinate
  22915. * @param z z coordinate
  22916. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22917. */
  22918. getNormalAtCoordinates(x: number, z: number): Vector3;
  22919. /**
  22920. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22921. * at the ground coordinates (x, z) expressed in the World system.
  22922. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22923. * @param x x coordinate
  22924. * @param z z coordinate
  22925. * @param ref vector to store the result
  22926. * @returns the GroundMesh.
  22927. */
  22928. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22929. /**
  22930. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22931. * if the ground has been updated.
  22932. * This can be used in the render loop.
  22933. * @returns the GroundMesh.
  22934. */
  22935. updateCoordinateHeights(): GroundMesh;
  22936. private _getFacetAt;
  22937. private _initHeightQuads;
  22938. private _computeHeightQuads;
  22939. /**
  22940. * Serializes this ground mesh
  22941. * @param serializationObject object to write serialization to
  22942. */
  22943. serialize(serializationObject: any): void;
  22944. /**
  22945. * Parses a serialized ground mesh
  22946. * @param parsedMesh the serialized mesh
  22947. * @param scene the scene to create the ground mesh in
  22948. * @returns the created ground mesh
  22949. */
  22950. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22951. }
  22952. }
  22953. declare module "babylonjs/Physics/physicsJoint" {
  22954. import { Vector3 } from "babylonjs/Maths/math.vector";
  22955. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22956. /**
  22957. * Interface for Physics-Joint data
  22958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22959. */
  22960. export interface PhysicsJointData {
  22961. /**
  22962. * The main pivot of the joint
  22963. */
  22964. mainPivot?: Vector3;
  22965. /**
  22966. * The connected pivot of the joint
  22967. */
  22968. connectedPivot?: Vector3;
  22969. /**
  22970. * The main axis of the joint
  22971. */
  22972. mainAxis?: Vector3;
  22973. /**
  22974. * The connected axis of the joint
  22975. */
  22976. connectedAxis?: Vector3;
  22977. /**
  22978. * The collision of the joint
  22979. */
  22980. collision?: boolean;
  22981. /**
  22982. * Native Oimo/Cannon/Energy data
  22983. */
  22984. nativeParams?: any;
  22985. }
  22986. /**
  22987. * This is a holder class for the physics joint created by the physics plugin
  22988. * It holds a set of functions to control the underlying joint
  22989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22990. */
  22991. export class PhysicsJoint {
  22992. /**
  22993. * The type of the physics joint
  22994. */
  22995. type: number;
  22996. /**
  22997. * The data for the physics joint
  22998. */
  22999. jointData: PhysicsJointData;
  23000. private _physicsJoint;
  23001. protected _physicsPlugin: IPhysicsEnginePlugin;
  23002. /**
  23003. * Initializes the physics joint
  23004. * @param type The type of the physics joint
  23005. * @param jointData The data for the physics joint
  23006. */
  23007. constructor(
  23008. /**
  23009. * The type of the physics joint
  23010. */
  23011. type: number,
  23012. /**
  23013. * The data for the physics joint
  23014. */
  23015. jointData: PhysicsJointData);
  23016. /**
  23017. * Gets the physics joint
  23018. */
  23019. /**
  23020. * Sets the physics joint
  23021. */
  23022. physicsJoint: any;
  23023. /**
  23024. * Sets the physics plugin
  23025. */
  23026. physicsPlugin: IPhysicsEnginePlugin;
  23027. /**
  23028. * Execute a function that is physics-plugin specific.
  23029. * @param {Function} func the function that will be executed.
  23030. * It accepts two parameters: the physics world and the physics joint
  23031. */
  23032. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23033. /**
  23034. * Distance-Joint type
  23035. */
  23036. static DistanceJoint: number;
  23037. /**
  23038. * Hinge-Joint type
  23039. */
  23040. static HingeJoint: number;
  23041. /**
  23042. * Ball-and-Socket joint type
  23043. */
  23044. static BallAndSocketJoint: number;
  23045. /**
  23046. * Wheel-Joint type
  23047. */
  23048. static WheelJoint: number;
  23049. /**
  23050. * Slider-Joint type
  23051. */
  23052. static SliderJoint: number;
  23053. /**
  23054. * Prismatic-Joint type
  23055. */
  23056. static PrismaticJoint: number;
  23057. /**
  23058. * Universal-Joint type
  23059. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23060. */
  23061. static UniversalJoint: number;
  23062. /**
  23063. * Hinge-Joint 2 type
  23064. */
  23065. static Hinge2Joint: number;
  23066. /**
  23067. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23068. */
  23069. static PointToPointJoint: number;
  23070. /**
  23071. * Spring-Joint type
  23072. */
  23073. static SpringJoint: number;
  23074. /**
  23075. * Lock-Joint type
  23076. */
  23077. static LockJoint: number;
  23078. }
  23079. /**
  23080. * A class representing a physics distance joint
  23081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23082. */
  23083. export class DistanceJoint extends PhysicsJoint {
  23084. /**
  23085. *
  23086. * @param jointData The data for the Distance-Joint
  23087. */
  23088. constructor(jointData: DistanceJointData);
  23089. /**
  23090. * Update the predefined distance.
  23091. * @param maxDistance The maximum preferred distance
  23092. * @param minDistance The minimum preferred distance
  23093. */
  23094. updateDistance(maxDistance: number, minDistance?: number): void;
  23095. }
  23096. /**
  23097. * Represents a Motor-Enabled Joint
  23098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23099. */
  23100. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23101. /**
  23102. * Initializes the Motor-Enabled Joint
  23103. * @param type The type of the joint
  23104. * @param jointData The physica joint data for the joint
  23105. */
  23106. constructor(type: number, jointData: PhysicsJointData);
  23107. /**
  23108. * Set the motor values.
  23109. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23110. * @param force the force to apply
  23111. * @param maxForce max force for this motor.
  23112. */
  23113. setMotor(force?: number, maxForce?: number): void;
  23114. /**
  23115. * Set the motor's limits.
  23116. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23117. * @param upperLimit The upper limit of the motor
  23118. * @param lowerLimit The lower limit of the motor
  23119. */
  23120. setLimit(upperLimit: number, lowerLimit?: number): void;
  23121. }
  23122. /**
  23123. * This class represents a single physics Hinge-Joint
  23124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23125. */
  23126. export class HingeJoint extends MotorEnabledJoint {
  23127. /**
  23128. * Initializes the Hinge-Joint
  23129. * @param jointData The joint data for the Hinge-Joint
  23130. */
  23131. constructor(jointData: PhysicsJointData);
  23132. /**
  23133. * Set the motor values.
  23134. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23135. * @param {number} force the force to apply
  23136. * @param {number} maxForce max force for this motor.
  23137. */
  23138. setMotor(force?: number, maxForce?: number): void;
  23139. /**
  23140. * Set the motor's limits.
  23141. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23142. * @param upperLimit The upper limit of the motor
  23143. * @param lowerLimit The lower limit of the motor
  23144. */
  23145. setLimit(upperLimit: number, lowerLimit?: number): void;
  23146. }
  23147. /**
  23148. * This class represents a dual hinge physics joint (same as wheel joint)
  23149. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23150. */
  23151. export class Hinge2Joint extends MotorEnabledJoint {
  23152. /**
  23153. * Initializes the Hinge2-Joint
  23154. * @param jointData The joint data for the Hinge2-Joint
  23155. */
  23156. constructor(jointData: PhysicsJointData);
  23157. /**
  23158. * Set the motor values.
  23159. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23160. * @param {number} targetSpeed the speed the motor is to reach
  23161. * @param {number} maxForce max force for this motor.
  23162. * @param {motorIndex} the motor's index, 0 or 1.
  23163. */
  23164. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23165. /**
  23166. * Set the motor limits.
  23167. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23168. * @param {number} upperLimit the upper limit
  23169. * @param {number} lowerLimit lower limit
  23170. * @param {motorIndex} the motor's index, 0 or 1.
  23171. */
  23172. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23173. }
  23174. /**
  23175. * Interface for a motor enabled joint
  23176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23177. */
  23178. export interface IMotorEnabledJoint {
  23179. /**
  23180. * Physics joint
  23181. */
  23182. physicsJoint: any;
  23183. /**
  23184. * Sets the motor of the motor-enabled joint
  23185. * @param force The force of the motor
  23186. * @param maxForce The maximum force of the motor
  23187. * @param motorIndex The index of the motor
  23188. */
  23189. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23190. /**
  23191. * Sets the limit of the motor
  23192. * @param upperLimit The upper limit of the motor
  23193. * @param lowerLimit The lower limit of the motor
  23194. * @param motorIndex The index of the motor
  23195. */
  23196. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23197. }
  23198. /**
  23199. * Joint data for a Distance-Joint
  23200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23201. */
  23202. export interface DistanceJointData extends PhysicsJointData {
  23203. /**
  23204. * Max distance the 2 joint objects can be apart
  23205. */
  23206. maxDistance: number;
  23207. }
  23208. /**
  23209. * Joint data from a spring joint
  23210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23211. */
  23212. export interface SpringJointData extends PhysicsJointData {
  23213. /**
  23214. * Length of the spring
  23215. */
  23216. length: number;
  23217. /**
  23218. * Stiffness of the spring
  23219. */
  23220. stiffness: number;
  23221. /**
  23222. * Damping of the spring
  23223. */
  23224. damping: number;
  23225. /** this callback will be called when applying the force to the impostors. */
  23226. forceApplicationCallback: () => void;
  23227. }
  23228. }
  23229. declare module "babylonjs/Physics/physicsRaycastResult" {
  23230. import { Vector3 } from "babylonjs/Maths/math.vector";
  23231. /**
  23232. * Holds the data for the raycast result
  23233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23234. */
  23235. export class PhysicsRaycastResult {
  23236. private _hasHit;
  23237. private _hitDistance;
  23238. private _hitNormalWorld;
  23239. private _hitPointWorld;
  23240. private _rayFromWorld;
  23241. private _rayToWorld;
  23242. /**
  23243. * Gets if there was a hit
  23244. */
  23245. readonly hasHit: boolean;
  23246. /**
  23247. * Gets the distance from the hit
  23248. */
  23249. readonly hitDistance: number;
  23250. /**
  23251. * Gets the hit normal/direction in the world
  23252. */
  23253. readonly hitNormalWorld: Vector3;
  23254. /**
  23255. * Gets the hit point in the world
  23256. */
  23257. readonly hitPointWorld: Vector3;
  23258. /**
  23259. * Gets the ray "start point" of the ray in the world
  23260. */
  23261. readonly rayFromWorld: Vector3;
  23262. /**
  23263. * Gets the ray "end point" of the ray in the world
  23264. */
  23265. readonly rayToWorld: Vector3;
  23266. /**
  23267. * Sets the hit data (normal & point in world space)
  23268. * @param hitNormalWorld defines the normal in world space
  23269. * @param hitPointWorld defines the point in world space
  23270. */
  23271. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23272. /**
  23273. * Sets the distance from the start point to the hit point
  23274. * @param distance
  23275. */
  23276. setHitDistance(distance: number): void;
  23277. /**
  23278. * Calculates the distance manually
  23279. */
  23280. calculateHitDistance(): void;
  23281. /**
  23282. * Resets all the values to default
  23283. * @param from The from point on world space
  23284. * @param to The to point on world space
  23285. */
  23286. reset(from?: Vector3, to?: Vector3): void;
  23287. }
  23288. /**
  23289. * Interface for the size containing width and height
  23290. */
  23291. interface IXYZ {
  23292. /**
  23293. * X
  23294. */
  23295. x: number;
  23296. /**
  23297. * Y
  23298. */
  23299. y: number;
  23300. /**
  23301. * Z
  23302. */
  23303. z: number;
  23304. }
  23305. }
  23306. declare module "babylonjs/Physics/IPhysicsEngine" {
  23307. import { Nullable } from "babylonjs/types";
  23308. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23310. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23311. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23312. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23313. /**
  23314. * Interface used to describe a physics joint
  23315. */
  23316. export interface PhysicsImpostorJoint {
  23317. /** Defines the main impostor to which the joint is linked */
  23318. mainImpostor: PhysicsImpostor;
  23319. /** Defines the impostor that is connected to the main impostor using this joint */
  23320. connectedImpostor: PhysicsImpostor;
  23321. /** Defines the joint itself */
  23322. joint: PhysicsJoint;
  23323. }
  23324. /** @hidden */
  23325. export interface IPhysicsEnginePlugin {
  23326. world: any;
  23327. name: string;
  23328. setGravity(gravity: Vector3): void;
  23329. setTimeStep(timeStep: number): void;
  23330. getTimeStep(): number;
  23331. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23332. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23333. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23334. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23335. removePhysicsBody(impostor: PhysicsImpostor): void;
  23336. generateJoint(joint: PhysicsImpostorJoint): void;
  23337. removeJoint(joint: PhysicsImpostorJoint): void;
  23338. isSupported(): boolean;
  23339. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23340. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23341. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23342. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23343. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23344. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23345. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23346. getBodyMass(impostor: PhysicsImpostor): number;
  23347. getBodyFriction(impostor: PhysicsImpostor): number;
  23348. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23349. getBodyRestitution(impostor: PhysicsImpostor): number;
  23350. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23351. getBodyPressure?(impostor: PhysicsImpostor): number;
  23352. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23353. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23354. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23355. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23356. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23357. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23358. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23359. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23360. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23361. sleepBody(impostor: PhysicsImpostor): void;
  23362. wakeUpBody(impostor: PhysicsImpostor): void;
  23363. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23364. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23365. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23366. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23367. getRadius(impostor: PhysicsImpostor): number;
  23368. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23369. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23370. dispose(): void;
  23371. }
  23372. /**
  23373. * Interface used to define a physics engine
  23374. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23375. */
  23376. export interface IPhysicsEngine {
  23377. /**
  23378. * Gets the gravity vector used by the simulation
  23379. */
  23380. gravity: Vector3;
  23381. /**
  23382. * Sets the gravity vector used by the simulation
  23383. * @param gravity defines the gravity vector to use
  23384. */
  23385. setGravity(gravity: Vector3): void;
  23386. /**
  23387. * Set the time step of the physics engine.
  23388. * Default is 1/60.
  23389. * To slow it down, enter 1/600 for example.
  23390. * To speed it up, 1/30
  23391. * @param newTimeStep the new timestep to apply to this world.
  23392. */
  23393. setTimeStep(newTimeStep: number): void;
  23394. /**
  23395. * Get the time step of the physics engine.
  23396. * @returns the current time step
  23397. */
  23398. getTimeStep(): number;
  23399. /**
  23400. * Release all resources
  23401. */
  23402. dispose(): void;
  23403. /**
  23404. * Gets the name of the current physics plugin
  23405. * @returns the name of the plugin
  23406. */
  23407. getPhysicsPluginName(): string;
  23408. /**
  23409. * Adding a new impostor for the impostor tracking.
  23410. * This will be done by the impostor itself.
  23411. * @param impostor the impostor to add
  23412. */
  23413. addImpostor(impostor: PhysicsImpostor): void;
  23414. /**
  23415. * Remove an impostor from the engine.
  23416. * This impostor and its mesh will not longer be updated by the physics engine.
  23417. * @param impostor the impostor to remove
  23418. */
  23419. removeImpostor(impostor: PhysicsImpostor): void;
  23420. /**
  23421. * Add a joint to the physics engine
  23422. * @param mainImpostor defines the main impostor to which the joint is added.
  23423. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23424. * @param joint defines the joint that will connect both impostors.
  23425. */
  23426. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23427. /**
  23428. * Removes a joint from the simulation
  23429. * @param mainImpostor defines the impostor used with the joint
  23430. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23431. * @param joint defines the joint to remove
  23432. */
  23433. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23434. /**
  23435. * Gets the current plugin used to run the simulation
  23436. * @returns current plugin
  23437. */
  23438. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23439. /**
  23440. * Gets the list of physic impostors
  23441. * @returns an array of PhysicsImpostor
  23442. */
  23443. getImpostors(): Array<PhysicsImpostor>;
  23444. /**
  23445. * Gets the impostor for a physics enabled object
  23446. * @param object defines the object impersonated by the impostor
  23447. * @returns the PhysicsImpostor or null if not found
  23448. */
  23449. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23450. /**
  23451. * Gets the impostor for a physics body object
  23452. * @param body defines physics body used by the impostor
  23453. * @returns the PhysicsImpostor or null if not found
  23454. */
  23455. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23456. /**
  23457. * Does a raycast in the physics world
  23458. * @param from when should the ray start?
  23459. * @param to when should the ray end?
  23460. * @returns PhysicsRaycastResult
  23461. */
  23462. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23463. /**
  23464. * Called by the scene. No need to call it.
  23465. * @param delta defines the timespam between frames
  23466. */
  23467. _step(delta: number): void;
  23468. }
  23469. }
  23470. declare module "babylonjs/Physics/physicsImpostor" {
  23471. import { Nullable, IndicesArray } from "babylonjs/types";
  23472. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23473. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23475. import { Scene } from "babylonjs/scene";
  23476. import { Bone } from "babylonjs/Bones/bone";
  23477. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23478. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23479. import { Space } from "babylonjs/Maths/math.axis";
  23480. /**
  23481. * The interface for the physics imposter parameters
  23482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23483. */
  23484. export interface PhysicsImpostorParameters {
  23485. /**
  23486. * The mass of the physics imposter
  23487. */
  23488. mass: number;
  23489. /**
  23490. * The friction of the physics imposter
  23491. */
  23492. friction?: number;
  23493. /**
  23494. * The coefficient of restitution of the physics imposter
  23495. */
  23496. restitution?: number;
  23497. /**
  23498. * The native options of the physics imposter
  23499. */
  23500. nativeOptions?: any;
  23501. /**
  23502. * Specifies if the parent should be ignored
  23503. */
  23504. ignoreParent?: boolean;
  23505. /**
  23506. * Specifies if bi-directional transformations should be disabled
  23507. */
  23508. disableBidirectionalTransformation?: boolean;
  23509. /**
  23510. * The pressure inside the physics imposter, soft object only
  23511. */
  23512. pressure?: number;
  23513. /**
  23514. * The stiffness the physics imposter, soft object only
  23515. */
  23516. stiffness?: number;
  23517. /**
  23518. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23519. */
  23520. velocityIterations?: number;
  23521. /**
  23522. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23523. */
  23524. positionIterations?: number;
  23525. /**
  23526. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23527. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23528. * Add to fix multiple points
  23529. */
  23530. fixedPoints?: number;
  23531. /**
  23532. * The collision margin around a soft object
  23533. */
  23534. margin?: number;
  23535. /**
  23536. * The collision margin around a soft object
  23537. */
  23538. damping?: number;
  23539. /**
  23540. * The path for a rope based on an extrusion
  23541. */
  23542. path?: any;
  23543. /**
  23544. * The shape of an extrusion used for a rope based on an extrusion
  23545. */
  23546. shape?: any;
  23547. }
  23548. /**
  23549. * Interface for a physics-enabled object
  23550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23551. */
  23552. export interface IPhysicsEnabledObject {
  23553. /**
  23554. * The position of the physics-enabled object
  23555. */
  23556. position: Vector3;
  23557. /**
  23558. * The rotation of the physics-enabled object
  23559. */
  23560. rotationQuaternion: Nullable<Quaternion>;
  23561. /**
  23562. * The scale of the physics-enabled object
  23563. */
  23564. scaling: Vector3;
  23565. /**
  23566. * The rotation of the physics-enabled object
  23567. */
  23568. rotation?: Vector3;
  23569. /**
  23570. * The parent of the physics-enabled object
  23571. */
  23572. parent?: any;
  23573. /**
  23574. * The bounding info of the physics-enabled object
  23575. * @returns The bounding info of the physics-enabled object
  23576. */
  23577. getBoundingInfo(): BoundingInfo;
  23578. /**
  23579. * Computes the world matrix
  23580. * @param force Specifies if the world matrix should be computed by force
  23581. * @returns A world matrix
  23582. */
  23583. computeWorldMatrix(force: boolean): Matrix;
  23584. /**
  23585. * Gets the world matrix
  23586. * @returns A world matrix
  23587. */
  23588. getWorldMatrix?(): Matrix;
  23589. /**
  23590. * Gets the child meshes
  23591. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23592. * @returns An array of abstract meshes
  23593. */
  23594. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23595. /**
  23596. * Gets the vertex data
  23597. * @param kind The type of vertex data
  23598. * @returns A nullable array of numbers, or a float32 array
  23599. */
  23600. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23601. /**
  23602. * Gets the indices from the mesh
  23603. * @returns A nullable array of index arrays
  23604. */
  23605. getIndices?(): Nullable<IndicesArray>;
  23606. /**
  23607. * Gets the scene from the mesh
  23608. * @returns the indices array or null
  23609. */
  23610. getScene?(): Scene;
  23611. /**
  23612. * Gets the absolute position from the mesh
  23613. * @returns the absolute position
  23614. */
  23615. getAbsolutePosition(): Vector3;
  23616. /**
  23617. * Gets the absolute pivot point from the mesh
  23618. * @returns the absolute pivot point
  23619. */
  23620. getAbsolutePivotPoint(): Vector3;
  23621. /**
  23622. * Rotates the mesh
  23623. * @param axis The axis of rotation
  23624. * @param amount The amount of rotation
  23625. * @param space The space of the rotation
  23626. * @returns The rotation transform node
  23627. */
  23628. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23629. /**
  23630. * Translates the mesh
  23631. * @param axis The axis of translation
  23632. * @param distance The distance of translation
  23633. * @param space The space of the translation
  23634. * @returns The transform node
  23635. */
  23636. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23637. /**
  23638. * Sets the absolute position of the mesh
  23639. * @param absolutePosition The absolute position of the mesh
  23640. * @returns The transform node
  23641. */
  23642. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23643. /**
  23644. * Gets the class name of the mesh
  23645. * @returns The class name
  23646. */
  23647. getClassName(): string;
  23648. }
  23649. /**
  23650. * Represents a physics imposter
  23651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23652. */
  23653. export class PhysicsImpostor {
  23654. /**
  23655. * The physics-enabled object used as the physics imposter
  23656. */
  23657. object: IPhysicsEnabledObject;
  23658. /**
  23659. * The type of the physics imposter
  23660. */
  23661. type: number;
  23662. private _options;
  23663. private _scene?;
  23664. /**
  23665. * The default object size of the imposter
  23666. */
  23667. static DEFAULT_OBJECT_SIZE: Vector3;
  23668. /**
  23669. * The identity quaternion of the imposter
  23670. */
  23671. static IDENTITY_QUATERNION: Quaternion;
  23672. /** @hidden */
  23673. _pluginData: any;
  23674. private _physicsEngine;
  23675. private _physicsBody;
  23676. private _bodyUpdateRequired;
  23677. private _onBeforePhysicsStepCallbacks;
  23678. private _onAfterPhysicsStepCallbacks;
  23679. /** @hidden */
  23680. _onPhysicsCollideCallbacks: Array<{
  23681. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23682. otherImpostors: Array<PhysicsImpostor>;
  23683. }>;
  23684. private _deltaPosition;
  23685. private _deltaRotation;
  23686. private _deltaRotationConjugated;
  23687. /** @hidden */
  23688. _isFromLine: boolean;
  23689. private _parent;
  23690. private _isDisposed;
  23691. private static _tmpVecs;
  23692. private static _tmpQuat;
  23693. /**
  23694. * Specifies if the physics imposter is disposed
  23695. */
  23696. readonly isDisposed: boolean;
  23697. /**
  23698. * Gets the mass of the physics imposter
  23699. */
  23700. mass: number;
  23701. /**
  23702. * Gets the coefficient of friction
  23703. */
  23704. /**
  23705. * Sets the coefficient of friction
  23706. */
  23707. friction: number;
  23708. /**
  23709. * Gets the coefficient of restitution
  23710. */
  23711. /**
  23712. * Sets the coefficient of restitution
  23713. */
  23714. restitution: number;
  23715. /**
  23716. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23717. */
  23718. /**
  23719. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23720. */
  23721. pressure: number;
  23722. /**
  23723. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23724. */
  23725. /**
  23726. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23727. */
  23728. stiffness: number;
  23729. /**
  23730. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23731. */
  23732. /**
  23733. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23734. */
  23735. velocityIterations: number;
  23736. /**
  23737. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23738. */
  23739. /**
  23740. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23741. */
  23742. positionIterations: number;
  23743. /**
  23744. * The unique id of the physics imposter
  23745. * set by the physics engine when adding this impostor to the array
  23746. */
  23747. uniqueId: number;
  23748. /**
  23749. * @hidden
  23750. */
  23751. soft: boolean;
  23752. /**
  23753. * @hidden
  23754. */
  23755. segments: number;
  23756. private _joints;
  23757. /**
  23758. * Initializes the physics imposter
  23759. * @param object The physics-enabled object used as the physics imposter
  23760. * @param type The type of the physics imposter
  23761. * @param _options The options for the physics imposter
  23762. * @param _scene The Babylon scene
  23763. */
  23764. constructor(
  23765. /**
  23766. * The physics-enabled object used as the physics imposter
  23767. */
  23768. object: IPhysicsEnabledObject,
  23769. /**
  23770. * The type of the physics imposter
  23771. */
  23772. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23773. /**
  23774. * This function will completly initialize this impostor.
  23775. * It will create a new body - but only if this mesh has no parent.
  23776. * If it has, this impostor will not be used other than to define the impostor
  23777. * of the child mesh.
  23778. * @hidden
  23779. */
  23780. _init(): void;
  23781. private _getPhysicsParent;
  23782. /**
  23783. * Should a new body be generated.
  23784. * @returns boolean specifying if body initialization is required
  23785. */
  23786. isBodyInitRequired(): boolean;
  23787. /**
  23788. * Sets the updated scaling
  23789. * @param updated Specifies if the scaling is updated
  23790. */
  23791. setScalingUpdated(): void;
  23792. /**
  23793. * Force a regeneration of this or the parent's impostor's body.
  23794. * Use under cautious - This will remove all joints already implemented.
  23795. */
  23796. forceUpdate(): void;
  23797. /**
  23798. * Gets the body that holds this impostor. Either its own, or its parent.
  23799. */
  23800. /**
  23801. * Set the physics body. Used mainly by the physics engine/plugin
  23802. */
  23803. physicsBody: any;
  23804. /**
  23805. * Get the parent of the physics imposter
  23806. * @returns Physics imposter or null
  23807. */
  23808. /**
  23809. * Sets the parent of the physics imposter
  23810. */
  23811. parent: Nullable<PhysicsImpostor>;
  23812. /**
  23813. * Resets the update flags
  23814. */
  23815. resetUpdateFlags(): void;
  23816. /**
  23817. * Gets the object extend size
  23818. * @returns the object extend size
  23819. */
  23820. getObjectExtendSize(): Vector3;
  23821. /**
  23822. * Gets the object center
  23823. * @returns The object center
  23824. */
  23825. getObjectCenter(): Vector3;
  23826. /**
  23827. * Get a specific parametes from the options parameter
  23828. * @param paramName The object parameter name
  23829. * @returns The object parameter
  23830. */
  23831. getParam(paramName: string): any;
  23832. /**
  23833. * Sets a specific parameter in the options given to the physics plugin
  23834. * @param paramName The parameter name
  23835. * @param value The value of the parameter
  23836. */
  23837. setParam(paramName: string, value: number): void;
  23838. /**
  23839. * Specifically change the body's mass option. Won't recreate the physics body object
  23840. * @param mass The mass of the physics imposter
  23841. */
  23842. setMass(mass: number): void;
  23843. /**
  23844. * Gets the linear velocity
  23845. * @returns linear velocity or null
  23846. */
  23847. getLinearVelocity(): Nullable<Vector3>;
  23848. /**
  23849. * Sets the linear velocity
  23850. * @param velocity linear velocity or null
  23851. */
  23852. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23853. /**
  23854. * Gets the angular velocity
  23855. * @returns angular velocity or null
  23856. */
  23857. getAngularVelocity(): Nullable<Vector3>;
  23858. /**
  23859. * Sets the angular velocity
  23860. * @param velocity The velocity or null
  23861. */
  23862. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23863. /**
  23864. * Execute a function with the physics plugin native code
  23865. * Provide a function the will have two variables - the world object and the physics body object
  23866. * @param func The function to execute with the physics plugin native code
  23867. */
  23868. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23869. /**
  23870. * Register a function that will be executed before the physics world is stepping forward
  23871. * @param func The function to execute before the physics world is stepped forward
  23872. */
  23873. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23874. /**
  23875. * Unregister a function that will be executed before the physics world is stepping forward
  23876. * @param func The function to execute before the physics world is stepped forward
  23877. */
  23878. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23879. /**
  23880. * Register a function that will be executed after the physics step
  23881. * @param func The function to execute after physics step
  23882. */
  23883. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23884. /**
  23885. * Unregisters a function that will be executed after the physics step
  23886. * @param func The function to execute after physics step
  23887. */
  23888. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23889. /**
  23890. * register a function that will be executed when this impostor collides against a different body
  23891. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23892. * @param func Callback that is executed on collision
  23893. */
  23894. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23895. /**
  23896. * Unregisters the physics imposter on contact
  23897. * @param collideAgainst The physics object to collide against
  23898. * @param func Callback to execute on collision
  23899. */
  23900. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23901. private _tmpQuat;
  23902. private _tmpQuat2;
  23903. /**
  23904. * Get the parent rotation
  23905. * @returns The parent rotation
  23906. */
  23907. getParentsRotation(): Quaternion;
  23908. /**
  23909. * this function is executed by the physics engine.
  23910. */
  23911. beforeStep: () => void;
  23912. /**
  23913. * this function is executed by the physics engine
  23914. */
  23915. afterStep: () => void;
  23916. /**
  23917. * Legacy collision detection event support
  23918. */
  23919. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23920. /**
  23921. * event and body object due to cannon's event-based architecture.
  23922. */
  23923. onCollide: (e: {
  23924. body: any;
  23925. }) => void;
  23926. /**
  23927. * Apply a force
  23928. * @param force The force to apply
  23929. * @param contactPoint The contact point for the force
  23930. * @returns The physics imposter
  23931. */
  23932. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23933. /**
  23934. * Apply an impulse
  23935. * @param force The impulse force
  23936. * @param contactPoint The contact point for the impulse force
  23937. * @returns The physics imposter
  23938. */
  23939. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23940. /**
  23941. * A help function to create a joint
  23942. * @param otherImpostor A physics imposter used to create a joint
  23943. * @param jointType The type of joint
  23944. * @param jointData The data for the joint
  23945. * @returns The physics imposter
  23946. */
  23947. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23948. /**
  23949. * Add a joint to this impostor with a different impostor
  23950. * @param otherImpostor A physics imposter used to add a joint
  23951. * @param joint The joint to add
  23952. * @returns The physics imposter
  23953. */
  23954. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23955. /**
  23956. * Add an anchor to a cloth impostor
  23957. * @param otherImpostor rigid impostor to anchor to
  23958. * @param width ratio across width from 0 to 1
  23959. * @param height ratio up height from 0 to 1
  23960. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23961. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23962. * @returns impostor the soft imposter
  23963. */
  23964. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23965. /**
  23966. * Add a hook to a rope impostor
  23967. * @param otherImpostor rigid impostor to anchor to
  23968. * @param length ratio across rope from 0 to 1
  23969. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23970. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23971. * @returns impostor the rope imposter
  23972. */
  23973. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23974. /**
  23975. * Will keep this body still, in a sleep mode.
  23976. * @returns the physics imposter
  23977. */
  23978. sleep(): PhysicsImpostor;
  23979. /**
  23980. * Wake the body up.
  23981. * @returns The physics imposter
  23982. */
  23983. wakeUp(): PhysicsImpostor;
  23984. /**
  23985. * Clones the physics imposter
  23986. * @param newObject The physics imposter clones to this physics-enabled object
  23987. * @returns A nullable physics imposter
  23988. */
  23989. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23990. /**
  23991. * Disposes the physics imposter
  23992. */
  23993. dispose(): void;
  23994. /**
  23995. * Sets the delta position
  23996. * @param position The delta position amount
  23997. */
  23998. setDeltaPosition(position: Vector3): void;
  23999. /**
  24000. * Sets the delta rotation
  24001. * @param rotation The delta rotation amount
  24002. */
  24003. setDeltaRotation(rotation: Quaternion): void;
  24004. /**
  24005. * Gets the box size of the physics imposter and stores the result in the input parameter
  24006. * @param result Stores the box size
  24007. * @returns The physics imposter
  24008. */
  24009. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24010. /**
  24011. * Gets the radius of the physics imposter
  24012. * @returns Radius of the physics imposter
  24013. */
  24014. getRadius(): number;
  24015. /**
  24016. * Sync a bone with this impostor
  24017. * @param bone The bone to sync to the impostor.
  24018. * @param boneMesh The mesh that the bone is influencing.
  24019. * @param jointPivot The pivot of the joint / bone in local space.
  24020. * @param distToJoint Optional distance from the impostor to the joint.
  24021. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24022. */
  24023. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24024. /**
  24025. * Sync impostor to a bone
  24026. * @param bone The bone that the impostor will be synced to.
  24027. * @param boneMesh The mesh that the bone is influencing.
  24028. * @param jointPivot The pivot of the joint / bone in local space.
  24029. * @param distToJoint Optional distance from the impostor to the joint.
  24030. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24031. * @param boneAxis Optional vector3 axis the bone is aligned with
  24032. */
  24033. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24034. /**
  24035. * No-Imposter type
  24036. */
  24037. static NoImpostor: number;
  24038. /**
  24039. * Sphere-Imposter type
  24040. */
  24041. static SphereImpostor: number;
  24042. /**
  24043. * Box-Imposter type
  24044. */
  24045. static BoxImpostor: number;
  24046. /**
  24047. * Plane-Imposter type
  24048. */
  24049. static PlaneImpostor: number;
  24050. /**
  24051. * Mesh-imposter type
  24052. */
  24053. static MeshImpostor: number;
  24054. /**
  24055. * Capsule-Impostor type (Ammo.js plugin only)
  24056. */
  24057. static CapsuleImpostor: number;
  24058. /**
  24059. * Cylinder-Imposter type
  24060. */
  24061. static CylinderImpostor: number;
  24062. /**
  24063. * Particle-Imposter type
  24064. */
  24065. static ParticleImpostor: number;
  24066. /**
  24067. * Heightmap-Imposter type
  24068. */
  24069. static HeightmapImpostor: number;
  24070. /**
  24071. * ConvexHull-Impostor type (Ammo.js plugin only)
  24072. */
  24073. static ConvexHullImpostor: number;
  24074. /**
  24075. * Rope-Imposter type
  24076. */
  24077. static RopeImpostor: number;
  24078. /**
  24079. * Cloth-Imposter type
  24080. */
  24081. static ClothImpostor: number;
  24082. /**
  24083. * Softbody-Imposter type
  24084. */
  24085. static SoftbodyImpostor: number;
  24086. }
  24087. }
  24088. declare module "babylonjs/Meshes/mesh" {
  24089. import { Observable } from "babylonjs/Misc/observable";
  24090. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24091. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24092. import { Camera } from "babylonjs/Cameras/camera";
  24093. import { Scene } from "babylonjs/scene";
  24094. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24095. import { Color4 } from "babylonjs/Maths/math.color";
  24096. import { Engine } from "babylonjs/Engines/engine";
  24097. import { Node } from "babylonjs/node";
  24098. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24099. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24100. import { Buffer } from "babylonjs/Meshes/buffer";
  24101. import { Geometry } from "babylonjs/Meshes/geometry";
  24102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24103. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24104. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24105. import { Effect } from "babylonjs/Materials/effect";
  24106. import { Material } from "babylonjs/Materials/material";
  24107. import { Skeleton } from "babylonjs/Bones/skeleton";
  24108. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24109. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24110. import { Path3D } from "babylonjs/Maths/math.path";
  24111. import { Plane } from "babylonjs/Maths/math.plane";
  24112. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24113. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24114. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24115. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24116. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24117. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24118. /**
  24119. * @hidden
  24120. **/
  24121. export class _CreationDataStorage {
  24122. closePath?: boolean;
  24123. closeArray?: boolean;
  24124. idx: number[];
  24125. dashSize: number;
  24126. gapSize: number;
  24127. path3D: Path3D;
  24128. pathArray: Vector3[][];
  24129. arc: number;
  24130. radius: number;
  24131. cap: number;
  24132. tessellation: number;
  24133. }
  24134. /**
  24135. * @hidden
  24136. **/
  24137. class _InstanceDataStorage {
  24138. visibleInstances: any;
  24139. batchCache: _InstancesBatch;
  24140. instancesBufferSize: number;
  24141. instancesBuffer: Nullable<Buffer>;
  24142. instancesData: Float32Array;
  24143. overridenInstanceCount: number;
  24144. isFrozen: boolean;
  24145. previousBatch: Nullable<_InstancesBatch>;
  24146. hardwareInstancedRendering: boolean;
  24147. sideOrientation: number;
  24148. }
  24149. /**
  24150. * @hidden
  24151. **/
  24152. export class _InstancesBatch {
  24153. mustReturn: boolean;
  24154. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24155. renderSelf: boolean[];
  24156. hardwareInstancedRendering: boolean[];
  24157. }
  24158. /**
  24159. * Class used to represent renderable models
  24160. */
  24161. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24162. /**
  24163. * Mesh side orientation : usually the external or front surface
  24164. */
  24165. static readonly FRONTSIDE: number;
  24166. /**
  24167. * Mesh side orientation : usually the internal or back surface
  24168. */
  24169. static readonly BACKSIDE: number;
  24170. /**
  24171. * Mesh side orientation : both internal and external or front and back surfaces
  24172. */
  24173. static readonly DOUBLESIDE: number;
  24174. /**
  24175. * Mesh side orientation : by default, `FRONTSIDE`
  24176. */
  24177. static readonly DEFAULTSIDE: number;
  24178. /**
  24179. * Mesh cap setting : no cap
  24180. */
  24181. static readonly NO_CAP: number;
  24182. /**
  24183. * Mesh cap setting : one cap at the beginning of the mesh
  24184. */
  24185. static readonly CAP_START: number;
  24186. /**
  24187. * Mesh cap setting : one cap at the end of the mesh
  24188. */
  24189. static readonly CAP_END: number;
  24190. /**
  24191. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24192. */
  24193. static readonly CAP_ALL: number;
  24194. /**
  24195. * Mesh pattern setting : no flip or rotate
  24196. */
  24197. static readonly NO_FLIP: number;
  24198. /**
  24199. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24200. */
  24201. static readonly FLIP_TILE: number;
  24202. /**
  24203. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24204. */
  24205. static readonly ROTATE_TILE: number;
  24206. /**
  24207. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24208. */
  24209. static readonly FLIP_ROW: number;
  24210. /**
  24211. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24212. */
  24213. static readonly ROTATE_ROW: number;
  24214. /**
  24215. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24216. */
  24217. static readonly FLIP_N_ROTATE_TILE: number;
  24218. /**
  24219. * Mesh pattern setting : rotate pattern and rotate
  24220. */
  24221. static readonly FLIP_N_ROTATE_ROW: number;
  24222. /**
  24223. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24224. */
  24225. static readonly CENTER: number;
  24226. /**
  24227. * Mesh tile positioning : part tiles on left
  24228. */
  24229. static readonly LEFT: number;
  24230. /**
  24231. * Mesh tile positioning : part tiles on right
  24232. */
  24233. static readonly RIGHT: number;
  24234. /**
  24235. * Mesh tile positioning : part tiles on top
  24236. */
  24237. static readonly TOP: number;
  24238. /**
  24239. * Mesh tile positioning : part tiles on bottom
  24240. */
  24241. static readonly BOTTOM: number;
  24242. /**
  24243. * Gets the default side orientation.
  24244. * @param orientation the orientation to value to attempt to get
  24245. * @returns the default orientation
  24246. * @hidden
  24247. */
  24248. static _GetDefaultSideOrientation(orientation?: number): number;
  24249. private _internalMeshDataInfo;
  24250. /**
  24251. * An event triggered before rendering the mesh
  24252. */
  24253. readonly onBeforeRenderObservable: Observable<Mesh>;
  24254. /**
  24255. * An event triggered before binding the mesh
  24256. */
  24257. readonly onBeforeBindObservable: Observable<Mesh>;
  24258. /**
  24259. * An event triggered after rendering the mesh
  24260. */
  24261. readonly onAfterRenderObservable: Observable<Mesh>;
  24262. /**
  24263. * An event triggered before drawing the mesh
  24264. */
  24265. readonly onBeforeDrawObservable: Observable<Mesh>;
  24266. private _onBeforeDrawObserver;
  24267. /**
  24268. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24269. */
  24270. onBeforeDraw: () => void;
  24271. readonly hasInstances: boolean;
  24272. /**
  24273. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24274. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24275. */
  24276. delayLoadState: number;
  24277. /**
  24278. * Gets the list of instances created from this mesh
  24279. * it is not supposed to be modified manually.
  24280. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24281. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24282. */
  24283. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24284. /**
  24285. * Gets the file containing delay loading data for this mesh
  24286. */
  24287. delayLoadingFile: string;
  24288. /** @hidden */
  24289. _binaryInfo: any;
  24290. /**
  24291. * User defined function used to change how LOD level selection is done
  24292. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24293. */
  24294. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24295. /**
  24296. * Gets or sets the morph target manager
  24297. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24298. */
  24299. morphTargetManager: Nullable<MorphTargetManager>;
  24300. /** @hidden */
  24301. _creationDataStorage: Nullable<_CreationDataStorage>;
  24302. /** @hidden */
  24303. _geometry: Nullable<Geometry>;
  24304. /** @hidden */
  24305. _delayInfo: Array<string>;
  24306. /** @hidden */
  24307. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24308. /** @hidden */
  24309. _instanceDataStorage: _InstanceDataStorage;
  24310. private _effectiveMaterial;
  24311. /** @hidden */
  24312. _shouldGenerateFlatShading: boolean;
  24313. /** @hidden */
  24314. _originalBuilderSideOrientation: number;
  24315. /**
  24316. * Use this property to change the original side orientation defined at construction time
  24317. */
  24318. overrideMaterialSideOrientation: Nullable<number>;
  24319. /**
  24320. * Gets the source mesh (the one used to clone this one from)
  24321. */
  24322. readonly source: Nullable<Mesh>;
  24323. /**
  24324. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24325. */
  24326. isUnIndexed: boolean;
  24327. /**
  24328. * @constructor
  24329. * @param name The value used by scene.getMeshByName() to do a lookup.
  24330. * @param scene The scene to add this mesh to.
  24331. * @param parent The parent of this mesh, if it has one
  24332. * @param source An optional Mesh from which geometry is shared, cloned.
  24333. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24334. * When false, achieved by calling a clone(), also passing False.
  24335. * This will make creation of children, recursive.
  24336. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24337. */
  24338. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24339. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24340. /**
  24341. * Gets the class name
  24342. * @returns the string "Mesh".
  24343. */
  24344. getClassName(): string;
  24345. /** @hidden */
  24346. readonly _isMesh: boolean;
  24347. /**
  24348. * Returns a description of this mesh
  24349. * @param fullDetails define if full details about this mesh must be used
  24350. * @returns a descriptive string representing this mesh
  24351. */
  24352. toString(fullDetails?: boolean): string;
  24353. /** @hidden */
  24354. _unBindEffect(): void;
  24355. /**
  24356. * Gets a boolean indicating if this mesh has LOD
  24357. */
  24358. readonly hasLODLevels: boolean;
  24359. /**
  24360. * Gets the list of MeshLODLevel associated with the current mesh
  24361. * @returns an array of MeshLODLevel
  24362. */
  24363. getLODLevels(): MeshLODLevel[];
  24364. private _sortLODLevels;
  24365. /**
  24366. * Add a mesh as LOD level triggered at the given distance.
  24367. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24368. * @param distance The distance from the center of the object to show this level
  24369. * @param mesh The mesh to be added as LOD level (can be null)
  24370. * @return This mesh (for chaining)
  24371. */
  24372. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24373. /**
  24374. * Returns the LOD level mesh at the passed distance or null if not found.
  24375. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24376. * @param distance The distance from the center of the object to show this level
  24377. * @returns a Mesh or `null`
  24378. */
  24379. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24380. /**
  24381. * Remove a mesh from the LOD array
  24382. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24383. * @param mesh defines the mesh to be removed
  24384. * @return This mesh (for chaining)
  24385. */
  24386. removeLODLevel(mesh: Mesh): Mesh;
  24387. /**
  24388. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24389. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24390. * @param camera defines the camera to use to compute distance
  24391. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24392. * @return This mesh (for chaining)
  24393. */
  24394. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24395. /**
  24396. * Gets the mesh internal Geometry object
  24397. */
  24398. readonly geometry: Nullable<Geometry>;
  24399. /**
  24400. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24401. * @returns the total number of vertices
  24402. */
  24403. getTotalVertices(): number;
  24404. /**
  24405. * Returns the content of an associated vertex buffer
  24406. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24407. * - VertexBuffer.PositionKind
  24408. * - VertexBuffer.UVKind
  24409. * - VertexBuffer.UV2Kind
  24410. * - VertexBuffer.UV3Kind
  24411. * - VertexBuffer.UV4Kind
  24412. * - VertexBuffer.UV5Kind
  24413. * - VertexBuffer.UV6Kind
  24414. * - VertexBuffer.ColorKind
  24415. * - VertexBuffer.MatricesIndicesKind
  24416. * - VertexBuffer.MatricesIndicesExtraKind
  24417. * - VertexBuffer.MatricesWeightsKind
  24418. * - VertexBuffer.MatricesWeightsExtraKind
  24419. * @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
  24420. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24421. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24422. */
  24423. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24424. /**
  24425. * Returns the mesh VertexBuffer object from the requested `kind`
  24426. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24427. * - VertexBuffer.PositionKind
  24428. * - VertexBuffer.NormalKind
  24429. * - VertexBuffer.UVKind
  24430. * - VertexBuffer.UV2Kind
  24431. * - VertexBuffer.UV3Kind
  24432. * - VertexBuffer.UV4Kind
  24433. * - VertexBuffer.UV5Kind
  24434. * - VertexBuffer.UV6Kind
  24435. * - VertexBuffer.ColorKind
  24436. * - VertexBuffer.MatricesIndicesKind
  24437. * - VertexBuffer.MatricesIndicesExtraKind
  24438. * - VertexBuffer.MatricesWeightsKind
  24439. * - VertexBuffer.MatricesWeightsExtraKind
  24440. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24441. */
  24442. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24443. /**
  24444. * Tests if a specific vertex buffer is associated with this mesh
  24445. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24446. * - VertexBuffer.PositionKind
  24447. * - VertexBuffer.NormalKind
  24448. * - VertexBuffer.UVKind
  24449. * - VertexBuffer.UV2Kind
  24450. * - VertexBuffer.UV3Kind
  24451. * - VertexBuffer.UV4Kind
  24452. * - VertexBuffer.UV5Kind
  24453. * - VertexBuffer.UV6Kind
  24454. * - VertexBuffer.ColorKind
  24455. * - VertexBuffer.MatricesIndicesKind
  24456. * - VertexBuffer.MatricesIndicesExtraKind
  24457. * - VertexBuffer.MatricesWeightsKind
  24458. * - VertexBuffer.MatricesWeightsExtraKind
  24459. * @returns a boolean
  24460. */
  24461. isVerticesDataPresent(kind: string): boolean;
  24462. /**
  24463. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24464. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24465. * - VertexBuffer.PositionKind
  24466. * - VertexBuffer.UVKind
  24467. * - VertexBuffer.UV2Kind
  24468. * - VertexBuffer.UV3Kind
  24469. * - VertexBuffer.UV4Kind
  24470. * - VertexBuffer.UV5Kind
  24471. * - VertexBuffer.UV6Kind
  24472. * - VertexBuffer.ColorKind
  24473. * - VertexBuffer.MatricesIndicesKind
  24474. * - VertexBuffer.MatricesIndicesExtraKind
  24475. * - VertexBuffer.MatricesWeightsKind
  24476. * - VertexBuffer.MatricesWeightsExtraKind
  24477. * @returns a boolean
  24478. */
  24479. isVertexBufferUpdatable(kind: string): boolean;
  24480. /**
  24481. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24482. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24483. * - VertexBuffer.PositionKind
  24484. * - VertexBuffer.NormalKind
  24485. * - VertexBuffer.UVKind
  24486. * - VertexBuffer.UV2Kind
  24487. * - VertexBuffer.UV3Kind
  24488. * - VertexBuffer.UV4Kind
  24489. * - VertexBuffer.UV5Kind
  24490. * - VertexBuffer.UV6Kind
  24491. * - VertexBuffer.ColorKind
  24492. * - VertexBuffer.MatricesIndicesKind
  24493. * - VertexBuffer.MatricesIndicesExtraKind
  24494. * - VertexBuffer.MatricesWeightsKind
  24495. * - VertexBuffer.MatricesWeightsExtraKind
  24496. * @returns an array of strings
  24497. */
  24498. getVerticesDataKinds(): string[];
  24499. /**
  24500. * Returns a positive integer : the total number of indices in this mesh geometry.
  24501. * @returns the numner of indices or zero if the mesh has no geometry.
  24502. */
  24503. getTotalIndices(): number;
  24504. /**
  24505. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24506. * @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.
  24507. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24508. * @returns the indices array or an empty array if the mesh has no geometry
  24509. */
  24510. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24511. readonly isBlocked: boolean;
  24512. /**
  24513. * Determine if the current mesh is ready to be rendered
  24514. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24515. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24516. * @returns true if all associated assets are ready (material, textures, shaders)
  24517. */
  24518. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24519. /**
  24520. * 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.
  24521. */
  24522. readonly areNormalsFrozen: boolean;
  24523. /**
  24524. * 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.
  24525. * @returns the current mesh
  24526. */
  24527. freezeNormals(): Mesh;
  24528. /**
  24529. * 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
  24530. * @returns the current mesh
  24531. */
  24532. unfreezeNormals(): Mesh;
  24533. /**
  24534. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24535. */
  24536. overridenInstanceCount: number;
  24537. /** @hidden */
  24538. _preActivate(): Mesh;
  24539. /** @hidden */
  24540. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24541. /** @hidden */
  24542. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24543. /**
  24544. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24545. * This means the mesh underlying bounding box and sphere are recomputed.
  24546. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24547. * @returns the current mesh
  24548. */
  24549. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24550. /** @hidden */
  24551. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24552. /**
  24553. * This function will subdivide the mesh into multiple submeshes
  24554. * @param count defines the expected number of submeshes
  24555. */
  24556. subdivide(count: number): void;
  24557. /**
  24558. * Copy a FloatArray into a specific associated vertex buffer
  24559. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24560. * - VertexBuffer.PositionKind
  24561. * - VertexBuffer.UVKind
  24562. * - VertexBuffer.UV2Kind
  24563. * - VertexBuffer.UV3Kind
  24564. * - VertexBuffer.UV4Kind
  24565. * - VertexBuffer.UV5Kind
  24566. * - VertexBuffer.UV6Kind
  24567. * - VertexBuffer.ColorKind
  24568. * - VertexBuffer.MatricesIndicesKind
  24569. * - VertexBuffer.MatricesIndicesExtraKind
  24570. * - VertexBuffer.MatricesWeightsKind
  24571. * - VertexBuffer.MatricesWeightsExtraKind
  24572. * @param data defines the data source
  24573. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24574. * @param stride defines the data stride size (can be null)
  24575. * @returns the current mesh
  24576. */
  24577. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24578. /**
  24579. * Flags an associated vertex buffer as updatable
  24580. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24581. * - VertexBuffer.PositionKind
  24582. * - VertexBuffer.UVKind
  24583. * - VertexBuffer.UV2Kind
  24584. * - VertexBuffer.UV3Kind
  24585. * - VertexBuffer.UV4Kind
  24586. * - VertexBuffer.UV5Kind
  24587. * - VertexBuffer.UV6Kind
  24588. * - VertexBuffer.ColorKind
  24589. * - VertexBuffer.MatricesIndicesKind
  24590. * - VertexBuffer.MatricesIndicesExtraKind
  24591. * - VertexBuffer.MatricesWeightsKind
  24592. * - VertexBuffer.MatricesWeightsExtraKind
  24593. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24594. */
  24595. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24596. /**
  24597. * Sets the mesh global Vertex Buffer
  24598. * @param buffer defines the buffer to use
  24599. * @returns the current mesh
  24600. */
  24601. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24602. /**
  24603. * Update a specific associated vertex buffer
  24604. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24605. * - VertexBuffer.PositionKind
  24606. * - VertexBuffer.UVKind
  24607. * - VertexBuffer.UV2Kind
  24608. * - VertexBuffer.UV3Kind
  24609. * - VertexBuffer.UV4Kind
  24610. * - VertexBuffer.UV5Kind
  24611. * - VertexBuffer.UV6Kind
  24612. * - VertexBuffer.ColorKind
  24613. * - VertexBuffer.MatricesIndicesKind
  24614. * - VertexBuffer.MatricesIndicesExtraKind
  24615. * - VertexBuffer.MatricesWeightsKind
  24616. * - VertexBuffer.MatricesWeightsExtraKind
  24617. * @param data defines the data source
  24618. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24619. * @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)
  24620. * @returns the current mesh
  24621. */
  24622. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24623. /**
  24624. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24625. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24626. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24627. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24628. * @returns the current mesh
  24629. */
  24630. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24631. /**
  24632. * Creates a un-shared specific occurence of the geometry for the mesh.
  24633. * @returns the current mesh
  24634. */
  24635. makeGeometryUnique(): Mesh;
  24636. /**
  24637. * Set the index buffer of this mesh
  24638. * @param indices defines the source data
  24639. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24640. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24641. * @returns the current mesh
  24642. */
  24643. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24644. /**
  24645. * Update the current index buffer
  24646. * @param indices defines the source data
  24647. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24648. * @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)
  24649. * @returns the current mesh
  24650. */
  24651. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24652. /**
  24653. * Invert the geometry to move from a right handed system to a left handed one.
  24654. * @returns the current mesh
  24655. */
  24656. toLeftHanded(): Mesh;
  24657. /** @hidden */
  24658. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24659. /** @hidden */
  24660. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24661. /**
  24662. * Registers for this mesh a javascript function called just before the rendering process
  24663. * @param func defines the function to call before rendering this mesh
  24664. * @returns the current mesh
  24665. */
  24666. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24667. /**
  24668. * Disposes a previously registered javascript function called before the rendering
  24669. * @param func defines the function to remove
  24670. * @returns the current mesh
  24671. */
  24672. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24673. /**
  24674. * Registers for this mesh a javascript function called just after the rendering is complete
  24675. * @param func defines the function to call after rendering this mesh
  24676. * @returns the current mesh
  24677. */
  24678. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24679. /**
  24680. * Disposes a previously registered javascript function called after the rendering.
  24681. * @param func defines the function to remove
  24682. * @returns the current mesh
  24683. */
  24684. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24685. /** @hidden */
  24686. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24687. /** @hidden */
  24688. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24689. /** @hidden */
  24690. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24691. /** @hidden */
  24692. _rebuild(): void;
  24693. /** @hidden */
  24694. _freeze(): void;
  24695. /** @hidden */
  24696. _unFreeze(): void;
  24697. /**
  24698. * 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
  24699. * @param subMesh defines the subMesh to render
  24700. * @param enableAlphaMode defines if alpha mode can be changed
  24701. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24702. * @returns the current mesh
  24703. */
  24704. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24705. private _onBeforeDraw;
  24706. /**
  24707. * Renormalize the mesh and patch it up if there are no weights
  24708. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24709. * However in the case of zero weights then we set just a single influence to 1.
  24710. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24711. */
  24712. cleanMatrixWeights(): void;
  24713. private normalizeSkinFourWeights;
  24714. private normalizeSkinWeightsAndExtra;
  24715. /**
  24716. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24717. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24718. * the user know there was an issue with importing the mesh
  24719. * @returns a validation object with skinned, valid and report string
  24720. */
  24721. validateSkinning(): {
  24722. skinned: boolean;
  24723. valid: boolean;
  24724. report: string;
  24725. };
  24726. /** @hidden */
  24727. _checkDelayState(): Mesh;
  24728. private _queueLoad;
  24729. /**
  24730. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24731. * A mesh is in the frustum if its bounding box intersects the frustum
  24732. * @param frustumPlanes defines the frustum to test
  24733. * @returns true if the mesh is in the frustum planes
  24734. */
  24735. isInFrustum(frustumPlanes: Plane[]): boolean;
  24736. /**
  24737. * Sets the mesh material by the material or multiMaterial `id` property
  24738. * @param id is a string identifying the material or the multiMaterial
  24739. * @returns the current mesh
  24740. */
  24741. setMaterialByID(id: string): Mesh;
  24742. /**
  24743. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24744. * @returns an array of IAnimatable
  24745. */
  24746. getAnimatables(): IAnimatable[];
  24747. /**
  24748. * Modifies the mesh geometry according to the passed transformation matrix.
  24749. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24750. * The mesh normals are modified using the same transformation.
  24751. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24752. * @param transform defines the transform matrix to use
  24753. * @see http://doc.babylonjs.com/resources/baking_transformations
  24754. * @returns the current mesh
  24755. */
  24756. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24757. /**
  24758. * Modifies the mesh geometry according to its own current World Matrix.
  24759. * The mesh World Matrix is then reset.
  24760. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24761. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24762. * @see http://doc.babylonjs.com/resources/baking_transformations
  24763. * @returns the current mesh
  24764. */
  24765. bakeCurrentTransformIntoVertices(): Mesh;
  24766. /** @hidden */
  24767. readonly _positions: Nullable<Vector3[]>;
  24768. /** @hidden */
  24769. _resetPointsArrayCache(): Mesh;
  24770. /** @hidden */
  24771. _generatePointsArray(): boolean;
  24772. /**
  24773. * Returns a new Mesh object generated from the current mesh properties.
  24774. * This method must not get confused with createInstance()
  24775. * @param name is a string, the name given to the new mesh
  24776. * @param newParent can be any Node object (default `null`)
  24777. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24778. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24779. * @returns a new mesh
  24780. */
  24781. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24782. /**
  24783. * Releases resources associated with this mesh.
  24784. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24785. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24786. */
  24787. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24788. /**
  24789. * Modifies the mesh geometry according to a displacement map.
  24790. * 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.
  24791. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24792. * @param url is a string, the URL from the image file is to be downloaded.
  24793. * @param minHeight is the lower limit of the displacement.
  24794. * @param maxHeight is the upper limit of the displacement.
  24795. * @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.
  24796. * @param uvOffset is an optional vector2 used to offset UV.
  24797. * @param uvScale is an optional vector2 used to scale UV.
  24798. * @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.
  24799. * @returns the Mesh.
  24800. */
  24801. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24802. /**
  24803. * Modifies the mesh geometry according to a displacementMap buffer.
  24804. * 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.
  24805. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24806. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24807. * @param heightMapWidth is the width of the buffer image.
  24808. * @param heightMapHeight is the height of the buffer image.
  24809. * @param minHeight is the lower limit of the displacement.
  24810. * @param maxHeight is the upper limit of the displacement.
  24811. * @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.
  24812. * @param uvOffset is an optional vector2 used to offset UV.
  24813. * @param uvScale is an optional vector2 used to scale UV.
  24814. * @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.
  24815. * @returns the Mesh.
  24816. */
  24817. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24818. /**
  24819. * Modify the mesh to get a flat shading rendering.
  24820. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24821. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24822. * @returns current mesh
  24823. */
  24824. convertToFlatShadedMesh(): Mesh;
  24825. /**
  24826. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24827. * In other words, more vertices, no more indices and a single bigger VBO.
  24828. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24829. * @returns current mesh
  24830. */
  24831. convertToUnIndexedMesh(): Mesh;
  24832. /**
  24833. * Inverses facet orientations.
  24834. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24835. * @param flipNormals will also inverts the normals
  24836. * @returns current mesh
  24837. */
  24838. flipFaces(flipNormals?: boolean): Mesh;
  24839. /**
  24840. * Increase the number of facets and hence vertices in a mesh
  24841. * Vertex normals are interpolated from existing vertex normals
  24842. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24843. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24844. */
  24845. increaseVertices(numberPerEdge: number): void;
  24846. /**
  24847. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24848. * This will undo any application of covertToFlatShadedMesh
  24849. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24850. */
  24851. forceSharedVertices(): void;
  24852. /** @hidden */
  24853. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24854. /** @hidden */
  24855. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24856. /**
  24857. * Creates a new InstancedMesh object from the mesh model.
  24858. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24859. * @param name defines the name of the new instance
  24860. * @returns a new InstancedMesh
  24861. */
  24862. createInstance(name: string): InstancedMesh;
  24863. /**
  24864. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24865. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24866. * @returns the current mesh
  24867. */
  24868. synchronizeInstances(): Mesh;
  24869. /**
  24870. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24871. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24872. * This should be used together with the simplification to avoid disappearing triangles.
  24873. * @param successCallback an optional success callback to be called after the optimization finished.
  24874. * @returns the current mesh
  24875. */
  24876. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24877. /**
  24878. * Serialize current mesh
  24879. * @param serializationObject defines the object which will receive the serialization data
  24880. */
  24881. serialize(serializationObject: any): void;
  24882. /** @hidden */
  24883. _syncGeometryWithMorphTargetManager(): void;
  24884. /** @hidden */
  24885. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24886. /**
  24887. * Returns a new Mesh object parsed from the source provided.
  24888. * @param parsedMesh is the source
  24889. * @param scene defines the hosting scene
  24890. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24891. * @returns a new Mesh
  24892. */
  24893. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24894. /**
  24895. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24896. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24897. * @param name defines the name of the mesh to create
  24898. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24899. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24900. * @param closePath creates a seam between the first and the last points of each path of the path array
  24901. * @param offset is taken in account only if the `pathArray` is containing a single path
  24902. * @param scene defines the hosting scene
  24903. * @param updatable defines if the mesh must be flagged as updatable
  24904. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24905. * @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)
  24906. * @returns a new Mesh
  24907. */
  24908. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24909. /**
  24910. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24911. * @param name defines the name of the mesh to create
  24912. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24913. * @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
  24914. * @param scene defines the hosting scene
  24915. * @param updatable defines if the mesh must be flagged as updatable
  24916. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24917. * @returns a new Mesh
  24918. */
  24919. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24920. /**
  24921. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24922. * @param name defines the name of the mesh to create
  24923. * @param size sets the size (float) of each box side (default 1)
  24924. * @param scene defines the hosting scene
  24925. * @param updatable defines if the mesh must be flagged as updatable
  24926. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24927. * @returns a new Mesh
  24928. */
  24929. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24930. /**
  24931. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24932. * @param name defines the name of the mesh to create
  24933. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24934. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24935. * @param scene defines the hosting scene
  24936. * @param updatable defines if the mesh must be flagged as updatable
  24937. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24938. * @returns a new Mesh
  24939. */
  24940. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24941. /**
  24942. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24943. * @param name defines the name of the mesh to create
  24944. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24945. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24946. * @param scene defines the hosting scene
  24947. * @returns a new Mesh
  24948. */
  24949. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24950. /**
  24951. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24952. * @param name defines the name of the mesh to create
  24953. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24954. * @param diameterTop set the top cap diameter (floats, default 1)
  24955. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24956. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24957. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24958. * @param scene defines the hosting scene
  24959. * @param updatable defines if the mesh must be flagged as updatable
  24960. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24961. * @returns a new Mesh
  24962. */
  24963. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24964. /**
  24965. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24966. * @param name defines the name of the mesh to create
  24967. * @param diameter sets the diameter size (float) of the torus (default 1)
  24968. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24969. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24970. * @param scene defines the hosting scene
  24971. * @param updatable defines if the mesh must be flagged as updatable
  24972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24973. * @returns a new Mesh
  24974. */
  24975. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24976. /**
  24977. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24978. * @param name defines the name of the mesh to create
  24979. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24980. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24981. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24982. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24983. * @param p the number of windings on X axis (positive integers, default 2)
  24984. * @param q the number of windings on Y axis (positive integers, default 3)
  24985. * @param scene defines the hosting scene
  24986. * @param updatable defines if the mesh must be flagged as updatable
  24987. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24988. * @returns a new Mesh
  24989. */
  24990. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24991. /**
  24992. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24993. * @param name defines the name of the mesh to create
  24994. * @param points is an array successive Vector3
  24995. * @param scene defines the hosting scene
  24996. * @param updatable defines if the mesh must be flagged as updatable
  24997. * @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).
  24998. * @returns a new Mesh
  24999. */
  25000. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25001. /**
  25002. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25003. * @param name defines the name of the mesh to create
  25004. * @param points is an array successive Vector3
  25005. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25006. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25007. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25008. * @param scene defines the hosting scene
  25009. * @param updatable defines if the mesh must be flagged as updatable
  25010. * @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)
  25011. * @returns a new Mesh
  25012. */
  25013. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25014. /**
  25015. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25016. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25017. * 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.
  25018. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25019. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25020. * Remember you can only change the shape positions, not their number when updating a polygon.
  25021. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25022. * @param name defines the name of the mesh to create
  25023. * @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
  25024. * @param scene defines the hosting scene
  25025. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25026. * @param updatable defines if the mesh must be flagged as updatable
  25027. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25028. * @param earcutInjection can be used to inject your own earcut reference
  25029. * @returns a new Mesh
  25030. */
  25031. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25032. /**
  25033. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25034. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25035. * @param name defines the name of the mesh to create
  25036. * @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
  25037. * @param depth defines the height of extrusion
  25038. * @param scene defines the hosting scene
  25039. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25040. * @param updatable defines if the mesh must be flagged as updatable
  25041. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25042. * @param earcutInjection can be used to inject your own earcut reference
  25043. * @returns a new Mesh
  25044. */
  25045. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25046. /**
  25047. * Creates an extruded shape mesh.
  25048. * 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
  25049. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25050. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25051. * @param name defines the name of the mesh to create
  25052. * @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
  25053. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25054. * @param scale is the value to scale the shape
  25055. * @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
  25056. * @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
  25057. * @param scene defines the hosting scene
  25058. * @param updatable defines if the mesh must be flagged as updatable
  25059. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25060. * @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)
  25061. * @returns a new Mesh
  25062. */
  25063. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25064. /**
  25065. * Creates an custom extruded shape mesh.
  25066. * The custom extrusion is a parametric shape.
  25067. * It has no predefined shape. Its final shape will depend on the input parameters.
  25068. * Please consider using the same method from the MeshBuilder class instead
  25069. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25070. * @param name defines the name of the mesh to create
  25071. * @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
  25072. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25073. * @param scaleFunction is a custom Javascript function called on each path point
  25074. * @param rotationFunction is a custom Javascript function called on each path point
  25075. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25076. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25077. * @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
  25078. * @param scene defines the hosting scene
  25079. * @param updatable defines if the mesh must be flagged as updatable
  25080. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25081. * @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)
  25082. * @returns a new Mesh
  25083. */
  25084. 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;
  25085. /**
  25086. * Creates lathe mesh.
  25087. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25088. * Please consider using the same method from the MeshBuilder class instead
  25089. * @param name defines the name of the mesh to create
  25090. * @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
  25091. * @param radius is the radius value of the lathe
  25092. * @param tessellation is the side number of the lathe.
  25093. * @param scene defines the hosting scene
  25094. * @param updatable defines if the mesh must be flagged as updatable
  25095. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25096. * @returns a new Mesh
  25097. */
  25098. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25099. /**
  25100. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25101. * @param name defines the name of the mesh to create
  25102. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25103. * @param scene defines the hosting scene
  25104. * @param updatable defines if the mesh must be flagged as updatable
  25105. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25106. * @returns a new Mesh
  25107. */
  25108. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25109. /**
  25110. * Creates a ground mesh.
  25111. * Please consider using the same method from the MeshBuilder class instead
  25112. * @param name defines the name of the mesh to create
  25113. * @param width set the width of the ground
  25114. * @param height set the height of the ground
  25115. * @param subdivisions sets the number of subdivisions per side
  25116. * @param scene defines the hosting scene
  25117. * @param updatable defines if the mesh must be flagged as updatable
  25118. * @returns a new Mesh
  25119. */
  25120. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25121. /**
  25122. * Creates a tiled ground mesh.
  25123. * Please consider using the same method from the MeshBuilder class instead
  25124. * @param name defines the name of the mesh to create
  25125. * @param xmin set the ground minimum X coordinate
  25126. * @param zmin set the ground minimum Y coordinate
  25127. * @param xmax set the ground maximum X coordinate
  25128. * @param zmax set the ground maximum Z coordinate
  25129. * @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
  25130. * @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
  25131. * @param scene defines the hosting scene
  25132. * @param updatable defines if the mesh must be flagged as updatable
  25133. * @returns a new Mesh
  25134. */
  25135. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25136. w: number;
  25137. h: number;
  25138. }, precision: {
  25139. w: number;
  25140. h: number;
  25141. }, scene: Scene, updatable?: boolean): Mesh;
  25142. /**
  25143. * Creates a ground mesh from a height map.
  25144. * Please consider using the same method from the MeshBuilder class instead
  25145. * @see http://doc.babylonjs.com/babylon101/height_map
  25146. * @param name defines the name of the mesh to create
  25147. * @param url sets the URL of the height map image resource
  25148. * @param width set the ground width size
  25149. * @param height set the ground height size
  25150. * @param subdivisions sets the number of subdivision per side
  25151. * @param minHeight is the minimum altitude on the ground
  25152. * @param maxHeight is the maximum altitude on the ground
  25153. * @param scene defines the hosting scene
  25154. * @param updatable defines if the mesh must be flagged as updatable
  25155. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25156. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25157. * @returns a new Mesh
  25158. */
  25159. 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;
  25160. /**
  25161. * Creates a tube mesh.
  25162. * The tube is a parametric shape.
  25163. * It has no predefined shape. Its final shape will depend on the input parameters.
  25164. * Please consider using the same method from the MeshBuilder class instead
  25165. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25166. * @param name defines the name of the mesh to create
  25167. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25168. * @param radius sets the tube radius size
  25169. * @param tessellation is the number of sides on the tubular surface
  25170. * @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
  25171. * @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
  25172. * @param scene defines the hosting scene
  25173. * @param updatable defines if the mesh must be flagged as updatable
  25174. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25175. * @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)
  25176. * @returns a new Mesh
  25177. */
  25178. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25179. (i: number, distance: number): number;
  25180. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25181. /**
  25182. * Creates a polyhedron mesh.
  25183. * Please consider using the same method from the MeshBuilder class instead.
  25184. * * 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
  25185. * * The parameter `size` (positive float, default 1) sets the polygon size
  25186. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25187. * * 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`
  25188. * * 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
  25189. * * 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)`)
  25190. * * 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
  25191. * * 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
  25192. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25193. * * 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
  25194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25195. * @param name defines the name of the mesh to create
  25196. * @param options defines the options used to create the mesh
  25197. * @param scene defines the hosting scene
  25198. * @returns a new Mesh
  25199. */
  25200. static CreatePolyhedron(name: string, options: {
  25201. type?: number;
  25202. size?: number;
  25203. sizeX?: number;
  25204. sizeY?: number;
  25205. sizeZ?: number;
  25206. custom?: any;
  25207. faceUV?: Vector4[];
  25208. faceColors?: Color4[];
  25209. updatable?: boolean;
  25210. sideOrientation?: number;
  25211. }, scene: Scene): Mesh;
  25212. /**
  25213. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25214. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25215. * * 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`)
  25216. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25217. * * 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
  25218. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25219. * * 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
  25220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25221. * @param name defines the name of the mesh
  25222. * @param options defines the options used to create the mesh
  25223. * @param scene defines the hosting scene
  25224. * @returns a new Mesh
  25225. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25226. */
  25227. static CreateIcoSphere(name: string, options: {
  25228. radius?: number;
  25229. flat?: boolean;
  25230. subdivisions?: number;
  25231. sideOrientation?: number;
  25232. updatable?: boolean;
  25233. }, scene: Scene): Mesh;
  25234. /**
  25235. * Creates a decal mesh.
  25236. * Please consider using the same method from the MeshBuilder class instead.
  25237. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25238. * @param name defines the name of the mesh
  25239. * @param sourceMesh defines the mesh receiving the decal
  25240. * @param position sets the position of the decal in world coordinates
  25241. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25242. * @param size sets the decal scaling
  25243. * @param angle sets the angle to rotate the decal
  25244. * @returns a new Mesh
  25245. */
  25246. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25247. /**
  25248. * Prepare internal position array for software CPU skinning
  25249. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25250. */
  25251. setPositionsForCPUSkinning(): Float32Array;
  25252. /**
  25253. * Prepare internal normal array for software CPU skinning
  25254. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25255. */
  25256. setNormalsForCPUSkinning(): Float32Array;
  25257. /**
  25258. * Updates the vertex buffer by applying transformation from the bones
  25259. * @param skeleton defines the skeleton to apply to current mesh
  25260. * @returns the current mesh
  25261. */
  25262. applySkeleton(skeleton: Skeleton): Mesh;
  25263. /**
  25264. * 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
  25265. * @param meshes defines the list of meshes to scan
  25266. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25267. */
  25268. static MinMax(meshes: AbstractMesh[]): {
  25269. min: Vector3;
  25270. max: Vector3;
  25271. };
  25272. /**
  25273. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25274. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25275. * @returns a vector3
  25276. */
  25277. static Center(meshesOrMinMaxVector: {
  25278. min: Vector3;
  25279. max: Vector3;
  25280. } | AbstractMesh[]): Vector3;
  25281. /**
  25282. * Merge the array of meshes into a single mesh for performance reasons.
  25283. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25284. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25285. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25286. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25287. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25288. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25289. * @returns a new mesh
  25290. */
  25291. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25292. /** @hidden */
  25293. addInstance(instance: InstancedMesh): void;
  25294. /** @hidden */
  25295. removeInstance(instance: InstancedMesh): void;
  25296. }
  25297. }
  25298. declare module "babylonjs/Cameras/camera" {
  25299. import { SmartArray } from "babylonjs/Misc/smartArray";
  25300. import { Observable } from "babylonjs/Misc/observable";
  25301. import { Nullable } from "babylonjs/types";
  25302. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25303. import { Scene } from "babylonjs/scene";
  25304. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25305. import { Node } from "babylonjs/node";
  25306. import { Mesh } from "babylonjs/Meshes/mesh";
  25307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25308. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25309. import { Viewport } from "babylonjs/Maths/math.viewport";
  25310. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25311. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25312. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25313. import { Ray } from "babylonjs/Culling/ray";
  25314. /**
  25315. * This is the base class of all the camera used in the application.
  25316. * @see http://doc.babylonjs.com/features/cameras
  25317. */
  25318. export class Camera extends Node {
  25319. /** @hidden */
  25320. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25321. /**
  25322. * This is the default projection mode used by the cameras.
  25323. * It helps recreating a feeling of perspective and better appreciate depth.
  25324. * This is the best way to simulate real life cameras.
  25325. */
  25326. static readonly PERSPECTIVE_CAMERA: number;
  25327. /**
  25328. * This helps creating camera with an orthographic mode.
  25329. * 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.
  25330. */
  25331. static readonly ORTHOGRAPHIC_CAMERA: number;
  25332. /**
  25333. * This is the default FOV mode for perspective cameras.
  25334. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25335. */
  25336. static readonly FOVMODE_VERTICAL_FIXED: number;
  25337. /**
  25338. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25339. */
  25340. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25341. /**
  25342. * This specifies ther is no need for a camera rig.
  25343. * Basically only one eye is rendered corresponding to the camera.
  25344. */
  25345. static readonly RIG_MODE_NONE: number;
  25346. /**
  25347. * Simulates a camera Rig with one blue eye and one red eye.
  25348. * This can be use with 3d blue and red glasses.
  25349. */
  25350. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25351. /**
  25352. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25353. */
  25354. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25355. /**
  25356. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25357. */
  25358. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25359. /**
  25360. * Defines that both eyes of the camera will be rendered over under each other.
  25361. */
  25362. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25363. /**
  25364. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25365. */
  25366. static readonly RIG_MODE_VR: number;
  25367. /**
  25368. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25369. */
  25370. static readonly RIG_MODE_WEBVR: number;
  25371. /**
  25372. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25373. */
  25374. static readonly RIG_MODE_CUSTOM: number;
  25375. /**
  25376. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25377. */
  25378. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25379. /**
  25380. * Define the input manager associated with the camera.
  25381. */
  25382. inputs: CameraInputsManager<Camera>;
  25383. /** @hidden */
  25384. _position: Vector3;
  25385. /**
  25386. * Define the current local position of the camera in the scene
  25387. */
  25388. position: Vector3;
  25389. /**
  25390. * The vector the camera should consider as up.
  25391. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25392. */
  25393. upVector: Vector3;
  25394. /**
  25395. * Define the current limit on the left side for an orthographic camera
  25396. * In scene unit
  25397. */
  25398. orthoLeft: Nullable<number>;
  25399. /**
  25400. * Define the current limit on the right side for an orthographic camera
  25401. * In scene unit
  25402. */
  25403. orthoRight: Nullable<number>;
  25404. /**
  25405. * Define the current limit on the bottom side for an orthographic camera
  25406. * In scene unit
  25407. */
  25408. orthoBottom: Nullable<number>;
  25409. /**
  25410. * Define the current limit on the top side for an orthographic camera
  25411. * In scene unit
  25412. */
  25413. orthoTop: Nullable<number>;
  25414. /**
  25415. * Field Of View is set in Radians. (default is 0.8)
  25416. */
  25417. fov: number;
  25418. /**
  25419. * Define the minimum distance the camera can see from.
  25420. * This is important to note that the depth buffer are not infinite and the closer it starts
  25421. * the more your scene might encounter depth fighting issue.
  25422. */
  25423. minZ: number;
  25424. /**
  25425. * Define the maximum distance the camera can see to.
  25426. * This is important to note that the depth buffer are not infinite and the further it end
  25427. * the more your scene might encounter depth fighting issue.
  25428. */
  25429. maxZ: number;
  25430. /**
  25431. * Define the default inertia of the camera.
  25432. * This helps giving a smooth feeling to the camera movement.
  25433. */
  25434. inertia: number;
  25435. /**
  25436. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25437. */
  25438. mode: number;
  25439. /**
  25440. * Define wether the camera is intermediate.
  25441. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25442. */
  25443. isIntermediate: boolean;
  25444. /**
  25445. * Define the viewport of the camera.
  25446. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25447. */
  25448. viewport: Viewport;
  25449. /**
  25450. * Restricts the camera to viewing objects with the same layerMask.
  25451. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25452. */
  25453. layerMask: number;
  25454. /**
  25455. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25456. */
  25457. fovMode: number;
  25458. /**
  25459. * Rig mode of the camera.
  25460. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25461. * This is normally controlled byt the camera themselves as internal use.
  25462. */
  25463. cameraRigMode: number;
  25464. /**
  25465. * Defines the distance between both "eyes" in case of a RIG
  25466. */
  25467. interaxialDistance: number;
  25468. /**
  25469. * Defines if stereoscopic rendering is done side by side or over under.
  25470. */
  25471. isStereoscopicSideBySide: boolean;
  25472. /**
  25473. * 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
  25474. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25475. * else in the scene. (Eg. security camera)
  25476. *
  25477. * 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)
  25478. */
  25479. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25480. /**
  25481. * When set, the camera will render to this render target instead of the default canvas
  25482. *
  25483. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25484. */
  25485. outputRenderTarget: Nullable<RenderTargetTexture>;
  25486. /**
  25487. * Observable triggered when the camera view matrix has changed.
  25488. */
  25489. onViewMatrixChangedObservable: Observable<Camera>;
  25490. /**
  25491. * Observable triggered when the camera Projection matrix has changed.
  25492. */
  25493. onProjectionMatrixChangedObservable: Observable<Camera>;
  25494. /**
  25495. * Observable triggered when the inputs have been processed.
  25496. */
  25497. onAfterCheckInputsObservable: Observable<Camera>;
  25498. /**
  25499. * Observable triggered when reset has been called and applied to the camera.
  25500. */
  25501. onRestoreStateObservable: Observable<Camera>;
  25502. /** @hidden */
  25503. _cameraRigParams: any;
  25504. /** @hidden */
  25505. _rigCameras: Camera[];
  25506. /** @hidden */
  25507. _rigPostProcess: Nullable<PostProcess>;
  25508. protected _webvrViewMatrix: Matrix;
  25509. /** @hidden */
  25510. _skipRendering: boolean;
  25511. /** @hidden */
  25512. _projectionMatrix: Matrix;
  25513. /** @hidden */
  25514. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25515. /** @hidden */
  25516. _activeMeshes: SmartArray<AbstractMesh>;
  25517. protected _globalPosition: Vector3;
  25518. /** @hidden */
  25519. _computedViewMatrix: Matrix;
  25520. private _doNotComputeProjectionMatrix;
  25521. private _transformMatrix;
  25522. private _frustumPlanes;
  25523. private _refreshFrustumPlanes;
  25524. private _storedFov;
  25525. private _stateStored;
  25526. /**
  25527. * Instantiates a new camera object.
  25528. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25529. * @see http://doc.babylonjs.com/features/cameras
  25530. * @param name Defines the name of the camera in the scene
  25531. * @param position Defines the position of the camera
  25532. * @param scene Defines the scene the camera belongs too
  25533. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25534. */
  25535. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25536. /**
  25537. * Store current camera state (fov, position, etc..)
  25538. * @returns the camera
  25539. */
  25540. storeState(): Camera;
  25541. /**
  25542. * Restores the camera state values if it has been stored. You must call storeState() first
  25543. */
  25544. protected _restoreStateValues(): boolean;
  25545. /**
  25546. * Restored camera state. You must call storeState() first.
  25547. * @returns true if restored and false otherwise
  25548. */
  25549. restoreState(): boolean;
  25550. /**
  25551. * Gets the class name of the camera.
  25552. * @returns the class name
  25553. */
  25554. getClassName(): string;
  25555. /** @hidden */
  25556. readonly _isCamera: boolean;
  25557. /**
  25558. * Gets a string representation of the camera useful for debug purpose.
  25559. * @param fullDetails Defines that a more verboe level of logging is required
  25560. * @returns the string representation
  25561. */
  25562. toString(fullDetails?: boolean): string;
  25563. /**
  25564. * Gets the current world space position of the camera.
  25565. */
  25566. readonly globalPosition: Vector3;
  25567. /**
  25568. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25569. * @returns the active meshe list
  25570. */
  25571. getActiveMeshes(): SmartArray<AbstractMesh>;
  25572. /**
  25573. * Check wether a mesh is part of the current active mesh list of the camera
  25574. * @param mesh Defines the mesh to check
  25575. * @returns true if active, false otherwise
  25576. */
  25577. isActiveMesh(mesh: Mesh): boolean;
  25578. /**
  25579. * Is this camera ready to be used/rendered
  25580. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25581. * @return true if the camera is ready
  25582. */
  25583. isReady(completeCheck?: boolean): boolean;
  25584. /** @hidden */
  25585. _initCache(): void;
  25586. /** @hidden */
  25587. _updateCache(ignoreParentClass?: boolean): void;
  25588. /** @hidden */
  25589. _isSynchronized(): boolean;
  25590. /** @hidden */
  25591. _isSynchronizedViewMatrix(): boolean;
  25592. /** @hidden */
  25593. _isSynchronizedProjectionMatrix(): boolean;
  25594. /**
  25595. * Attach the input controls to a specific dom element to get the input from.
  25596. * @param element Defines the element the controls should be listened from
  25597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25598. */
  25599. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25600. /**
  25601. * Detach the current controls from the specified dom element.
  25602. * @param element Defines the element to stop listening the inputs from
  25603. */
  25604. detachControl(element: HTMLElement): void;
  25605. /**
  25606. * Update the camera state according to the different inputs gathered during the frame.
  25607. */
  25608. update(): void;
  25609. /** @hidden */
  25610. _checkInputs(): void;
  25611. /** @hidden */
  25612. readonly rigCameras: Camera[];
  25613. /**
  25614. * Gets the post process used by the rig cameras
  25615. */
  25616. readonly rigPostProcess: Nullable<PostProcess>;
  25617. /**
  25618. * Internal, gets the first post proces.
  25619. * @returns the first post process to be run on this camera.
  25620. */
  25621. _getFirstPostProcess(): Nullable<PostProcess>;
  25622. private _cascadePostProcessesToRigCams;
  25623. /**
  25624. * Attach a post process to the camera.
  25625. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25626. * @param postProcess The post process to attach to the camera
  25627. * @param insertAt The position of the post process in case several of them are in use in the scene
  25628. * @returns the position the post process has been inserted at
  25629. */
  25630. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25631. /**
  25632. * Detach a post process to the camera.
  25633. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25634. * @param postProcess The post process to detach from the camera
  25635. */
  25636. detachPostProcess(postProcess: PostProcess): void;
  25637. /**
  25638. * Gets the current world matrix of the camera
  25639. */
  25640. getWorldMatrix(): Matrix;
  25641. /** @hidden */
  25642. _getViewMatrix(): Matrix;
  25643. /**
  25644. * Gets the current view matrix of the camera.
  25645. * @param force forces the camera to recompute the matrix without looking at the cached state
  25646. * @returns the view matrix
  25647. */
  25648. getViewMatrix(force?: boolean): Matrix;
  25649. /**
  25650. * Freeze the projection matrix.
  25651. * It will prevent the cache check of the camera projection compute and can speed up perf
  25652. * if no parameter of the camera are meant to change
  25653. * @param projection Defines manually a projection if necessary
  25654. */
  25655. freezeProjectionMatrix(projection?: Matrix): void;
  25656. /**
  25657. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25658. */
  25659. unfreezeProjectionMatrix(): void;
  25660. /**
  25661. * Gets the current projection matrix of the camera.
  25662. * @param force forces the camera to recompute the matrix without looking at the cached state
  25663. * @returns the projection matrix
  25664. */
  25665. getProjectionMatrix(force?: boolean): Matrix;
  25666. /**
  25667. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25668. * @returns a Matrix
  25669. */
  25670. getTransformationMatrix(): Matrix;
  25671. private _updateFrustumPlanes;
  25672. /**
  25673. * Checks if a cullable object (mesh...) is in the camera frustum
  25674. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25675. * @param target The object to check
  25676. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25677. * @returns true if the object is in frustum otherwise false
  25678. */
  25679. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25680. /**
  25681. * Checks if a cullable object (mesh...) is in the camera frustum
  25682. * Unlike isInFrustum this cheks the full bounding box
  25683. * @param target The object to check
  25684. * @returns true if the object is in frustum otherwise false
  25685. */
  25686. isCompletelyInFrustum(target: ICullable): boolean;
  25687. /**
  25688. * Gets a ray in the forward direction from the camera.
  25689. * @param length Defines the length of the ray to create
  25690. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25691. * @param origin Defines the start point of the ray which defaults to the camera position
  25692. * @returns the forward ray
  25693. */
  25694. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25695. /**
  25696. * Releases resources associated with this node.
  25697. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25698. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25699. */
  25700. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25701. /** @hidden */
  25702. _isLeftCamera: boolean;
  25703. /**
  25704. * Gets the left camera of a rig setup in case of Rigged Camera
  25705. */
  25706. readonly isLeftCamera: boolean;
  25707. /** @hidden */
  25708. _isRightCamera: boolean;
  25709. /**
  25710. * Gets the right camera of a rig setup in case of Rigged Camera
  25711. */
  25712. readonly isRightCamera: boolean;
  25713. /**
  25714. * Gets the left camera of a rig setup in case of Rigged Camera
  25715. */
  25716. readonly leftCamera: Nullable<FreeCamera>;
  25717. /**
  25718. * Gets the right camera of a rig setup in case of Rigged Camera
  25719. */
  25720. readonly rightCamera: Nullable<FreeCamera>;
  25721. /**
  25722. * Gets the left camera target of a rig setup in case of Rigged Camera
  25723. * @returns the target position
  25724. */
  25725. getLeftTarget(): Nullable<Vector3>;
  25726. /**
  25727. * Gets the right camera target of a rig setup in case of Rigged Camera
  25728. * @returns the target position
  25729. */
  25730. getRightTarget(): Nullable<Vector3>;
  25731. /**
  25732. * @hidden
  25733. */
  25734. setCameraRigMode(mode: number, rigParams: any): void;
  25735. /** @hidden */
  25736. static _setStereoscopicRigMode(camera: Camera): void;
  25737. /** @hidden */
  25738. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25739. /** @hidden */
  25740. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25741. /** @hidden */
  25742. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25743. /** @hidden */
  25744. _getVRProjectionMatrix(): Matrix;
  25745. protected _updateCameraRotationMatrix(): void;
  25746. protected _updateWebVRCameraRotationMatrix(): void;
  25747. /**
  25748. * This function MUST be overwritten by the different WebVR cameras available.
  25749. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25750. * @hidden
  25751. */
  25752. _getWebVRProjectionMatrix(): Matrix;
  25753. /**
  25754. * This function MUST be overwritten by the different WebVR cameras available.
  25755. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25756. * @hidden
  25757. */
  25758. _getWebVRViewMatrix(): Matrix;
  25759. /** @hidden */
  25760. setCameraRigParameter(name: string, value: any): void;
  25761. /**
  25762. * needs to be overridden by children so sub has required properties to be copied
  25763. * @hidden
  25764. */
  25765. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25766. /**
  25767. * May need to be overridden by children
  25768. * @hidden
  25769. */
  25770. _updateRigCameras(): void;
  25771. /** @hidden */
  25772. _setupInputs(): void;
  25773. /**
  25774. * Serialiaze the camera setup to a json represention
  25775. * @returns the JSON representation
  25776. */
  25777. serialize(): any;
  25778. /**
  25779. * Clones the current camera.
  25780. * @param name The cloned camera name
  25781. * @returns the cloned camera
  25782. */
  25783. clone(name: string): Camera;
  25784. /**
  25785. * Gets the direction of the camera relative to a given local axis.
  25786. * @param localAxis Defines the reference axis to provide a relative direction.
  25787. * @return the direction
  25788. */
  25789. getDirection(localAxis: Vector3): Vector3;
  25790. /**
  25791. * Returns the current camera absolute rotation
  25792. */
  25793. readonly absoluteRotation: Quaternion;
  25794. /**
  25795. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25796. * @param localAxis Defines the reference axis to provide a relative direction.
  25797. * @param result Defines the vector to store the result in
  25798. */
  25799. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25800. /**
  25801. * Gets a camera constructor for a given camera type
  25802. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25803. * @param name The name of the camera the result will be able to instantiate
  25804. * @param scene The scene the result will construct the camera in
  25805. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25806. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25807. * @returns a factory method to construc the camera
  25808. */
  25809. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25810. /**
  25811. * Compute the world matrix of the camera.
  25812. * @returns the camera workd matrix
  25813. */
  25814. computeWorldMatrix(): Matrix;
  25815. /**
  25816. * Parse a JSON and creates the camera from the parsed information
  25817. * @param parsedCamera The JSON to parse
  25818. * @param scene The scene to instantiate the camera in
  25819. * @returns the newly constructed camera
  25820. */
  25821. static Parse(parsedCamera: any, scene: Scene): Camera;
  25822. }
  25823. }
  25824. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25825. import { Nullable } from "babylonjs/types";
  25826. import { Scene } from "babylonjs/scene";
  25827. import { Vector4 } from "babylonjs/Maths/math.vector";
  25828. import { Mesh } from "babylonjs/Meshes/mesh";
  25829. /**
  25830. * Class containing static functions to help procedurally build meshes
  25831. */
  25832. export class DiscBuilder {
  25833. /**
  25834. * Creates a plane polygonal mesh. By default, this is a disc
  25835. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25836. * * 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
  25837. * * 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
  25838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25839. * * 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
  25840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25841. * @param name defines the name of the mesh
  25842. * @param options defines the options used to create the mesh
  25843. * @param scene defines the hosting scene
  25844. * @returns the plane polygonal mesh
  25845. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25846. */
  25847. static CreateDisc(name: string, options: {
  25848. radius?: number;
  25849. tessellation?: number;
  25850. arc?: number;
  25851. updatable?: boolean;
  25852. sideOrientation?: number;
  25853. frontUVs?: Vector4;
  25854. backUVs?: Vector4;
  25855. }, scene?: Nullable<Scene>): Mesh;
  25856. }
  25857. }
  25858. declare module "babylonjs/Particles/solidParticleSystem" {
  25859. import { Vector3 } from "babylonjs/Maths/math.vector";
  25860. import { Mesh } from "babylonjs/Meshes/mesh";
  25861. import { Scene, IDisposable } from "babylonjs/scene";
  25862. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25863. /**
  25864. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25865. *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.
  25866. * The SPS is also a particle system. It provides some methods to manage the particles.
  25867. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25868. *
  25869. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25870. */
  25871. export class SolidParticleSystem implements IDisposable {
  25872. /**
  25873. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25874. * Example : var p = SPS.particles[i];
  25875. */
  25876. particles: SolidParticle[];
  25877. /**
  25878. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25879. */
  25880. nbParticles: number;
  25881. /**
  25882. * If the particles must ever face the camera (default false). Useful for planar particles.
  25883. */
  25884. billboard: boolean;
  25885. /**
  25886. * Recompute normals when adding a shape
  25887. */
  25888. recomputeNormals: boolean;
  25889. /**
  25890. * This a counter ofr your own usage. It's not set by any SPS functions.
  25891. */
  25892. counter: number;
  25893. /**
  25894. * The SPS name. This name is also given to the underlying mesh.
  25895. */
  25896. name: string;
  25897. /**
  25898. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25899. */
  25900. mesh: Mesh;
  25901. /**
  25902. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25903. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25904. */
  25905. vars: any;
  25906. /**
  25907. * This array is populated when the SPS is set as 'pickable'.
  25908. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25909. * Each element of this array is an object `{idx: int, faceId: int}`.
  25910. * `idx` is the picked particle index in the `SPS.particles` array
  25911. * `faceId` is the picked face index counted within this particle.
  25912. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25913. */
  25914. pickedParticles: {
  25915. idx: number;
  25916. faceId: number;
  25917. }[];
  25918. /**
  25919. * This array is populated when `enableDepthSort` is set to true.
  25920. * Each element of this array is an instance of the class DepthSortedParticle.
  25921. */
  25922. depthSortedParticles: DepthSortedParticle[];
  25923. /**
  25924. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25925. * @hidden
  25926. */
  25927. _bSphereOnly: boolean;
  25928. /**
  25929. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25930. * @hidden
  25931. */
  25932. _bSphereRadiusFactor: number;
  25933. private _scene;
  25934. private _positions;
  25935. private _indices;
  25936. private _normals;
  25937. private _colors;
  25938. private _uvs;
  25939. private _indices32;
  25940. private _positions32;
  25941. private _normals32;
  25942. private _fixedNormal32;
  25943. private _colors32;
  25944. private _uvs32;
  25945. private _index;
  25946. private _updatable;
  25947. private _pickable;
  25948. private _isVisibilityBoxLocked;
  25949. private _alwaysVisible;
  25950. private _depthSort;
  25951. private _expandable;
  25952. private _shapeCounter;
  25953. private _copy;
  25954. private _color;
  25955. private _computeParticleColor;
  25956. private _computeParticleTexture;
  25957. private _computeParticleRotation;
  25958. private _computeParticleVertex;
  25959. private _computeBoundingBox;
  25960. private _depthSortParticles;
  25961. private _camera;
  25962. private _mustUnrotateFixedNormals;
  25963. private _particlesIntersect;
  25964. private _needs32Bits;
  25965. /**
  25966. * Creates a SPS (Solid Particle System) object.
  25967. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25968. * @param scene (Scene) is the scene in which the SPS is added.
  25969. * @param options defines the options of the sps e.g.
  25970. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25971. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25972. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25973. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25974. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25975. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25976. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25977. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25978. */
  25979. constructor(name: string, scene: Scene, options?: {
  25980. updatable?: boolean;
  25981. isPickable?: boolean;
  25982. enableDepthSort?: boolean;
  25983. particleIntersection?: boolean;
  25984. boundingSphereOnly?: boolean;
  25985. bSphereRadiusFactor?: number;
  25986. expandable?: boolean;
  25987. });
  25988. /**
  25989. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25990. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25991. * @returns the created mesh
  25992. */
  25993. buildMesh(): Mesh;
  25994. /**
  25995. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25996. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25997. * Thus the particles generated from `digest()` have their property `position` set yet.
  25998. * @param mesh ( Mesh ) is the mesh to be digested
  25999. * @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
  26000. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26001. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26002. * @returns the current SPS
  26003. */
  26004. digest(mesh: Mesh, options?: {
  26005. facetNb?: number;
  26006. number?: number;
  26007. delta?: number;
  26008. }): SolidParticleSystem;
  26009. private _unrotateFixedNormals;
  26010. private _resetCopy;
  26011. private _meshBuilder;
  26012. private _posToShape;
  26013. private _uvsToShapeUV;
  26014. private _addParticle;
  26015. /**
  26016. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26017. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26018. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26019. * @param nb (positive integer) the number of particles to be created from this model
  26020. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26021. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26022. * @returns the number of shapes in the system
  26023. */
  26024. addShape(mesh: Mesh, nb: number, options?: {
  26025. positionFunction?: any;
  26026. vertexFunction?: any;
  26027. }): number;
  26028. private _rebuildParticle;
  26029. /**
  26030. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26031. * @returns the SPS.
  26032. */
  26033. rebuildMesh(): SolidParticleSystem;
  26034. /**
  26035. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26036. * This method calls `updateParticle()` for each particle of the SPS.
  26037. * For an animated SPS, it is usually called within the render loop.
  26038. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26039. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26040. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26041. * @returns the SPS.
  26042. */
  26043. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26044. /**
  26045. * Disposes the SPS.
  26046. */
  26047. dispose(): void;
  26048. /**
  26049. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26050. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26051. * @returns the SPS.
  26052. */
  26053. refreshVisibleSize(): SolidParticleSystem;
  26054. /**
  26055. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26056. * @param size the size (float) of the visibility box
  26057. * note : this doesn't lock the SPS mesh bounding box.
  26058. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26059. */
  26060. setVisibilityBox(size: number): void;
  26061. /**
  26062. * Gets whether the SPS as always visible or not
  26063. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26064. */
  26065. /**
  26066. * Sets the SPS as always visible or not
  26067. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26068. */
  26069. isAlwaysVisible: boolean;
  26070. /**
  26071. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26072. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26073. */
  26074. /**
  26075. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26076. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26077. */
  26078. isVisibilityBoxLocked: boolean;
  26079. /**
  26080. * Tells to `setParticles()` to compute the particle rotations or not.
  26081. * Default value : true. The SPS is faster when it's set to false.
  26082. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26083. */
  26084. /**
  26085. * Gets if `setParticles()` computes the particle rotations or not.
  26086. * Default value : true. The SPS is faster when it's set to false.
  26087. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26088. */
  26089. computeParticleRotation: boolean;
  26090. /**
  26091. * Tells to `setParticles()` to compute the particle colors or not.
  26092. * Default value : true. The SPS is faster when it's set to false.
  26093. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26094. */
  26095. /**
  26096. * Gets if `setParticles()` computes the particle colors or not.
  26097. * Default value : true. The SPS is faster when it's set to false.
  26098. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26099. */
  26100. computeParticleColor: boolean;
  26101. /**
  26102. * Gets if `setParticles()` computes the particle textures or not.
  26103. * Default value : true. The SPS is faster when it's set to false.
  26104. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26105. */
  26106. computeParticleTexture: boolean;
  26107. /**
  26108. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26109. * Default value : false. The SPS is faster when it's set to false.
  26110. * Note : the particle custom vertex positions aren't stored values.
  26111. */
  26112. /**
  26113. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26114. * Default value : false. The SPS is faster when it's set to false.
  26115. * Note : the particle custom vertex positions aren't stored values.
  26116. */
  26117. computeParticleVertex: boolean;
  26118. /**
  26119. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26120. */
  26121. /**
  26122. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26123. */
  26124. computeBoundingBox: boolean;
  26125. /**
  26126. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26127. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26128. * Default : `true`
  26129. */
  26130. /**
  26131. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26132. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26133. * Default : `true`
  26134. */
  26135. depthSortParticles: boolean;
  26136. /**
  26137. * Gets if the SPS is created as expandable at construction time.
  26138. * Default : `false`
  26139. */
  26140. readonly expandable: boolean;
  26141. /**
  26142. * This function does nothing. It may be overwritten to set all the particle first values.
  26143. * The SPS doesn't call this function, you may have to call it by your own.
  26144. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26145. */
  26146. initParticles(): void;
  26147. /**
  26148. * This function does nothing. It may be overwritten to recycle a particle.
  26149. * The SPS doesn't call this function, you may have to call it by your own.
  26150. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26151. * @param particle The particle to recycle
  26152. * @returns the recycled particle
  26153. */
  26154. recycleParticle(particle: SolidParticle): SolidParticle;
  26155. /**
  26156. * Updates a particle : this function should be overwritten by the user.
  26157. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26158. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26159. * @example : just set a particle position or velocity and recycle conditions
  26160. * @param particle The particle to update
  26161. * @returns the updated particle
  26162. */
  26163. updateParticle(particle: SolidParticle): SolidParticle;
  26164. /**
  26165. * Updates a vertex of a particle : it can be overwritten by the user.
  26166. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26167. * @param particle the current particle
  26168. * @param vertex the current index of the current particle
  26169. * @param pt the index of the current vertex in the particle shape
  26170. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26171. * @example : just set a vertex particle position
  26172. * @returns the updated vertex
  26173. */
  26174. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26175. /**
  26176. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26177. * This does nothing and may be overwritten by the user.
  26178. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26179. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26180. * @param update the boolean update value actually passed to setParticles()
  26181. */
  26182. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26183. /**
  26184. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26185. * This will be passed three parameters.
  26186. * This does nothing and may be overwritten by the user.
  26187. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26188. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26189. * @param update the boolean update value actually passed to setParticles()
  26190. */
  26191. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26192. }
  26193. }
  26194. declare module "babylonjs/Particles/solidParticle" {
  26195. import { Nullable } from "babylonjs/types";
  26196. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26197. import { Color4 } from "babylonjs/Maths/math.color";
  26198. import { Mesh } from "babylonjs/Meshes/mesh";
  26199. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26200. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26201. import { Plane } from "babylonjs/Maths/math.plane";
  26202. /**
  26203. * Represents one particle of a solid particle system.
  26204. */
  26205. export class SolidParticle {
  26206. /**
  26207. * particle global index
  26208. */
  26209. idx: number;
  26210. /**
  26211. * The color of the particle
  26212. */
  26213. color: Nullable<Color4>;
  26214. /**
  26215. * The world space position of the particle.
  26216. */
  26217. position: Vector3;
  26218. /**
  26219. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26220. */
  26221. rotation: Vector3;
  26222. /**
  26223. * The world space rotation quaternion of the particle.
  26224. */
  26225. rotationQuaternion: Nullable<Quaternion>;
  26226. /**
  26227. * The scaling of the particle.
  26228. */
  26229. scaling: Vector3;
  26230. /**
  26231. * The uvs of the particle.
  26232. */
  26233. uvs: Vector4;
  26234. /**
  26235. * The current speed of the particle.
  26236. */
  26237. velocity: Vector3;
  26238. /**
  26239. * The pivot point in the particle local space.
  26240. */
  26241. pivot: Vector3;
  26242. /**
  26243. * Must the particle be translated from its pivot point in its local space ?
  26244. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26245. * Default : false
  26246. */
  26247. translateFromPivot: boolean;
  26248. /**
  26249. * Is the particle active or not ?
  26250. */
  26251. alive: boolean;
  26252. /**
  26253. * Is the particle visible or not ?
  26254. */
  26255. isVisible: boolean;
  26256. /**
  26257. * Index of this particle in the global "positions" array (Internal use)
  26258. * @hidden
  26259. */
  26260. _pos: number;
  26261. /**
  26262. * @hidden Index of this particle in the global "indices" array (Internal use)
  26263. */
  26264. _ind: number;
  26265. /**
  26266. * @hidden ModelShape of this particle (Internal use)
  26267. */
  26268. _model: ModelShape;
  26269. /**
  26270. * ModelShape id of this particle
  26271. */
  26272. shapeId: number;
  26273. /**
  26274. * Index of the particle in its shape id
  26275. */
  26276. idxInShape: number;
  26277. /**
  26278. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26279. */
  26280. _modelBoundingInfo: BoundingInfo;
  26281. /**
  26282. * @hidden Particle BoundingInfo object (Internal use)
  26283. */
  26284. _boundingInfo: BoundingInfo;
  26285. /**
  26286. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26287. */
  26288. _sps: SolidParticleSystem;
  26289. /**
  26290. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26291. */
  26292. _stillInvisible: boolean;
  26293. /**
  26294. * @hidden Last computed particle rotation matrix
  26295. */
  26296. _rotationMatrix: number[];
  26297. /**
  26298. * Parent particle Id, if any.
  26299. * Default null.
  26300. */
  26301. parentId: Nullable<number>;
  26302. /**
  26303. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26304. * The possible values are :
  26305. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26306. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26307. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26308. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26309. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26310. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26311. * */
  26312. cullingStrategy: number;
  26313. /**
  26314. * @hidden Internal global position in the SPS.
  26315. */
  26316. _globalPosition: Vector3;
  26317. /**
  26318. * Creates a Solid Particle object.
  26319. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26320. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26321. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26322. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26323. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26324. * @param shapeId (integer) is the model shape identifier in the SPS.
  26325. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26326. * @param sps defines the sps it is associated to
  26327. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26328. */
  26329. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26330. /**
  26331. * Legacy support, changed scale to scaling
  26332. */
  26333. /**
  26334. * Legacy support, changed scale to scaling
  26335. */
  26336. scale: Vector3;
  26337. /**
  26338. * Legacy support, changed quaternion to rotationQuaternion
  26339. */
  26340. /**
  26341. * Legacy support, changed quaternion to rotationQuaternion
  26342. */
  26343. quaternion: Nullable<Quaternion>;
  26344. /**
  26345. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26346. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26347. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26348. * @returns true if it intersects
  26349. */
  26350. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26351. /**
  26352. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26353. * A particle is in the frustum if its bounding box intersects the frustum
  26354. * @param frustumPlanes defines the frustum to test
  26355. * @returns true if the particle is in the frustum planes
  26356. */
  26357. isInFrustum(frustumPlanes: Plane[]): boolean;
  26358. /**
  26359. * get the rotation matrix of the particle
  26360. * @hidden
  26361. */
  26362. getRotationMatrix(m: Matrix): void;
  26363. }
  26364. /**
  26365. * Represents the shape of the model used by one particle of a solid particle system.
  26366. * SPS internal tool, don't use it manually.
  26367. */
  26368. export class ModelShape {
  26369. /**
  26370. * The shape id
  26371. * @hidden
  26372. */
  26373. shapeID: number;
  26374. /**
  26375. * flat array of model positions (internal use)
  26376. * @hidden
  26377. */
  26378. _shape: Vector3[];
  26379. /**
  26380. * flat array of model UVs (internal use)
  26381. * @hidden
  26382. */
  26383. _shapeUV: number[];
  26384. /**
  26385. * length of the shape in the model indices array (internal use)
  26386. * @hidden
  26387. */
  26388. _indicesLength: number;
  26389. /**
  26390. * Custom position function (internal use)
  26391. * @hidden
  26392. */
  26393. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26394. /**
  26395. * Custom vertex function (internal use)
  26396. * @hidden
  26397. */
  26398. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26399. /**
  26400. * 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.
  26401. * SPS internal tool, don't use it manually.
  26402. * @hidden
  26403. */
  26404. 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>);
  26405. }
  26406. /**
  26407. * Represents a Depth Sorted Particle in the solid particle system.
  26408. */
  26409. export class DepthSortedParticle {
  26410. /**
  26411. * Index of the particle in the "indices" array
  26412. */
  26413. ind: number;
  26414. /**
  26415. * Length of the particle shape in the "indices" array
  26416. */
  26417. indicesLength: number;
  26418. /**
  26419. * Squared distance from the particle to the camera
  26420. */
  26421. sqDistance: number;
  26422. }
  26423. }
  26424. declare module "babylonjs/Collisions/meshCollisionData" {
  26425. import { Collider } from "babylonjs/Collisions/collider";
  26426. import { Vector3 } from "babylonjs/Maths/math.vector";
  26427. import { Nullable } from "babylonjs/types";
  26428. import { Observer } from "babylonjs/Misc/observable";
  26429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26430. /**
  26431. * @hidden
  26432. */
  26433. export class _MeshCollisionData {
  26434. _checkCollisions: boolean;
  26435. _collisionMask: number;
  26436. _collisionGroup: number;
  26437. _collider: Nullable<Collider>;
  26438. _oldPositionForCollisions: Vector3;
  26439. _diffPositionForCollisions: Vector3;
  26440. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26441. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26442. }
  26443. }
  26444. declare module "babylonjs/Meshes/abstractMesh" {
  26445. import { Observable } from "babylonjs/Misc/observable";
  26446. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26447. import { Camera } from "babylonjs/Cameras/camera";
  26448. import { Scene, IDisposable } from "babylonjs/scene";
  26449. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26450. import { Node } from "babylonjs/node";
  26451. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26452. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26453. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26454. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26455. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26456. import { Material } from "babylonjs/Materials/material";
  26457. import { Light } from "babylonjs/Lights/light";
  26458. import { Skeleton } from "babylonjs/Bones/skeleton";
  26459. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26460. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26461. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26462. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26463. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26464. import { Plane } from "babylonjs/Maths/math.plane";
  26465. import { Ray } from "babylonjs/Culling/ray";
  26466. import { Collider } from "babylonjs/Collisions/collider";
  26467. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26468. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26469. /** @hidden */
  26470. class _FacetDataStorage {
  26471. facetPositions: Vector3[];
  26472. facetNormals: Vector3[];
  26473. facetPartitioning: number[][];
  26474. facetNb: number;
  26475. partitioningSubdivisions: number;
  26476. partitioningBBoxRatio: number;
  26477. facetDataEnabled: boolean;
  26478. facetParameters: any;
  26479. bbSize: Vector3;
  26480. subDiv: {
  26481. max: number;
  26482. X: number;
  26483. Y: number;
  26484. Z: number;
  26485. };
  26486. facetDepthSort: boolean;
  26487. facetDepthSortEnabled: boolean;
  26488. depthSortedIndices: IndicesArray;
  26489. depthSortedFacets: {
  26490. ind: number;
  26491. sqDistance: number;
  26492. }[];
  26493. facetDepthSortFunction: (f1: {
  26494. ind: number;
  26495. sqDistance: number;
  26496. }, f2: {
  26497. ind: number;
  26498. sqDistance: number;
  26499. }) => number;
  26500. facetDepthSortFrom: Vector3;
  26501. facetDepthSortOrigin: Vector3;
  26502. invertedMatrix: Matrix;
  26503. }
  26504. /**
  26505. * @hidden
  26506. **/
  26507. class _InternalAbstractMeshDataInfo {
  26508. _hasVertexAlpha: boolean;
  26509. _useVertexColors: boolean;
  26510. _numBoneInfluencers: number;
  26511. _applyFog: boolean;
  26512. _receiveShadows: boolean;
  26513. _facetData: _FacetDataStorage;
  26514. _visibility: number;
  26515. _skeleton: Nullable<Skeleton>;
  26516. _layerMask: number;
  26517. _computeBonesUsingShaders: boolean;
  26518. _isActive: boolean;
  26519. _onlyForInstances: boolean;
  26520. _isActiveIntermediate: boolean;
  26521. _onlyForInstancesIntermediate: boolean;
  26522. _actAsRegularMesh: boolean;
  26523. }
  26524. /**
  26525. * Class used to store all common mesh properties
  26526. */
  26527. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26528. /** No occlusion */
  26529. static OCCLUSION_TYPE_NONE: number;
  26530. /** Occlusion set to optimisitic */
  26531. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26532. /** Occlusion set to strict */
  26533. static OCCLUSION_TYPE_STRICT: number;
  26534. /** Use an accurante occlusion algorithm */
  26535. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26536. /** Use a conservative occlusion algorithm */
  26537. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26538. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26539. * Test order :
  26540. * Is the bounding sphere outside the frustum ?
  26541. * If not, are the bounding box vertices outside the frustum ?
  26542. * It not, then the cullable object is in the frustum.
  26543. */
  26544. static readonly CULLINGSTRATEGY_STANDARD: number;
  26545. /** Culling strategy : Bounding Sphere Only.
  26546. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26547. * It's also less accurate than the standard because some not visible objects can still be selected.
  26548. * Test : is the bounding sphere outside the frustum ?
  26549. * If not, then the cullable object is in the frustum.
  26550. */
  26551. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26552. /** Culling strategy : Optimistic Inclusion.
  26553. * This in an inclusion test first, then the standard exclusion test.
  26554. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26555. * 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.
  26556. * Anyway, it's as accurate as the standard strategy.
  26557. * Test :
  26558. * Is the cullable object bounding sphere center in the frustum ?
  26559. * If not, apply the default culling strategy.
  26560. */
  26561. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26562. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26563. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26564. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26565. * 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.
  26566. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26567. * Test :
  26568. * Is the cullable object bounding sphere center in the frustum ?
  26569. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26570. */
  26571. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26572. /**
  26573. * No billboard
  26574. */
  26575. static readonly BILLBOARDMODE_NONE: number;
  26576. /** Billboard on X axis */
  26577. static readonly BILLBOARDMODE_X: number;
  26578. /** Billboard on Y axis */
  26579. static readonly BILLBOARDMODE_Y: number;
  26580. /** Billboard on Z axis */
  26581. static readonly BILLBOARDMODE_Z: number;
  26582. /** Billboard on all axes */
  26583. static readonly BILLBOARDMODE_ALL: number;
  26584. /** Billboard on using position instead of orientation */
  26585. static readonly BILLBOARDMODE_USE_POSITION: number;
  26586. /** @hidden */
  26587. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26588. /**
  26589. * The culling strategy to use to check whether the mesh must be rendered or not.
  26590. * This value can be changed at any time and will be used on the next render mesh selection.
  26591. * The possible values are :
  26592. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26593. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26594. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26595. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26596. * Please read each static variable documentation to get details about the culling process.
  26597. * */
  26598. cullingStrategy: number;
  26599. /**
  26600. * Gets the number of facets in the mesh
  26601. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26602. */
  26603. readonly facetNb: number;
  26604. /**
  26605. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26606. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26607. */
  26608. partitioningSubdivisions: number;
  26609. /**
  26610. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26611. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26612. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26613. */
  26614. partitioningBBoxRatio: number;
  26615. /**
  26616. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26617. * Works only for updatable meshes.
  26618. * Doesn't work with multi-materials
  26619. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26620. */
  26621. mustDepthSortFacets: boolean;
  26622. /**
  26623. * The location (Vector3) where the facet depth sort must be computed from.
  26624. * By default, the active camera position.
  26625. * Used only when facet depth sort is enabled
  26626. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26627. */
  26628. facetDepthSortFrom: Vector3;
  26629. /**
  26630. * gets a boolean indicating if facetData is enabled
  26631. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26632. */
  26633. readonly isFacetDataEnabled: boolean;
  26634. /** @hidden */
  26635. _updateNonUniformScalingState(value: boolean): boolean;
  26636. /**
  26637. * An event triggered when this mesh collides with another one
  26638. */
  26639. onCollideObservable: Observable<AbstractMesh>;
  26640. /** Set a function to call when this mesh collides with another one */
  26641. onCollide: () => void;
  26642. /**
  26643. * An event triggered when the collision's position changes
  26644. */
  26645. onCollisionPositionChangeObservable: Observable<Vector3>;
  26646. /** Set a function to call when the collision's position changes */
  26647. onCollisionPositionChange: () => void;
  26648. /**
  26649. * An event triggered when material is changed
  26650. */
  26651. onMaterialChangedObservable: Observable<AbstractMesh>;
  26652. /**
  26653. * Gets or sets the orientation for POV movement & rotation
  26654. */
  26655. definedFacingForward: boolean;
  26656. /** @hidden */
  26657. _occlusionQuery: Nullable<WebGLQuery>;
  26658. /** @hidden */
  26659. _renderingGroup: Nullable<RenderingGroup>;
  26660. /**
  26661. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26662. */
  26663. /**
  26664. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26665. */
  26666. visibility: number;
  26667. /** Gets or sets the alpha index used to sort transparent meshes
  26668. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26669. */
  26670. alphaIndex: number;
  26671. /**
  26672. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26673. */
  26674. isVisible: boolean;
  26675. /**
  26676. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26677. */
  26678. isPickable: boolean;
  26679. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26680. showSubMeshesBoundingBox: boolean;
  26681. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26682. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26683. */
  26684. isBlocker: boolean;
  26685. /**
  26686. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26687. */
  26688. enablePointerMoveEvents: boolean;
  26689. /**
  26690. * Specifies the rendering group id for this mesh (0 by default)
  26691. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26692. */
  26693. renderingGroupId: number;
  26694. private _material;
  26695. /** Gets or sets current material */
  26696. material: Nullable<Material>;
  26697. /**
  26698. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26699. * @see http://doc.babylonjs.com/babylon101/shadows
  26700. */
  26701. receiveShadows: boolean;
  26702. /** Defines color to use when rendering outline */
  26703. outlineColor: Color3;
  26704. /** Define width to use when rendering outline */
  26705. outlineWidth: number;
  26706. /** Defines color to use when rendering overlay */
  26707. overlayColor: Color3;
  26708. /** Defines alpha to use when rendering overlay */
  26709. overlayAlpha: number;
  26710. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26711. hasVertexAlpha: boolean;
  26712. /** 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) */
  26713. useVertexColors: boolean;
  26714. /**
  26715. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26716. */
  26717. computeBonesUsingShaders: boolean;
  26718. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26719. numBoneInfluencers: number;
  26720. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26721. applyFog: boolean;
  26722. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26723. useOctreeForRenderingSelection: boolean;
  26724. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26725. useOctreeForPicking: boolean;
  26726. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26727. useOctreeForCollisions: boolean;
  26728. /**
  26729. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26730. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26731. */
  26732. layerMask: number;
  26733. /**
  26734. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26735. */
  26736. alwaysSelectAsActiveMesh: boolean;
  26737. /**
  26738. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26739. */
  26740. doNotSyncBoundingInfo: boolean;
  26741. /**
  26742. * Gets or sets the current action manager
  26743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26744. */
  26745. actionManager: Nullable<AbstractActionManager>;
  26746. private _meshCollisionData;
  26747. /**
  26748. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26749. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26750. */
  26751. ellipsoid: Vector3;
  26752. /**
  26753. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26754. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26755. */
  26756. ellipsoidOffset: Vector3;
  26757. /**
  26758. * Gets or sets a collision mask used to mask collisions (default is -1).
  26759. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26760. */
  26761. collisionMask: number;
  26762. /**
  26763. * Gets or sets the current collision group mask (-1 by default).
  26764. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26765. */
  26766. collisionGroup: number;
  26767. /**
  26768. * Defines edge width used when edgesRenderer is enabled
  26769. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26770. */
  26771. edgesWidth: number;
  26772. /**
  26773. * Defines edge color used when edgesRenderer is enabled
  26774. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26775. */
  26776. edgesColor: Color4;
  26777. /** @hidden */
  26778. _edgesRenderer: Nullable<IEdgesRenderer>;
  26779. /** @hidden */
  26780. _masterMesh: Nullable<AbstractMesh>;
  26781. /** @hidden */
  26782. _boundingInfo: Nullable<BoundingInfo>;
  26783. /** @hidden */
  26784. _renderId: number;
  26785. /**
  26786. * Gets or sets the list of subMeshes
  26787. * @see http://doc.babylonjs.com/how_to/multi_materials
  26788. */
  26789. subMeshes: SubMesh[];
  26790. /** @hidden */
  26791. _intersectionsInProgress: AbstractMesh[];
  26792. /** @hidden */
  26793. _unIndexed: boolean;
  26794. /** @hidden */
  26795. _lightSources: Light[];
  26796. /** Gets the list of lights affecting that mesh */
  26797. readonly lightSources: Light[];
  26798. /** @hidden */
  26799. readonly _positions: Nullable<Vector3[]>;
  26800. /** @hidden */
  26801. _waitingData: {
  26802. lods: Nullable<any>;
  26803. actions: Nullable<any>;
  26804. freezeWorldMatrix: Nullable<boolean>;
  26805. };
  26806. /** @hidden */
  26807. _bonesTransformMatrices: Nullable<Float32Array>;
  26808. /** @hidden */
  26809. _transformMatrixTexture: Nullable<RawTexture>;
  26810. /**
  26811. * Gets or sets a skeleton to apply skining transformations
  26812. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26813. */
  26814. skeleton: Nullable<Skeleton>;
  26815. /**
  26816. * An event triggered when the mesh is rebuilt.
  26817. */
  26818. onRebuildObservable: Observable<AbstractMesh>;
  26819. /**
  26820. * Creates a new AbstractMesh
  26821. * @param name defines the name of the mesh
  26822. * @param scene defines the hosting scene
  26823. */
  26824. constructor(name: string, scene?: Nullable<Scene>);
  26825. /**
  26826. * Returns the string "AbstractMesh"
  26827. * @returns "AbstractMesh"
  26828. */
  26829. getClassName(): string;
  26830. /**
  26831. * Gets a string representation of the current mesh
  26832. * @param fullDetails defines a boolean indicating if full details must be included
  26833. * @returns a string representation of the current mesh
  26834. */
  26835. toString(fullDetails?: boolean): string;
  26836. /**
  26837. * @hidden
  26838. */
  26839. protected _getEffectiveParent(): Nullable<Node>;
  26840. /** @hidden */
  26841. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26842. /** @hidden */
  26843. _rebuild(): void;
  26844. /** @hidden */
  26845. _resyncLightSources(): void;
  26846. /** @hidden */
  26847. _resyncLighSource(light: Light): void;
  26848. /** @hidden */
  26849. _unBindEffect(): void;
  26850. /** @hidden */
  26851. _removeLightSource(light: Light, dispose: boolean): void;
  26852. private _markSubMeshesAsDirty;
  26853. /** @hidden */
  26854. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26855. /** @hidden */
  26856. _markSubMeshesAsAttributesDirty(): void;
  26857. /** @hidden */
  26858. _markSubMeshesAsMiscDirty(): void;
  26859. /**
  26860. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26861. */
  26862. scaling: Vector3;
  26863. /**
  26864. * Returns true if the mesh is blocked. Implemented by child classes
  26865. */
  26866. readonly isBlocked: boolean;
  26867. /**
  26868. * Returns the mesh itself by default. Implemented by child classes
  26869. * @param camera defines the camera to use to pick the right LOD level
  26870. * @returns the currentAbstractMesh
  26871. */
  26872. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26873. /**
  26874. * Returns 0 by default. Implemented by child classes
  26875. * @returns an integer
  26876. */
  26877. getTotalVertices(): number;
  26878. /**
  26879. * Returns a positive integer : the total number of indices in this mesh geometry.
  26880. * @returns the numner of indices or zero if the mesh has no geometry.
  26881. */
  26882. getTotalIndices(): number;
  26883. /**
  26884. * Returns null by default. Implemented by child classes
  26885. * @returns null
  26886. */
  26887. getIndices(): Nullable<IndicesArray>;
  26888. /**
  26889. * Returns the array of the requested vertex data kind. Implemented by child classes
  26890. * @param kind defines the vertex data kind to use
  26891. * @returns null
  26892. */
  26893. getVerticesData(kind: string): Nullable<FloatArray>;
  26894. /**
  26895. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26896. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26897. * Note that a new underlying VertexBuffer object is created each call.
  26898. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26899. * @param kind defines vertex data kind:
  26900. * * VertexBuffer.PositionKind
  26901. * * VertexBuffer.UVKind
  26902. * * VertexBuffer.UV2Kind
  26903. * * VertexBuffer.UV3Kind
  26904. * * VertexBuffer.UV4Kind
  26905. * * VertexBuffer.UV5Kind
  26906. * * VertexBuffer.UV6Kind
  26907. * * VertexBuffer.ColorKind
  26908. * * VertexBuffer.MatricesIndicesKind
  26909. * * VertexBuffer.MatricesIndicesExtraKind
  26910. * * VertexBuffer.MatricesWeightsKind
  26911. * * VertexBuffer.MatricesWeightsExtraKind
  26912. * @param data defines the data source
  26913. * @param updatable defines if the data must be flagged as updatable (or static)
  26914. * @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
  26915. * @returns the current mesh
  26916. */
  26917. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26918. /**
  26919. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26920. * If the mesh has no geometry, it is simply returned as it is.
  26921. * @param kind defines vertex data kind:
  26922. * * VertexBuffer.PositionKind
  26923. * * VertexBuffer.UVKind
  26924. * * VertexBuffer.UV2Kind
  26925. * * VertexBuffer.UV3Kind
  26926. * * VertexBuffer.UV4Kind
  26927. * * VertexBuffer.UV5Kind
  26928. * * VertexBuffer.UV6Kind
  26929. * * VertexBuffer.ColorKind
  26930. * * VertexBuffer.MatricesIndicesKind
  26931. * * VertexBuffer.MatricesIndicesExtraKind
  26932. * * VertexBuffer.MatricesWeightsKind
  26933. * * VertexBuffer.MatricesWeightsExtraKind
  26934. * @param data defines the data source
  26935. * @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
  26936. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26937. * @returns the current mesh
  26938. */
  26939. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26940. /**
  26941. * Sets the mesh indices,
  26942. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26943. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26944. * @param totalVertices Defines the total number of vertices
  26945. * @returns the current mesh
  26946. */
  26947. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26948. /**
  26949. * Gets a boolean indicating if specific vertex data is present
  26950. * @param kind defines the vertex data kind to use
  26951. * @returns true is data kind is present
  26952. */
  26953. isVerticesDataPresent(kind: string): boolean;
  26954. /**
  26955. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26956. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26957. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26958. * @returns a BoundingInfo
  26959. */
  26960. getBoundingInfo(): BoundingInfo;
  26961. /**
  26962. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26963. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26964. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26965. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26966. * @returns the current mesh
  26967. */
  26968. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26969. /**
  26970. * Overwrite the current bounding info
  26971. * @param boundingInfo defines the new bounding info
  26972. * @returns the current mesh
  26973. */
  26974. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26975. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26976. readonly useBones: boolean;
  26977. /** @hidden */
  26978. _preActivate(): void;
  26979. /** @hidden */
  26980. _preActivateForIntermediateRendering(renderId: number): void;
  26981. /** @hidden */
  26982. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26983. /** @hidden */
  26984. _postActivate(): void;
  26985. /** @hidden */
  26986. _freeze(): void;
  26987. /** @hidden */
  26988. _unFreeze(): void;
  26989. /**
  26990. * Gets the current world matrix
  26991. * @returns a Matrix
  26992. */
  26993. getWorldMatrix(): Matrix;
  26994. /** @hidden */
  26995. _getWorldMatrixDeterminant(): number;
  26996. /**
  26997. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26998. */
  26999. readonly isAnInstance: boolean;
  27000. /**
  27001. * Gets a boolean indicating if this mesh has instances
  27002. */
  27003. readonly hasInstances: boolean;
  27004. /**
  27005. * Perform relative position change from the point of view of behind the front of the mesh.
  27006. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27007. * Supports definition of mesh facing forward or backward
  27008. * @param amountRight defines the distance on the right axis
  27009. * @param amountUp defines the distance on the up axis
  27010. * @param amountForward defines the distance on the forward axis
  27011. * @returns the current mesh
  27012. */
  27013. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27014. /**
  27015. * Calculate relative position change from the point of view of behind the front of the mesh.
  27016. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27017. * Supports definition of mesh facing forward or backward
  27018. * @param amountRight defines the distance on the right axis
  27019. * @param amountUp defines the distance on the up axis
  27020. * @param amountForward defines the distance on the forward axis
  27021. * @returns the new displacement vector
  27022. */
  27023. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27024. /**
  27025. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27026. * Supports definition of mesh facing forward or backward
  27027. * @param flipBack defines the flip
  27028. * @param twirlClockwise defines the twirl
  27029. * @param tiltRight defines the tilt
  27030. * @returns the current mesh
  27031. */
  27032. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27033. /**
  27034. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27035. * Supports definition of mesh facing forward or backward.
  27036. * @param flipBack defines the flip
  27037. * @param twirlClockwise defines the twirl
  27038. * @param tiltRight defines the tilt
  27039. * @returns the new rotation vector
  27040. */
  27041. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27042. /**
  27043. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27044. * This means the mesh underlying bounding box and sphere are recomputed.
  27045. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27046. * @returns the current mesh
  27047. */
  27048. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27049. /** @hidden */
  27050. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27051. /** @hidden */
  27052. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27053. /** @hidden */
  27054. _updateBoundingInfo(): AbstractMesh;
  27055. /** @hidden */
  27056. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27057. /** @hidden */
  27058. protected _afterComputeWorldMatrix(): void;
  27059. /** @hidden */
  27060. readonly _effectiveMesh: AbstractMesh;
  27061. /**
  27062. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27063. * A mesh is in the frustum if its bounding box intersects the frustum
  27064. * @param frustumPlanes defines the frustum to test
  27065. * @returns true if the mesh is in the frustum planes
  27066. */
  27067. isInFrustum(frustumPlanes: Plane[]): boolean;
  27068. /**
  27069. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27070. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27071. * @param frustumPlanes defines the frustum to test
  27072. * @returns true if the mesh is completely in the frustum planes
  27073. */
  27074. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27075. /**
  27076. * True if the mesh intersects another mesh or a SolidParticle object
  27077. * @param mesh defines a target mesh or SolidParticle to test
  27078. * @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)
  27079. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27080. * @returns true if there is an intersection
  27081. */
  27082. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27083. /**
  27084. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27085. * @param point defines the point to test
  27086. * @returns true if there is an intersection
  27087. */
  27088. intersectsPoint(point: Vector3): boolean;
  27089. /**
  27090. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27091. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27092. */
  27093. checkCollisions: boolean;
  27094. /**
  27095. * Gets Collider object used to compute collisions (not physics)
  27096. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27097. */
  27098. readonly collider: Nullable<Collider>;
  27099. /**
  27100. * Move the mesh using collision engine
  27101. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27102. * @param displacement defines the requested displacement vector
  27103. * @returns the current mesh
  27104. */
  27105. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27106. private _onCollisionPositionChange;
  27107. /** @hidden */
  27108. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27109. /** @hidden */
  27110. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27111. /** @hidden */
  27112. _checkCollision(collider: Collider): AbstractMesh;
  27113. /** @hidden */
  27114. _generatePointsArray(): boolean;
  27115. /**
  27116. * Checks if the passed Ray intersects with the mesh
  27117. * @param ray defines the ray to use
  27118. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27119. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27120. * @returns the picking info
  27121. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27122. */
  27123. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27124. /**
  27125. * Clones the current mesh
  27126. * @param name defines the mesh name
  27127. * @param newParent defines the new mesh parent
  27128. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27129. * @returns the new mesh
  27130. */
  27131. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27132. /**
  27133. * Disposes all the submeshes of the current meshnp
  27134. * @returns the current mesh
  27135. */
  27136. releaseSubMeshes(): AbstractMesh;
  27137. /**
  27138. * Releases resources associated with this abstract mesh.
  27139. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27140. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27141. */
  27142. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27143. /**
  27144. * Adds the passed mesh as a child to the current mesh
  27145. * @param mesh defines the child mesh
  27146. * @returns the current mesh
  27147. */
  27148. addChild(mesh: AbstractMesh): AbstractMesh;
  27149. /**
  27150. * Removes the passed mesh from the current mesh children list
  27151. * @param mesh defines the child mesh
  27152. * @returns the current mesh
  27153. */
  27154. removeChild(mesh: AbstractMesh): AbstractMesh;
  27155. /** @hidden */
  27156. private _initFacetData;
  27157. /**
  27158. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27159. * This method can be called within the render loop.
  27160. * 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
  27161. * @returns the current mesh
  27162. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27163. */
  27164. updateFacetData(): AbstractMesh;
  27165. /**
  27166. * Returns the facetLocalNormals array.
  27167. * The normals are expressed in the mesh local spac
  27168. * @returns an array of Vector3
  27169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27170. */
  27171. getFacetLocalNormals(): Vector3[];
  27172. /**
  27173. * Returns the facetLocalPositions array.
  27174. * The facet positions are expressed in the mesh local space
  27175. * @returns an array of Vector3
  27176. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27177. */
  27178. getFacetLocalPositions(): Vector3[];
  27179. /**
  27180. * Returns the facetLocalPartioning array
  27181. * @returns an array of array of numbers
  27182. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27183. */
  27184. getFacetLocalPartitioning(): number[][];
  27185. /**
  27186. * Returns the i-th facet position in the world system.
  27187. * This method allocates a new Vector3 per call
  27188. * @param i defines the facet index
  27189. * @returns a new Vector3
  27190. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27191. */
  27192. getFacetPosition(i: number): Vector3;
  27193. /**
  27194. * Sets the reference Vector3 with the i-th facet position in the world system
  27195. * @param i defines the facet index
  27196. * @param ref defines the target vector
  27197. * @returns the current mesh
  27198. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27199. */
  27200. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27201. /**
  27202. * Returns the i-th facet normal in the world system.
  27203. * This method allocates a new Vector3 per call
  27204. * @param i defines the facet index
  27205. * @returns a new Vector3
  27206. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27207. */
  27208. getFacetNormal(i: number): Vector3;
  27209. /**
  27210. * Sets the reference Vector3 with the i-th facet normal in the world system
  27211. * @param i defines the facet index
  27212. * @param ref defines the target vector
  27213. * @returns the current mesh
  27214. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27215. */
  27216. getFacetNormalToRef(i: number, ref: Vector3): this;
  27217. /**
  27218. * 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)
  27219. * @param x defines x coordinate
  27220. * @param y defines y coordinate
  27221. * @param z defines z coordinate
  27222. * @returns the array of facet indexes
  27223. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27224. */
  27225. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27226. /**
  27227. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27228. * @param projected sets as the (x,y,z) world projection on the facet
  27229. * @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
  27230. * @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
  27231. * @param x defines x coordinate
  27232. * @param y defines y coordinate
  27233. * @param z defines z coordinate
  27234. * @returns the face index if found (or null instead)
  27235. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27236. */
  27237. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27238. /**
  27239. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27240. * @param projected sets as the (x,y,z) local projection on the facet
  27241. * @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
  27242. * @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
  27243. * @param x defines x coordinate
  27244. * @param y defines y coordinate
  27245. * @param z defines z coordinate
  27246. * @returns the face index if found (or null instead)
  27247. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27248. */
  27249. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27250. /**
  27251. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27252. * @returns the parameters
  27253. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27254. */
  27255. getFacetDataParameters(): any;
  27256. /**
  27257. * Disables the feature FacetData and frees the related memory
  27258. * @returns the current mesh
  27259. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27260. */
  27261. disableFacetData(): AbstractMesh;
  27262. /**
  27263. * Updates the AbstractMesh indices array
  27264. * @param indices defines the data source
  27265. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27266. * @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)
  27267. * @returns the current mesh
  27268. */
  27269. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27270. /**
  27271. * Creates new normals data for the mesh
  27272. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27273. * @returns the current mesh
  27274. */
  27275. createNormals(updatable: boolean): AbstractMesh;
  27276. /**
  27277. * Align the mesh with a normal
  27278. * @param normal defines the normal to use
  27279. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27280. * @returns the current mesh
  27281. */
  27282. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27283. /** @hidden */
  27284. _checkOcclusionQuery(): boolean;
  27285. /**
  27286. * Disables the mesh edge rendering mode
  27287. * @returns the currentAbstractMesh
  27288. */
  27289. disableEdgesRendering(): AbstractMesh;
  27290. /**
  27291. * Enables the edge rendering mode on the mesh.
  27292. * This mode makes the mesh edges visible
  27293. * @param epsilon defines the maximal distance between two angles to detect a face
  27294. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27295. * @returns the currentAbstractMesh
  27296. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27297. */
  27298. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27299. }
  27300. }
  27301. declare module "babylonjs/Actions/actionEvent" {
  27302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27303. import { Nullable } from "babylonjs/types";
  27304. import { Sprite } from "babylonjs/Sprites/sprite";
  27305. import { Scene } from "babylonjs/scene";
  27306. import { Vector2 } from "babylonjs/Maths/math.vector";
  27307. /**
  27308. * Interface used to define ActionEvent
  27309. */
  27310. export interface IActionEvent {
  27311. /** The mesh or sprite that triggered the action */
  27312. source: any;
  27313. /** The X mouse cursor position at the time of the event */
  27314. pointerX: number;
  27315. /** The Y mouse cursor position at the time of the event */
  27316. pointerY: number;
  27317. /** The mesh that is currently pointed at (can be null) */
  27318. meshUnderPointer: Nullable<AbstractMesh>;
  27319. /** the original (browser) event that triggered the ActionEvent */
  27320. sourceEvent?: any;
  27321. /** additional data for the event */
  27322. additionalData?: any;
  27323. }
  27324. /**
  27325. * ActionEvent is the event being sent when an action is triggered.
  27326. */
  27327. export class ActionEvent implements IActionEvent {
  27328. /** The mesh or sprite that triggered the action */
  27329. source: any;
  27330. /** The X mouse cursor position at the time of the event */
  27331. pointerX: number;
  27332. /** The Y mouse cursor position at the time of the event */
  27333. pointerY: number;
  27334. /** The mesh that is currently pointed at (can be null) */
  27335. meshUnderPointer: Nullable<AbstractMesh>;
  27336. /** the original (browser) event that triggered the ActionEvent */
  27337. sourceEvent?: any;
  27338. /** additional data for the event */
  27339. additionalData?: any;
  27340. /**
  27341. * Creates a new ActionEvent
  27342. * @param source The mesh or sprite that triggered the action
  27343. * @param pointerX The X mouse cursor position at the time of the event
  27344. * @param pointerY The Y mouse cursor position at the time of the event
  27345. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27346. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27347. * @param additionalData additional data for the event
  27348. */
  27349. constructor(
  27350. /** The mesh or sprite that triggered the action */
  27351. source: any,
  27352. /** The X mouse cursor position at the time of the event */
  27353. pointerX: number,
  27354. /** The Y mouse cursor position at the time of the event */
  27355. pointerY: number,
  27356. /** The mesh that is currently pointed at (can be null) */
  27357. meshUnderPointer: Nullable<AbstractMesh>,
  27358. /** the original (browser) event that triggered the ActionEvent */
  27359. sourceEvent?: any,
  27360. /** additional data for the event */
  27361. additionalData?: any);
  27362. /**
  27363. * Helper function to auto-create an ActionEvent from a source mesh.
  27364. * @param source The source mesh that triggered the event
  27365. * @param evt The original (browser) event
  27366. * @param additionalData additional data for the event
  27367. * @returns the new ActionEvent
  27368. */
  27369. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27370. /**
  27371. * Helper function to auto-create an ActionEvent from a source sprite
  27372. * @param source The source sprite that triggered the event
  27373. * @param scene Scene associated with the sprite
  27374. * @param evt The original (browser) event
  27375. * @param additionalData additional data for the event
  27376. * @returns the new ActionEvent
  27377. */
  27378. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27379. /**
  27380. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27381. * @param scene the scene where the event occurred
  27382. * @param evt The original (browser) event
  27383. * @returns the new ActionEvent
  27384. */
  27385. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27386. /**
  27387. * Helper function to auto-create an ActionEvent from a primitive
  27388. * @param prim defines the target primitive
  27389. * @param pointerPos defines the pointer position
  27390. * @param evt The original (browser) event
  27391. * @param additionalData additional data for the event
  27392. * @returns the new ActionEvent
  27393. */
  27394. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27395. }
  27396. }
  27397. declare module "babylonjs/Actions/abstractActionManager" {
  27398. import { IDisposable } from "babylonjs/scene";
  27399. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27400. import { IAction } from "babylonjs/Actions/action";
  27401. import { Nullable } from "babylonjs/types";
  27402. /**
  27403. * Abstract class used to decouple action Manager from scene and meshes.
  27404. * Do not instantiate.
  27405. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27406. */
  27407. export abstract class AbstractActionManager implements IDisposable {
  27408. /** Gets the list of active triggers */
  27409. static Triggers: {
  27410. [key: string]: number;
  27411. };
  27412. /** Gets the cursor to use when hovering items */
  27413. hoverCursor: string;
  27414. /** Gets the list of actions */
  27415. actions: IAction[];
  27416. /**
  27417. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27418. */
  27419. isRecursive: boolean;
  27420. /**
  27421. * Releases all associated resources
  27422. */
  27423. abstract dispose(): void;
  27424. /**
  27425. * Does this action manager has pointer triggers
  27426. */
  27427. abstract readonly hasPointerTriggers: boolean;
  27428. /**
  27429. * Does this action manager has pick triggers
  27430. */
  27431. abstract readonly hasPickTriggers: boolean;
  27432. /**
  27433. * Process a specific trigger
  27434. * @param trigger defines the trigger to process
  27435. * @param evt defines the event details to be processed
  27436. */
  27437. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27438. /**
  27439. * Does this action manager handles actions of any of the given triggers
  27440. * @param triggers defines the triggers to be tested
  27441. * @return a boolean indicating whether one (or more) of the triggers is handled
  27442. */
  27443. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27444. /**
  27445. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27446. * speed.
  27447. * @param triggerA defines the trigger to be tested
  27448. * @param triggerB defines the trigger to be tested
  27449. * @return a boolean indicating whether one (or more) of the triggers is handled
  27450. */
  27451. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27452. /**
  27453. * Does this action manager handles actions of a given trigger
  27454. * @param trigger defines the trigger to be tested
  27455. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27456. * @return whether the trigger is handled
  27457. */
  27458. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27459. /**
  27460. * Serialize this manager to a JSON object
  27461. * @param name defines the property name to store this manager
  27462. * @returns a JSON representation of this manager
  27463. */
  27464. abstract serialize(name: string): any;
  27465. /**
  27466. * Registers an action to this action manager
  27467. * @param action defines the action to be registered
  27468. * @return the action amended (prepared) after registration
  27469. */
  27470. abstract registerAction(action: IAction): Nullable<IAction>;
  27471. /**
  27472. * Unregisters an action to this action manager
  27473. * @param action defines the action to be unregistered
  27474. * @return a boolean indicating whether the action has been unregistered
  27475. */
  27476. abstract unregisterAction(action: IAction): Boolean;
  27477. /**
  27478. * Does exist one action manager with at least one trigger
  27479. **/
  27480. static readonly HasTriggers: boolean;
  27481. /**
  27482. * Does exist one action manager with at least one pick trigger
  27483. **/
  27484. static readonly HasPickTriggers: boolean;
  27485. /**
  27486. * Does exist one action manager that handles actions of a given trigger
  27487. * @param trigger defines the trigger to be tested
  27488. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27489. **/
  27490. static HasSpecificTrigger(trigger: number): boolean;
  27491. }
  27492. }
  27493. declare module "babylonjs/node" {
  27494. import { Scene } from "babylonjs/scene";
  27495. import { Nullable } from "babylonjs/types";
  27496. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27497. import { Engine } from "babylonjs/Engines/engine";
  27498. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27499. import { Observable } from "babylonjs/Misc/observable";
  27500. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27501. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27502. import { Animatable } from "babylonjs/Animations/animatable";
  27503. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27504. import { Animation } from "babylonjs/Animations/animation";
  27505. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27507. /**
  27508. * Defines how a node can be built from a string name.
  27509. */
  27510. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27511. /**
  27512. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27513. */
  27514. export class Node implements IBehaviorAware<Node> {
  27515. /** @hidden */
  27516. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27517. private static _NodeConstructors;
  27518. /**
  27519. * Add a new node constructor
  27520. * @param type defines the type name of the node to construct
  27521. * @param constructorFunc defines the constructor function
  27522. */
  27523. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27524. /**
  27525. * Returns a node constructor based on type name
  27526. * @param type defines the type name
  27527. * @param name defines the new node name
  27528. * @param scene defines the hosting scene
  27529. * @param options defines optional options to transmit to constructors
  27530. * @returns the new constructor or null
  27531. */
  27532. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27533. /**
  27534. * Gets or sets the name of the node
  27535. */
  27536. name: string;
  27537. /**
  27538. * Gets or sets the id of the node
  27539. */
  27540. id: string;
  27541. /**
  27542. * Gets or sets the unique id of the node
  27543. */
  27544. uniqueId: number;
  27545. /**
  27546. * Gets or sets a string used to store user defined state for the node
  27547. */
  27548. state: string;
  27549. /**
  27550. * Gets or sets an object used to store user defined information for the node
  27551. */
  27552. metadata: any;
  27553. /**
  27554. * For internal use only. Please do not use.
  27555. */
  27556. reservedDataStore: any;
  27557. /**
  27558. * List of inspectable custom properties (used by the Inspector)
  27559. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27560. */
  27561. inspectableCustomProperties: IInspectable[];
  27562. private _doNotSerialize;
  27563. /**
  27564. * Gets or sets a boolean used to define if the node must be serialized
  27565. */
  27566. doNotSerialize: boolean;
  27567. /** @hidden */
  27568. _isDisposed: boolean;
  27569. /**
  27570. * Gets a list of Animations associated with the node
  27571. */
  27572. animations: import("babylonjs/Animations/animation").Animation[];
  27573. protected _ranges: {
  27574. [name: string]: Nullable<AnimationRange>;
  27575. };
  27576. /**
  27577. * Callback raised when the node is ready to be used
  27578. */
  27579. onReady: Nullable<(node: Node) => void>;
  27580. private _isEnabled;
  27581. private _isParentEnabled;
  27582. private _isReady;
  27583. /** @hidden */
  27584. _currentRenderId: number;
  27585. private _parentUpdateId;
  27586. /** @hidden */
  27587. _childUpdateId: number;
  27588. /** @hidden */
  27589. _waitingParentId: Nullable<string>;
  27590. /** @hidden */
  27591. _scene: Scene;
  27592. /** @hidden */
  27593. _cache: any;
  27594. private _parentNode;
  27595. private _children;
  27596. /** @hidden */
  27597. _worldMatrix: Matrix;
  27598. /** @hidden */
  27599. _worldMatrixDeterminant: number;
  27600. /** @hidden */
  27601. _worldMatrixDeterminantIsDirty: boolean;
  27602. /** @hidden */
  27603. private _sceneRootNodesIndex;
  27604. /**
  27605. * Gets a boolean indicating if the node has been disposed
  27606. * @returns true if the node was disposed
  27607. */
  27608. isDisposed(): boolean;
  27609. /**
  27610. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27611. * @see https://doc.babylonjs.com/how_to/parenting
  27612. */
  27613. parent: Nullable<Node>;
  27614. private addToSceneRootNodes;
  27615. private removeFromSceneRootNodes;
  27616. private _animationPropertiesOverride;
  27617. /**
  27618. * Gets or sets the animation properties override
  27619. */
  27620. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27621. /**
  27622. * Gets a string idenfifying the name of the class
  27623. * @returns "Node" string
  27624. */
  27625. getClassName(): string;
  27626. /** @hidden */
  27627. readonly _isNode: boolean;
  27628. /**
  27629. * An event triggered when the mesh is disposed
  27630. */
  27631. onDisposeObservable: Observable<Node>;
  27632. private _onDisposeObserver;
  27633. /**
  27634. * Sets a callback that will be raised when the node will be disposed
  27635. */
  27636. onDispose: () => void;
  27637. /**
  27638. * Creates a new Node
  27639. * @param name the name and id to be given to this node
  27640. * @param scene the scene this node will be added to
  27641. * @param addToRootNodes the node will be added to scene.rootNodes
  27642. */
  27643. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27644. /**
  27645. * Gets the scene of the node
  27646. * @returns a scene
  27647. */
  27648. getScene(): Scene;
  27649. /**
  27650. * Gets the engine of the node
  27651. * @returns a Engine
  27652. */
  27653. getEngine(): Engine;
  27654. private _behaviors;
  27655. /**
  27656. * Attach a behavior to the node
  27657. * @see http://doc.babylonjs.com/features/behaviour
  27658. * @param behavior defines the behavior to attach
  27659. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27660. * @returns the current Node
  27661. */
  27662. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27663. /**
  27664. * Remove an attached behavior
  27665. * @see http://doc.babylonjs.com/features/behaviour
  27666. * @param behavior defines the behavior to attach
  27667. * @returns the current Node
  27668. */
  27669. removeBehavior(behavior: Behavior<Node>): Node;
  27670. /**
  27671. * Gets the list of attached behaviors
  27672. * @see http://doc.babylonjs.com/features/behaviour
  27673. */
  27674. readonly behaviors: Behavior<Node>[];
  27675. /**
  27676. * Gets an attached behavior by name
  27677. * @param name defines the name of the behavior to look for
  27678. * @see http://doc.babylonjs.com/features/behaviour
  27679. * @returns null if behavior was not found else the requested behavior
  27680. */
  27681. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27682. /**
  27683. * Returns the latest update of the World matrix
  27684. * @returns a Matrix
  27685. */
  27686. getWorldMatrix(): Matrix;
  27687. /** @hidden */
  27688. _getWorldMatrixDeterminant(): number;
  27689. /**
  27690. * Returns directly the latest state of the mesh World matrix.
  27691. * A Matrix is returned.
  27692. */
  27693. readonly worldMatrixFromCache: Matrix;
  27694. /** @hidden */
  27695. _initCache(): void;
  27696. /** @hidden */
  27697. updateCache(force?: boolean): void;
  27698. /** @hidden */
  27699. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27700. /** @hidden */
  27701. _updateCache(ignoreParentClass?: boolean): void;
  27702. /** @hidden */
  27703. _isSynchronized(): boolean;
  27704. /** @hidden */
  27705. _markSyncedWithParent(): void;
  27706. /** @hidden */
  27707. isSynchronizedWithParent(): boolean;
  27708. /** @hidden */
  27709. isSynchronized(): boolean;
  27710. /**
  27711. * Is this node ready to be used/rendered
  27712. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27713. * @return true if the node is ready
  27714. */
  27715. isReady(completeCheck?: boolean): boolean;
  27716. /**
  27717. * Is this node enabled?
  27718. * 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
  27719. * @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
  27720. * @return whether this node (and its parent) is enabled
  27721. */
  27722. isEnabled(checkAncestors?: boolean): boolean;
  27723. /** @hidden */
  27724. protected _syncParentEnabledState(): void;
  27725. /**
  27726. * Set the enabled state of this node
  27727. * @param value defines the new enabled state
  27728. */
  27729. setEnabled(value: boolean): void;
  27730. /**
  27731. * Is this node a descendant of the given node?
  27732. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27733. * @param ancestor defines the parent node to inspect
  27734. * @returns a boolean indicating if this node is a descendant of the given node
  27735. */
  27736. isDescendantOf(ancestor: Node): boolean;
  27737. /** @hidden */
  27738. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27739. /**
  27740. * Will return all nodes that have this node as ascendant
  27741. * @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
  27742. * @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
  27743. * @return all children nodes of all types
  27744. */
  27745. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27746. /**
  27747. * Get all child-meshes of this node
  27748. * @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)
  27749. * @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
  27750. * @returns an array of AbstractMesh
  27751. */
  27752. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27753. /**
  27754. * Get all direct children of this node
  27755. * @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
  27756. * @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)
  27757. * @returns an array of Node
  27758. */
  27759. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27760. /** @hidden */
  27761. _setReady(state: boolean): void;
  27762. /**
  27763. * Get an animation by name
  27764. * @param name defines the name of the animation to look for
  27765. * @returns null if not found else the requested animation
  27766. */
  27767. getAnimationByName(name: string): Nullable<Animation>;
  27768. /**
  27769. * Creates an animation range for this node
  27770. * @param name defines the name of the range
  27771. * @param from defines the starting key
  27772. * @param to defines the end key
  27773. */
  27774. createAnimationRange(name: string, from: number, to: number): void;
  27775. /**
  27776. * Delete a specific animation range
  27777. * @param name defines the name of the range to delete
  27778. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27779. */
  27780. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27781. /**
  27782. * Get an animation range by name
  27783. * @param name defines the name of the animation range to look for
  27784. * @returns null if not found else the requested animation range
  27785. */
  27786. getAnimationRange(name: string): Nullable<AnimationRange>;
  27787. /**
  27788. * Gets the list of all animation ranges defined on this node
  27789. * @returns an array
  27790. */
  27791. getAnimationRanges(): Nullable<AnimationRange>[];
  27792. /**
  27793. * Will start the animation sequence
  27794. * @param name defines the range frames for animation sequence
  27795. * @param loop defines if the animation should loop (false by default)
  27796. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27797. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27798. * @returns the object created for this animation. If range does not exist, it will return null
  27799. */
  27800. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27801. /**
  27802. * Serialize animation ranges into a JSON compatible object
  27803. * @returns serialization object
  27804. */
  27805. serializeAnimationRanges(): any;
  27806. /**
  27807. * Computes the world matrix of the node
  27808. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27809. * @returns the world matrix
  27810. */
  27811. computeWorldMatrix(force?: boolean): Matrix;
  27812. /**
  27813. * Releases resources associated with this node.
  27814. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27815. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27816. */
  27817. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27818. /**
  27819. * Parse animation range data from a serialization object and store them into a given node
  27820. * @param node defines where to store the animation ranges
  27821. * @param parsedNode defines the serialization object to read data from
  27822. * @param scene defines the hosting scene
  27823. */
  27824. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27825. /**
  27826. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27827. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27828. * @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
  27829. * @returns the new bounding vectors
  27830. */
  27831. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27832. min: Vector3;
  27833. max: Vector3;
  27834. };
  27835. }
  27836. }
  27837. declare module "babylonjs/Animations/animation" {
  27838. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27839. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27840. import { Color3 } from "babylonjs/Maths/math.color";
  27841. import { Nullable } from "babylonjs/types";
  27842. import { Scene } from "babylonjs/scene";
  27843. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27844. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27845. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27846. import { Node } from "babylonjs/node";
  27847. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27848. import { Size } from "babylonjs/Maths/math.size";
  27849. import { Animatable } from "babylonjs/Animations/animatable";
  27850. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27851. /**
  27852. * @hidden
  27853. */
  27854. export class _IAnimationState {
  27855. key: number;
  27856. repeatCount: number;
  27857. workValue?: any;
  27858. loopMode?: number;
  27859. offsetValue?: any;
  27860. highLimitValue?: any;
  27861. }
  27862. /**
  27863. * Class used to store any kind of animation
  27864. */
  27865. export class Animation {
  27866. /**Name of the animation */
  27867. name: string;
  27868. /**Property to animate */
  27869. targetProperty: string;
  27870. /**The frames per second of the animation */
  27871. framePerSecond: number;
  27872. /**The data type of the animation */
  27873. dataType: number;
  27874. /**The loop mode of the animation */
  27875. loopMode?: number | undefined;
  27876. /**Specifies if blending should be enabled */
  27877. enableBlending?: boolean | undefined;
  27878. /**
  27879. * Use matrix interpolation instead of using direct key value when animating matrices
  27880. */
  27881. static AllowMatricesInterpolation: boolean;
  27882. /**
  27883. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27884. */
  27885. static AllowMatrixDecomposeForInterpolation: boolean;
  27886. /**
  27887. * Stores the key frames of the animation
  27888. */
  27889. private _keys;
  27890. /**
  27891. * Stores the easing function of the animation
  27892. */
  27893. private _easingFunction;
  27894. /**
  27895. * @hidden Internal use only
  27896. */
  27897. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27898. /**
  27899. * The set of event that will be linked to this animation
  27900. */
  27901. private _events;
  27902. /**
  27903. * Stores an array of target property paths
  27904. */
  27905. targetPropertyPath: string[];
  27906. /**
  27907. * Stores the blending speed of the animation
  27908. */
  27909. blendingSpeed: number;
  27910. /**
  27911. * Stores the animation ranges for the animation
  27912. */
  27913. private _ranges;
  27914. /**
  27915. * @hidden Internal use
  27916. */
  27917. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27918. /**
  27919. * Sets up an animation
  27920. * @param property The property to animate
  27921. * @param animationType The animation type to apply
  27922. * @param framePerSecond The frames per second of the animation
  27923. * @param easingFunction The easing function used in the animation
  27924. * @returns The created animation
  27925. */
  27926. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27927. /**
  27928. * Create and start an animation on a node
  27929. * @param name defines the name of the global animation that will be run on all nodes
  27930. * @param node defines the root node where the animation will take place
  27931. * @param targetProperty defines property to animate
  27932. * @param framePerSecond defines the number of frame per second yo use
  27933. * @param totalFrame defines the number of frames in total
  27934. * @param from defines the initial value
  27935. * @param to defines the final value
  27936. * @param loopMode defines which loop mode you want to use (off by default)
  27937. * @param easingFunction defines the easing function to use (linear by default)
  27938. * @param onAnimationEnd defines the callback to call when animation end
  27939. * @returns the animatable created for this animation
  27940. */
  27941. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27942. /**
  27943. * Create and start an animation on a node and its descendants
  27944. * @param name defines the name of the global animation that will be run on all nodes
  27945. * @param node defines the root node where the animation will take place
  27946. * @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
  27947. * @param targetProperty defines property to animate
  27948. * @param framePerSecond defines the number of frame per second to use
  27949. * @param totalFrame defines the number of frames in total
  27950. * @param from defines the initial value
  27951. * @param to defines the final value
  27952. * @param loopMode defines which loop mode you want to use (off by default)
  27953. * @param easingFunction defines the easing function to use (linear by default)
  27954. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27955. * @returns the list of animatables created for all nodes
  27956. * @example https://www.babylonjs-playground.com/#MH0VLI
  27957. */
  27958. 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[]>;
  27959. /**
  27960. * Creates a new animation, merges it with the existing animations and starts it
  27961. * @param name Name of the animation
  27962. * @param node Node which contains the scene that begins the animations
  27963. * @param targetProperty Specifies which property to animate
  27964. * @param framePerSecond The frames per second of the animation
  27965. * @param totalFrame The total number of frames
  27966. * @param from The frame at the beginning of the animation
  27967. * @param to The frame at the end of the animation
  27968. * @param loopMode Specifies the loop mode of the animation
  27969. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27970. * @param onAnimationEnd Callback to run once the animation is complete
  27971. * @returns Nullable animation
  27972. */
  27973. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27974. /**
  27975. * Transition property of an host to the target Value
  27976. * @param property The property to transition
  27977. * @param targetValue The target Value of the property
  27978. * @param host The object where the property to animate belongs
  27979. * @param scene Scene used to run the animation
  27980. * @param frameRate Framerate (in frame/s) to use
  27981. * @param transition The transition type we want to use
  27982. * @param duration The duration of the animation, in milliseconds
  27983. * @param onAnimationEnd Callback trigger at the end of the animation
  27984. * @returns Nullable animation
  27985. */
  27986. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27987. /**
  27988. * Return the array of runtime animations currently using this animation
  27989. */
  27990. readonly runtimeAnimations: RuntimeAnimation[];
  27991. /**
  27992. * Specifies if any of the runtime animations are currently running
  27993. */
  27994. readonly hasRunningRuntimeAnimations: boolean;
  27995. /**
  27996. * Initializes the animation
  27997. * @param name Name of the animation
  27998. * @param targetProperty Property to animate
  27999. * @param framePerSecond The frames per second of the animation
  28000. * @param dataType The data type of the animation
  28001. * @param loopMode The loop mode of the animation
  28002. * @param enableBlending Specifies if blending should be enabled
  28003. */
  28004. constructor(
  28005. /**Name of the animation */
  28006. name: string,
  28007. /**Property to animate */
  28008. targetProperty: string,
  28009. /**The frames per second of the animation */
  28010. framePerSecond: number,
  28011. /**The data type of the animation */
  28012. dataType: number,
  28013. /**The loop mode of the animation */
  28014. loopMode?: number | undefined,
  28015. /**Specifies if blending should be enabled */
  28016. enableBlending?: boolean | undefined);
  28017. /**
  28018. * Converts the animation to a string
  28019. * @param fullDetails support for multiple levels of logging within scene loading
  28020. * @returns String form of the animation
  28021. */
  28022. toString(fullDetails?: boolean): string;
  28023. /**
  28024. * Add an event to this animation
  28025. * @param event Event to add
  28026. */
  28027. addEvent(event: AnimationEvent): void;
  28028. /**
  28029. * Remove all events found at the given frame
  28030. * @param frame The frame to remove events from
  28031. */
  28032. removeEvents(frame: number): void;
  28033. /**
  28034. * Retrieves all the events from the animation
  28035. * @returns Events from the animation
  28036. */
  28037. getEvents(): AnimationEvent[];
  28038. /**
  28039. * Creates an animation range
  28040. * @param name Name of the animation range
  28041. * @param from Starting frame of the animation range
  28042. * @param to Ending frame of the animation
  28043. */
  28044. createRange(name: string, from: number, to: number): void;
  28045. /**
  28046. * Deletes an animation range by name
  28047. * @param name Name of the animation range to delete
  28048. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28049. */
  28050. deleteRange(name: string, deleteFrames?: boolean): void;
  28051. /**
  28052. * Gets the animation range by name, or null if not defined
  28053. * @param name Name of the animation range
  28054. * @returns Nullable animation range
  28055. */
  28056. getRange(name: string): Nullable<AnimationRange>;
  28057. /**
  28058. * Gets the key frames from the animation
  28059. * @returns The key frames of the animation
  28060. */
  28061. getKeys(): Array<IAnimationKey>;
  28062. /**
  28063. * Gets the highest frame rate of the animation
  28064. * @returns Highest frame rate of the animation
  28065. */
  28066. getHighestFrame(): number;
  28067. /**
  28068. * Gets the easing function of the animation
  28069. * @returns Easing function of the animation
  28070. */
  28071. getEasingFunction(): IEasingFunction;
  28072. /**
  28073. * Sets the easing function of the animation
  28074. * @param easingFunction A custom mathematical formula for animation
  28075. */
  28076. setEasingFunction(easingFunction: EasingFunction): void;
  28077. /**
  28078. * Interpolates a scalar linearly
  28079. * @param startValue Start value of the animation curve
  28080. * @param endValue End value of the animation curve
  28081. * @param gradient Scalar amount to interpolate
  28082. * @returns Interpolated scalar value
  28083. */
  28084. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28085. /**
  28086. * Interpolates a scalar cubically
  28087. * @param startValue Start value of the animation curve
  28088. * @param outTangent End tangent of the animation
  28089. * @param endValue End value of the animation curve
  28090. * @param inTangent Start tangent of the animation curve
  28091. * @param gradient Scalar amount to interpolate
  28092. * @returns Interpolated scalar value
  28093. */
  28094. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28095. /**
  28096. * Interpolates a quaternion using a spherical linear interpolation
  28097. * @param startValue Start value of the animation curve
  28098. * @param endValue End value of the animation curve
  28099. * @param gradient Scalar amount to interpolate
  28100. * @returns Interpolated quaternion value
  28101. */
  28102. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28103. /**
  28104. * Interpolates a quaternion cubically
  28105. * @param startValue Start value of the animation curve
  28106. * @param outTangent End tangent of the animation curve
  28107. * @param endValue End value of the animation curve
  28108. * @param inTangent Start tangent of the animation curve
  28109. * @param gradient Scalar amount to interpolate
  28110. * @returns Interpolated quaternion value
  28111. */
  28112. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28113. /**
  28114. * Interpolates a Vector3 linearl
  28115. * @param startValue Start value of the animation curve
  28116. * @param endValue End value of the animation curve
  28117. * @param gradient Scalar amount to interpolate
  28118. * @returns Interpolated scalar value
  28119. */
  28120. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28121. /**
  28122. * Interpolates a Vector3 cubically
  28123. * @param startValue Start value of the animation curve
  28124. * @param outTangent End tangent of the animation
  28125. * @param endValue End value of the animation curve
  28126. * @param inTangent Start tangent of the animation curve
  28127. * @param gradient Scalar amount to interpolate
  28128. * @returns InterpolatedVector3 value
  28129. */
  28130. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28131. /**
  28132. * Interpolates a Vector2 linearly
  28133. * @param startValue Start value of the animation curve
  28134. * @param endValue End value of the animation curve
  28135. * @param gradient Scalar amount to interpolate
  28136. * @returns Interpolated Vector2 value
  28137. */
  28138. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28139. /**
  28140. * Interpolates a Vector2 cubically
  28141. * @param startValue Start value of the animation curve
  28142. * @param outTangent End tangent of the animation
  28143. * @param endValue End value of the animation curve
  28144. * @param inTangent Start tangent of the animation curve
  28145. * @param gradient Scalar amount to interpolate
  28146. * @returns Interpolated Vector2 value
  28147. */
  28148. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28149. /**
  28150. * Interpolates a size linearly
  28151. * @param startValue Start value of the animation curve
  28152. * @param endValue End value of the animation curve
  28153. * @param gradient Scalar amount to interpolate
  28154. * @returns Interpolated Size value
  28155. */
  28156. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28157. /**
  28158. * Interpolates a Color3 linearly
  28159. * @param startValue Start value of the animation curve
  28160. * @param endValue End value of the animation curve
  28161. * @param gradient Scalar amount to interpolate
  28162. * @returns Interpolated Color3 value
  28163. */
  28164. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28165. /**
  28166. * @hidden Internal use only
  28167. */
  28168. _getKeyValue(value: any): any;
  28169. /**
  28170. * @hidden Internal use only
  28171. */
  28172. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28173. /**
  28174. * Defines the function to use to interpolate matrices
  28175. * @param startValue defines the start matrix
  28176. * @param endValue defines the end matrix
  28177. * @param gradient defines the gradient between both matrices
  28178. * @param result defines an optional target matrix where to store the interpolation
  28179. * @returns the interpolated matrix
  28180. */
  28181. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28182. /**
  28183. * Makes a copy of the animation
  28184. * @returns Cloned animation
  28185. */
  28186. clone(): Animation;
  28187. /**
  28188. * Sets the key frames of the animation
  28189. * @param values The animation key frames to set
  28190. */
  28191. setKeys(values: Array<IAnimationKey>): void;
  28192. /**
  28193. * Serializes the animation to an object
  28194. * @returns Serialized object
  28195. */
  28196. serialize(): any;
  28197. /**
  28198. * Float animation type
  28199. */
  28200. private static _ANIMATIONTYPE_FLOAT;
  28201. /**
  28202. * Vector3 animation type
  28203. */
  28204. private static _ANIMATIONTYPE_VECTOR3;
  28205. /**
  28206. * Quaternion animation type
  28207. */
  28208. private static _ANIMATIONTYPE_QUATERNION;
  28209. /**
  28210. * Matrix animation type
  28211. */
  28212. private static _ANIMATIONTYPE_MATRIX;
  28213. /**
  28214. * Color3 animation type
  28215. */
  28216. private static _ANIMATIONTYPE_COLOR3;
  28217. /**
  28218. * Vector2 animation type
  28219. */
  28220. private static _ANIMATIONTYPE_VECTOR2;
  28221. /**
  28222. * Size animation type
  28223. */
  28224. private static _ANIMATIONTYPE_SIZE;
  28225. /**
  28226. * Relative Loop Mode
  28227. */
  28228. private static _ANIMATIONLOOPMODE_RELATIVE;
  28229. /**
  28230. * Cycle Loop Mode
  28231. */
  28232. private static _ANIMATIONLOOPMODE_CYCLE;
  28233. /**
  28234. * Constant Loop Mode
  28235. */
  28236. private static _ANIMATIONLOOPMODE_CONSTANT;
  28237. /**
  28238. * Get the float animation type
  28239. */
  28240. static readonly ANIMATIONTYPE_FLOAT: number;
  28241. /**
  28242. * Get the Vector3 animation type
  28243. */
  28244. static readonly ANIMATIONTYPE_VECTOR3: number;
  28245. /**
  28246. * Get the Vector2 animation type
  28247. */
  28248. static readonly ANIMATIONTYPE_VECTOR2: number;
  28249. /**
  28250. * Get the Size animation type
  28251. */
  28252. static readonly ANIMATIONTYPE_SIZE: number;
  28253. /**
  28254. * Get the Quaternion animation type
  28255. */
  28256. static readonly ANIMATIONTYPE_QUATERNION: number;
  28257. /**
  28258. * Get the Matrix animation type
  28259. */
  28260. static readonly ANIMATIONTYPE_MATRIX: number;
  28261. /**
  28262. * Get the Color3 animation type
  28263. */
  28264. static readonly ANIMATIONTYPE_COLOR3: number;
  28265. /**
  28266. * Get the Relative Loop Mode
  28267. */
  28268. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28269. /**
  28270. * Get the Cycle Loop Mode
  28271. */
  28272. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28273. /**
  28274. * Get the Constant Loop Mode
  28275. */
  28276. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28277. /** @hidden */
  28278. static _UniversalLerp(left: any, right: any, amount: number): any;
  28279. /**
  28280. * Parses an animation object and creates an animation
  28281. * @param parsedAnimation Parsed animation object
  28282. * @returns Animation object
  28283. */
  28284. static Parse(parsedAnimation: any): Animation;
  28285. /**
  28286. * Appends the serialized animations from the source animations
  28287. * @param source Source containing the animations
  28288. * @param destination Target to store the animations
  28289. */
  28290. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28291. }
  28292. }
  28293. declare module "babylonjs/Animations/animatable.interface" {
  28294. import { Nullable } from "babylonjs/types";
  28295. import { Animation } from "babylonjs/Animations/animation";
  28296. /**
  28297. * Interface containing an array of animations
  28298. */
  28299. export interface IAnimatable {
  28300. /**
  28301. * Array of animations
  28302. */
  28303. animations: Nullable<Array<Animation>>;
  28304. }
  28305. }
  28306. declare module "babylonjs/Materials/fresnelParameters" {
  28307. import { Color3 } from "babylonjs/Maths/math.color";
  28308. /**
  28309. * This represents all the required information to add a fresnel effect on a material:
  28310. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28311. */
  28312. export class FresnelParameters {
  28313. private _isEnabled;
  28314. /**
  28315. * Define if the fresnel effect is enable or not.
  28316. */
  28317. isEnabled: boolean;
  28318. /**
  28319. * Define the color used on edges (grazing angle)
  28320. */
  28321. leftColor: Color3;
  28322. /**
  28323. * Define the color used on center
  28324. */
  28325. rightColor: Color3;
  28326. /**
  28327. * Define bias applied to computed fresnel term
  28328. */
  28329. bias: number;
  28330. /**
  28331. * Defined the power exponent applied to fresnel term
  28332. */
  28333. power: number;
  28334. /**
  28335. * Clones the current fresnel and its valuues
  28336. * @returns a clone fresnel configuration
  28337. */
  28338. clone(): FresnelParameters;
  28339. /**
  28340. * Serializes the current fresnel parameters to a JSON representation.
  28341. * @return the JSON serialization
  28342. */
  28343. serialize(): any;
  28344. /**
  28345. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28346. * @param parsedFresnelParameters Define the JSON representation
  28347. * @returns the parsed parameters
  28348. */
  28349. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28350. }
  28351. }
  28352. declare module "babylonjs/Misc/decorators" {
  28353. import { Nullable } from "babylonjs/types";
  28354. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28355. import { Scene } from "babylonjs/scene";
  28356. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28357. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28358. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28359. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28360. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28361. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28362. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28363. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28364. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28365. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28366. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28367. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28368. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28369. /**
  28370. * Decorator used to define property that can be serialized as reference to a camera
  28371. * @param sourceName defines the name of the property to decorate
  28372. */
  28373. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28374. /**
  28375. * Class used to help serialization objects
  28376. */
  28377. export class SerializationHelper {
  28378. /** @hidden */
  28379. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28380. /** @hidden */
  28381. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28382. /** @hidden */
  28383. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28384. /** @hidden */
  28385. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28386. /**
  28387. * Appends the serialized animations from the source animations
  28388. * @param source Source containing the animations
  28389. * @param destination Target to store the animations
  28390. */
  28391. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28392. /**
  28393. * Static function used to serialized a specific entity
  28394. * @param entity defines the entity to serialize
  28395. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28396. * @returns a JSON compatible object representing the serialization of the entity
  28397. */
  28398. static Serialize<T>(entity: T, serializationObject?: any): any;
  28399. /**
  28400. * Creates a new entity from a serialization data object
  28401. * @param creationFunction defines a function used to instanciated the new entity
  28402. * @param source defines the source serialization data
  28403. * @param scene defines the hosting scene
  28404. * @param rootUrl defines the root url for resources
  28405. * @returns a new entity
  28406. */
  28407. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28408. /**
  28409. * Clones an object
  28410. * @param creationFunction defines the function used to instanciate the new object
  28411. * @param source defines the source object
  28412. * @returns the cloned object
  28413. */
  28414. static Clone<T>(creationFunction: () => T, source: T): T;
  28415. /**
  28416. * Instanciates a new object based on a source one (some data will be shared between both object)
  28417. * @param creationFunction defines the function used to instanciate the new object
  28418. * @param source defines the source object
  28419. * @returns the new object
  28420. */
  28421. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28422. }
  28423. }
  28424. declare module "babylonjs/Misc/guid" {
  28425. /**
  28426. * Class used to manipulate GUIDs
  28427. */
  28428. export class GUID {
  28429. /**
  28430. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28431. * Be aware Math.random() could cause collisions, but:
  28432. * "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"
  28433. * @returns a pseudo random id
  28434. */
  28435. static RandomId(): string;
  28436. }
  28437. }
  28438. declare module "babylonjs/Materials/Textures/baseTexture" {
  28439. import { Observable } from "babylonjs/Misc/observable";
  28440. import { Nullable } from "babylonjs/types";
  28441. import { Scene } from "babylonjs/scene";
  28442. import { Matrix } from "babylonjs/Maths/math.vector";
  28443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28444. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28445. import { ISize } from "babylonjs/Maths/math.size";
  28446. /**
  28447. * Base class of all the textures in babylon.
  28448. * It groups all the common properties the materials, post process, lights... might need
  28449. * in order to make a correct use of the texture.
  28450. */
  28451. export class BaseTexture implements IAnimatable {
  28452. /**
  28453. * Default anisotropic filtering level for the application.
  28454. * It is set to 4 as a good tradeoff between perf and quality.
  28455. */
  28456. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28457. /**
  28458. * Gets or sets the unique id of the texture
  28459. */
  28460. uniqueId: number;
  28461. /**
  28462. * Define the name of the texture.
  28463. */
  28464. name: string;
  28465. /**
  28466. * Gets or sets an object used to store user defined information.
  28467. */
  28468. metadata: any;
  28469. /**
  28470. * For internal use only. Please do not use.
  28471. */
  28472. reservedDataStore: any;
  28473. private _hasAlpha;
  28474. /**
  28475. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28476. */
  28477. hasAlpha: boolean;
  28478. /**
  28479. * Defines if the alpha value should be determined via the rgb values.
  28480. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28481. */
  28482. getAlphaFromRGB: boolean;
  28483. /**
  28484. * Intensity or strength of the texture.
  28485. * It is commonly used by materials to fine tune the intensity of the texture
  28486. */
  28487. level: number;
  28488. /**
  28489. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28490. * This is part of the texture as textures usually maps to one uv set.
  28491. */
  28492. coordinatesIndex: number;
  28493. private _coordinatesMode;
  28494. /**
  28495. * How a texture is mapped.
  28496. *
  28497. * | Value | Type | Description |
  28498. * | ----- | ----------------------------------- | ----------- |
  28499. * | 0 | EXPLICIT_MODE | |
  28500. * | 1 | SPHERICAL_MODE | |
  28501. * | 2 | PLANAR_MODE | |
  28502. * | 3 | CUBIC_MODE | |
  28503. * | 4 | PROJECTION_MODE | |
  28504. * | 5 | SKYBOX_MODE | |
  28505. * | 6 | INVCUBIC_MODE | |
  28506. * | 7 | EQUIRECTANGULAR_MODE | |
  28507. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28508. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28509. */
  28510. coordinatesMode: number;
  28511. /**
  28512. * | Value | Type | Description |
  28513. * | ----- | ------------------ | ----------- |
  28514. * | 0 | CLAMP_ADDRESSMODE | |
  28515. * | 1 | WRAP_ADDRESSMODE | |
  28516. * | 2 | MIRROR_ADDRESSMODE | |
  28517. */
  28518. wrapU: number;
  28519. /**
  28520. * | Value | Type | Description |
  28521. * | ----- | ------------------ | ----------- |
  28522. * | 0 | CLAMP_ADDRESSMODE | |
  28523. * | 1 | WRAP_ADDRESSMODE | |
  28524. * | 2 | MIRROR_ADDRESSMODE | |
  28525. */
  28526. wrapV: number;
  28527. /**
  28528. * | Value | Type | Description |
  28529. * | ----- | ------------------ | ----------- |
  28530. * | 0 | CLAMP_ADDRESSMODE | |
  28531. * | 1 | WRAP_ADDRESSMODE | |
  28532. * | 2 | MIRROR_ADDRESSMODE | |
  28533. */
  28534. wrapR: number;
  28535. /**
  28536. * With compliant hardware and browser (supporting anisotropic filtering)
  28537. * this defines the level of anisotropic filtering in the texture.
  28538. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28539. */
  28540. anisotropicFilteringLevel: number;
  28541. /**
  28542. * Define if the texture is a cube texture or if false a 2d texture.
  28543. */
  28544. isCube: boolean;
  28545. /**
  28546. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28547. */
  28548. is3D: boolean;
  28549. /**
  28550. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28551. * HDR texture are usually stored in linear space.
  28552. * This only impacts the PBR and Background materials
  28553. */
  28554. gammaSpace: boolean;
  28555. /**
  28556. * Gets or sets whether or not the texture contains RGBD data.
  28557. */
  28558. isRGBD: boolean;
  28559. /**
  28560. * Is Z inverted in the texture (useful in a cube texture).
  28561. */
  28562. invertZ: boolean;
  28563. /**
  28564. * Are mip maps generated for this texture or not.
  28565. */
  28566. readonly noMipmap: boolean;
  28567. /**
  28568. * @hidden
  28569. */
  28570. lodLevelInAlpha: boolean;
  28571. /**
  28572. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28573. */
  28574. lodGenerationOffset: number;
  28575. /**
  28576. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28577. */
  28578. lodGenerationScale: number;
  28579. /**
  28580. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28581. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28582. * average roughness values.
  28583. */
  28584. linearSpecularLOD: boolean;
  28585. /**
  28586. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28587. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28588. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28589. */
  28590. irradianceTexture: Nullable<BaseTexture>;
  28591. /**
  28592. * Define if the texture is a render target.
  28593. */
  28594. isRenderTarget: boolean;
  28595. /**
  28596. * Define the unique id of the texture in the scene.
  28597. */
  28598. readonly uid: string;
  28599. /**
  28600. * Return a string representation of the texture.
  28601. * @returns the texture as a string
  28602. */
  28603. toString(): string;
  28604. /**
  28605. * Get the class name of the texture.
  28606. * @returns "BaseTexture"
  28607. */
  28608. getClassName(): string;
  28609. /**
  28610. * Define the list of animation attached to the texture.
  28611. */
  28612. animations: import("babylonjs/Animations/animation").Animation[];
  28613. /**
  28614. * An event triggered when the texture is disposed.
  28615. */
  28616. onDisposeObservable: Observable<BaseTexture>;
  28617. private _onDisposeObserver;
  28618. /**
  28619. * Callback triggered when the texture has been disposed.
  28620. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28621. */
  28622. onDispose: () => void;
  28623. /**
  28624. * Define the current state of the loading sequence when in delayed load mode.
  28625. */
  28626. delayLoadState: number;
  28627. private _scene;
  28628. /** @hidden */
  28629. _texture: Nullable<InternalTexture>;
  28630. private _uid;
  28631. /**
  28632. * Define if the texture is preventinga material to render or not.
  28633. * If not and the texture is not ready, the engine will use a default black texture instead.
  28634. */
  28635. readonly isBlocking: boolean;
  28636. /**
  28637. * Instantiates a new BaseTexture.
  28638. * Base class of all the textures in babylon.
  28639. * It groups all the common properties the materials, post process, lights... might need
  28640. * in order to make a correct use of the texture.
  28641. * @param scene Define the scene the texture blongs to
  28642. */
  28643. constructor(scene: Nullable<Scene>);
  28644. /**
  28645. * Get the scene the texture belongs to.
  28646. * @returns the scene or null if undefined
  28647. */
  28648. getScene(): Nullable<Scene>;
  28649. /**
  28650. * Get the texture transform matrix used to offset tile the texture for istance.
  28651. * @returns the transformation matrix
  28652. */
  28653. getTextureMatrix(): Matrix;
  28654. /**
  28655. * Get the texture reflection matrix used to rotate/transform the reflection.
  28656. * @returns the reflection matrix
  28657. */
  28658. getReflectionTextureMatrix(): Matrix;
  28659. /**
  28660. * Get the underlying lower level texture from Babylon.
  28661. * @returns the insternal texture
  28662. */
  28663. getInternalTexture(): Nullable<InternalTexture>;
  28664. /**
  28665. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28666. * @returns true if ready or not blocking
  28667. */
  28668. isReadyOrNotBlocking(): boolean;
  28669. /**
  28670. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28671. * @returns true if fully ready
  28672. */
  28673. isReady(): boolean;
  28674. private _cachedSize;
  28675. /**
  28676. * Get the size of the texture.
  28677. * @returns the texture size.
  28678. */
  28679. getSize(): ISize;
  28680. /**
  28681. * Get the base size of the texture.
  28682. * It can be different from the size if the texture has been resized for POT for instance
  28683. * @returns the base size
  28684. */
  28685. getBaseSize(): ISize;
  28686. /**
  28687. * Update the sampling mode of the texture.
  28688. * Default is Trilinear mode.
  28689. *
  28690. * | Value | Type | Description |
  28691. * | ----- | ------------------ | ----------- |
  28692. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28693. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28694. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28695. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28696. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28697. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28698. * | 7 | NEAREST_LINEAR | |
  28699. * | 8 | NEAREST_NEAREST | |
  28700. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28701. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28702. * | 11 | LINEAR_LINEAR | |
  28703. * | 12 | LINEAR_NEAREST | |
  28704. *
  28705. * > _mag_: magnification filter (close to the viewer)
  28706. * > _min_: minification filter (far from the viewer)
  28707. * > _mip_: filter used between mip map levels
  28708. *@param samplingMode Define the new sampling mode of the texture
  28709. */
  28710. updateSamplingMode(samplingMode: number): void;
  28711. /**
  28712. * Scales the texture if is `canRescale()`
  28713. * @param ratio the resize factor we want to use to rescale
  28714. */
  28715. scale(ratio: number): void;
  28716. /**
  28717. * Get if the texture can rescale.
  28718. */
  28719. readonly canRescale: boolean;
  28720. /** @hidden */
  28721. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28722. /** @hidden */
  28723. _rebuild(): void;
  28724. /**
  28725. * Triggers the load sequence in delayed load mode.
  28726. */
  28727. delayLoad(): void;
  28728. /**
  28729. * Clones the texture.
  28730. * @returns the cloned texture
  28731. */
  28732. clone(): Nullable<BaseTexture>;
  28733. /**
  28734. * Get the texture underlying type (INT, FLOAT...)
  28735. */
  28736. readonly textureType: number;
  28737. /**
  28738. * Get the texture underlying format (RGB, RGBA...)
  28739. */
  28740. readonly textureFormat: number;
  28741. /**
  28742. * Indicates that textures need to be re-calculated for all materials
  28743. */
  28744. protected _markAllSubMeshesAsTexturesDirty(): void;
  28745. /**
  28746. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28747. * This will returns an RGBA array buffer containing either in values (0-255) or
  28748. * float values (0-1) depending of the underlying buffer type.
  28749. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28750. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28751. * @param buffer defines a user defined buffer to fill with data (can be null)
  28752. * @returns The Array buffer containing the pixels data.
  28753. */
  28754. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28755. /**
  28756. * Release and destroy the underlying lower level texture aka internalTexture.
  28757. */
  28758. releaseInternalTexture(): void;
  28759. /** @hidden */
  28760. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28761. /** @hidden */
  28762. readonly _lodTextureMid: Nullable<BaseTexture>;
  28763. /** @hidden */
  28764. readonly _lodTextureLow: Nullable<BaseTexture>;
  28765. /**
  28766. * Dispose the texture and release its associated resources.
  28767. */
  28768. dispose(): void;
  28769. /**
  28770. * Serialize the texture into a JSON representation that can be parsed later on.
  28771. * @returns the JSON representation of the texture
  28772. */
  28773. serialize(): any;
  28774. /**
  28775. * Helper function to be called back once a list of texture contains only ready textures.
  28776. * @param textures Define the list of textures to wait for
  28777. * @param callback Define the callback triggered once the entire list will be ready
  28778. */
  28779. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28780. }
  28781. }
  28782. declare module "babylonjs/Materials/effect" {
  28783. import { Observable } from "babylonjs/Misc/observable";
  28784. import { Nullable } from "babylonjs/types";
  28785. import { IDisposable } from "babylonjs/scene";
  28786. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28787. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28788. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28789. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  28790. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  28791. import { Engine } from "babylonjs/Engines/engine";
  28792. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28793. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28794. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28795. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28796. /**
  28797. * Options to be used when creating an effect.
  28798. */
  28799. export interface IEffectCreationOptions {
  28800. /**
  28801. * Atrributes that will be used in the shader.
  28802. */
  28803. attributes: string[];
  28804. /**
  28805. * Uniform varible names that will be set in the shader.
  28806. */
  28807. uniformsNames: string[];
  28808. /**
  28809. * Uniform buffer varible names that will be set in the shader.
  28810. */
  28811. uniformBuffersNames: string[];
  28812. /**
  28813. * Sampler texture variable names that will be set in the shader.
  28814. */
  28815. samplers: string[];
  28816. /**
  28817. * Define statements that will be set in the shader.
  28818. */
  28819. defines: any;
  28820. /**
  28821. * Possible fallbacks for this effect to improve performance when needed.
  28822. */
  28823. fallbacks: Nullable<IEffectFallbacks>;
  28824. /**
  28825. * Callback that will be called when the shader is compiled.
  28826. */
  28827. onCompiled: Nullable<(effect: Effect) => void>;
  28828. /**
  28829. * Callback that will be called if an error occurs during shader compilation.
  28830. */
  28831. onError: Nullable<(effect: Effect, errors: string) => void>;
  28832. /**
  28833. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28834. */
  28835. indexParameters?: any;
  28836. /**
  28837. * Max number of lights that can be used in the shader.
  28838. */
  28839. maxSimultaneousLights?: number;
  28840. /**
  28841. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28842. */
  28843. transformFeedbackVaryings?: Nullable<string[]>;
  28844. }
  28845. /**
  28846. * Effect containing vertex and fragment shader that can be executed on an object.
  28847. */
  28848. export class Effect implements IDisposable {
  28849. /**
  28850. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28851. */
  28852. static ShadersRepository: string;
  28853. /**
  28854. * Name of the effect.
  28855. */
  28856. name: any;
  28857. /**
  28858. * String container all the define statements that should be set on the shader.
  28859. */
  28860. defines: string;
  28861. /**
  28862. * Callback that will be called when the shader is compiled.
  28863. */
  28864. onCompiled: Nullable<(effect: Effect) => void>;
  28865. /**
  28866. * Callback that will be called if an error occurs during shader compilation.
  28867. */
  28868. onError: Nullable<(effect: Effect, errors: string) => void>;
  28869. /**
  28870. * Callback that will be called when effect is bound.
  28871. */
  28872. onBind: Nullable<(effect: Effect) => void>;
  28873. /**
  28874. * Unique ID of the effect.
  28875. */
  28876. uniqueId: number;
  28877. /**
  28878. * Observable that will be called when the shader is compiled.
  28879. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28880. */
  28881. onCompileObservable: Observable<Effect>;
  28882. /**
  28883. * Observable that will be called if an error occurs during shader compilation.
  28884. */
  28885. onErrorObservable: Observable<Effect>;
  28886. /** @hidden */
  28887. _onBindObservable: Nullable<Observable<Effect>>;
  28888. /**
  28889. * Observable that will be called when effect is bound.
  28890. */
  28891. readonly onBindObservable: Observable<Effect>;
  28892. /** @hidden */
  28893. _bonesComputationForcedToCPU: boolean;
  28894. private static _uniqueIdSeed;
  28895. private _engine;
  28896. private _uniformBuffersNames;
  28897. private _uniformsNames;
  28898. private _samplerList;
  28899. private _samplers;
  28900. private _isReady;
  28901. private _compilationError;
  28902. private _allFallbacksProcessed;
  28903. private _attributesNames;
  28904. private _attributes;
  28905. private _uniforms;
  28906. /**
  28907. * Key for the effect.
  28908. * @hidden
  28909. */
  28910. _key: string;
  28911. private _indexParameters;
  28912. private _fallbacks;
  28913. private _vertexSourceCode;
  28914. private _fragmentSourceCode;
  28915. private _vertexSourceCodeOverride;
  28916. private _fragmentSourceCodeOverride;
  28917. private _transformFeedbackVaryings;
  28918. /**
  28919. * Compiled shader to webGL program.
  28920. * @hidden
  28921. */
  28922. _pipelineContext: Nullable<IPipelineContext>;
  28923. private _valueCache;
  28924. private static _baseCache;
  28925. /**
  28926. * Instantiates an effect.
  28927. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28928. * @param baseName Name of the effect.
  28929. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28930. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28931. * @param samplers List of sampler variables that will be passed to the shader.
  28932. * @param engine Engine to be used to render the effect
  28933. * @param defines Define statements to be added to the shader.
  28934. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28935. * @param onCompiled Callback that will be called when the shader is compiled.
  28936. * @param onError Callback that will be called if an error occurs during shader compilation.
  28937. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28938. */
  28939. 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);
  28940. private _useFinalCode;
  28941. /**
  28942. * Unique key for this effect
  28943. */
  28944. readonly key: string;
  28945. /**
  28946. * If the effect has been compiled and prepared.
  28947. * @returns if the effect is compiled and prepared.
  28948. */
  28949. isReady(): boolean;
  28950. private _isReadyInternal;
  28951. /**
  28952. * The engine the effect was initialized with.
  28953. * @returns the engine.
  28954. */
  28955. getEngine(): Engine;
  28956. /**
  28957. * The pipeline context for this effect
  28958. * @returns the associated pipeline context
  28959. */
  28960. getPipelineContext(): Nullable<IPipelineContext>;
  28961. /**
  28962. * The set of names of attribute variables for the shader.
  28963. * @returns An array of attribute names.
  28964. */
  28965. getAttributesNames(): string[];
  28966. /**
  28967. * Returns the attribute at the given index.
  28968. * @param index The index of the attribute.
  28969. * @returns The location of the attribute.
  28970. */
  28971. getAttributeLocation(index: number): number;
  28972. /**
  28973. * Returns the attribute based on the name of the variable.
  28974. * @param name of the attribute to look up.
  28975. * @returns the attribute location.
  28976. */
  28977. getAttributeLocationByName(name: string): number;
  28978. /**
  28979. * The number of attributes.
  28980. * @returns the numnber of attributes.
  28981. */
  28982. getAttributesCount(): number;
  28983. /**
  28984. * Gets the index of a uniform variable.
  28985. * @param uniformName of the uniform to look up.
  28986. * @returns the index.
  28987. */
  28988. getUniformIndex(uniformName: string): number;
  28989. /**
  28990. * Returns the attribute based on the name of the variable.
  28991. * @param uniformName of the uniform to look up.
  28992. * @returns the location of the uniform.
  28993. */
  28994. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28995. /**
  28996. * Returns an array of sampler variable names
  28997. * @returns The array of sampler variable neames.
  28998. */
  28999. getSamplers(): string[];
  29000. /**
  29001. * The error from the last compilation.
  29002. * @returns the error string.
  29003. */
  29004. getCompilationError(): string;
  29005. /**
  29006. * Gets a boolean indicating that all fallbacks were used during compilation
  29007. * @returns true if all fallbacks were used
  29008. */
  29009. allFallbacksProcessed(): boolean;
  29010. /**
  29011. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29012. * @param func The callback to be used.
  29013. */
  29014. executeWhenCompiled(func: (effect: Effect) => void): void;
  29015. private _checkIsReady;
  29016. private _loadShader;
  29017. /**
  29018. * Recompiles the webGL program
  29019. * @param vertexSourceCode The source code for the vertex shader.
  29020. * @param fragmentSourceCode The source code for the fragment shader.
  29021. * @param onCompiled Callback called when completed.
  29022. * @param onError Callback called on error.
  29023. * @hidden
  29024. */
  29025. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29026. /**
  29027. * Prepares the effect
  29028. * @hidden
  29029. */
  29030. _prepareEffect(): void;
  29031. private _processCompilationErrors;
  29032. /**
  29033. * Checks if the effect is supported. (Must be called after compilation)
  29034. */
  29035. readonly isSupported: boolean;
  29036. /**
  29037. * Binds a texture to the engine to be used as output of the shader.
  29038. * @param channel Name of the output variable.
  29039. * @param texture Texture to bind.
  29040. * @hidden
  29041. */
  29042. _bindTexture(channel: string, texture: InternalTexture): void;
  29043. /**
  29044. * Sets a texture on the engine to be used in the shader.
  29045. * @param channel Name of the sampler variable.
  29046. * @param texture Texture to set.
  29047. */
  29048. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29049. /**
  29050. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29051. * @param channel Name of the sampler variable.
  29052. * @param texture Texture to set.
  29053. */
  29054. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29055. /**
  29056. * Sets an array of textures on the engine to be used in the shader.
  29057. * @param channel Name of the variable.
  29058. * @param textures Textures to set.
  29059. */
  29060. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29061. /**
  29062. * 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)
  29063. * @param channel Name of the sampler variable.
  29064. * @param postProcess Post process to get the input texture from.
  29065. */
  29066. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29067. /**
  29068. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29069. * 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)
  29070. * @param channel Name of the sampler variable.
  29071. * @param postProcess Post process to get the output texture from.
  29072. */
  29073. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29074. /** @hidden */
  29075. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29076. /** @hidden */
  29077. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29078. /** @hidden */
  29079. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29080. /** @hidden */
  29081. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29082. /**
  29083. * Binds a buffer to a uniform.
  29084. * @param buffer Buffer to bind.
  29085. * @param name Name of the uniform variable to bind to.
  29086. */
  29087. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29088. /**
  29089. * Binds block to a uniform.
  29090. * @param blockName Name of the block to bind.
  29091. * @param index Index to bind.
  29092. */
  29093. bindUniformBlock(blockName: string, index: number): void;
  29094. /**
  29095. * Sets an interger value on a uniform variable.
  29096. * @param uniformName Name of the variable.
  29097. * @param value Value to be set.
  29098. * @returns this effect.
  29099. */
  29100. setInt(uniformName: string, value: number): Effect;
  29101. /**
  29102. * Sets an int array on a uniform variable.
  29103. * @param uniformName Name of the variable.
  29104. * @param array array to be set.
  29105. * @returns this effect.
  29106. */
  29107. setIntArray(uniformName: string, array: Int32Array): Effect;
  29108. /**
  29109. * 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)
  29110. * @param uniformName Name of the variable.
  29111. * @param array array to be set.
  29112. * @returns this effect.
  29113. */
  29114. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29115. /**
  29116. * 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)
  29117. * @param uniformName Name of the variable.
  29118. * @param array array to be set.
  29119. * @returns this effect.
  29120. */
  29121. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29122. /**
  29123. * 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)
  29124. * @param uniformName Name of the variable.
  29125. * @param array array to be set.
  29126. * @returns this effect.
  29127. */
  29128. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29129. /**
  29130. * Sets an float array on a uniform variable.
  29131. * @param uniformName Name of the variable.
  29132. * @param array array to be set.
  29133. * @returns this effect.
  29134. */
  29135. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29136. /**
  29137. * 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)
  29138. * @param uniformName Name of the variable.
  29139. * @param array array to be set.
  29140. * @returns this effect.
  29141. */
  29142. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29143. /**
  29144. * 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)
  29145. * @param uniformName Name of the variable.
  29146. * @param array array to be set.
  29147. * @returns this effect.
  29148. */
  29149. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29150. /**
  29151. * 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)
  29152. * @param uniformName Name of the variable.
  29153. * @param array array to be set.
  29154. * @returns this effect.
  29155. */
  29156. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29157. /**
  29158. * Sets an array on a uniform variable.
  29159. * @param uniformName Name of the variable.
  29160. * @param array array to be set.
  29161. * @returns this effect.
  29162. */
  29163. setArray(uniformName: string, array: number[]): Effect;
  29164. /**
  29165. * 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)
  29166. * @param uniformName Name of the variable.
  29167. * @param array array to be set.
  29168. * @returns this effect.
  29169. */
  29170. setArray2(uniformName: string, array: number[]): Effect;
  29171. /**
  29172. * 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)
  29173. * @param uniformName Name of the variable.
  29174. * @param array array to be set.
  29175. * @returns this effect.
  29176. */
  29177. setArray3(uniformName: string, array: number[]): Effect;
  29178. /**
  29179. * 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)
  29180. * @param uniformName Name of the variable.
  29181. * @param array array to be set.
  29182. * @returns this effect.
  29183. */
  29184. setArray4(uniformName: string, array: number[]): Effect;
  29185. /**
  29186. * Sets matrices on a uniform variable.
  29187. * @param uniformName Name of the variable.
  29188. * @param matrices matrices to be set.
  29189. * @returns this effect.
  29190. */
  29191. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29192. /**
  29193. * Sets matrix on a uniform variable.
  29194. * @param uniformName Name of the variable.
  29195. * @param matrix matrix to be set.
  29196. * @returns this effect.
  29197. */
  29198. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29199. /**
  29200. * 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)
  29201. * @param uniformName Name of the variable.
  29202. * @param matrix matrix to be set.
  29203. * @returns this effect.
  29204. */
  29205. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29206. /**
  29207. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29208. * @param uniformName Name of the variable.
  29209. * @param matrix matrix to be set.
  29210. * @returns this effect.
  29211. */
  29212. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29213. /**
  29214. * Sets a float on a uniform variable.
  29215. * @param uniformName Name of the variable.
  29216. * @param value value to be set.
  29217. * @returns this effect.
  29218. */
  29219. setFloat(uniformName: string, value: number): Effect;
  29220. /**
  29221. * Sets a boolean on a uniform variable.
  29222. * @param uniformName Name of the variable.
  29223. * @param bool value to be set.
  29224. * @returns this effect.
  29225. */
  29226. setBool(uniformName: string, bool: boolean): Effect;
  29227. /**
  29228. * Sets a Vector2 on a uniform variable.
  29229. * @param uniformName Name of the variable.
  29230. * @param vector2 vector2 to be set.
  29231. * @returns this effect.
  29232. */
  29233. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29234. /**
  29235. * Sets a float2 on a uniform variable.
  29236. * @param uniformName Name of the variable.
  29237. * @param x First float in float2.
  29238. * @param y Second float in float2.
  29239. * @returns this effect.
  29240. */
  29241. setFloat2(uniformName: string, x: number, y: number): Effect;
  29242. /**
  29243. * Sets a Vector3 on a uniform variable.
  29244. * @param uniformName Name of the variable.
  29245. * @param vector3 Value to be set.
  29246. * @returns this effect.
  29247. */
  29248. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29249. /**
  29250. * Sets a float3 on a uniform variable.
  29251. * @param uniformName Name of the variable.
  29252. * @param x First float in float3.
  29253. * @param y Second float in float3.
  29254. * @param z Third float in float3.
  29255. * @returns this effect.
  29256. */
  29257. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29258. /**
  29259. * Sets a Vector4 on a uniform variable.
  29260. * @param uniformName Name of the variable.
  29261. * @param vector4 Value to be set.
  29262. * @returns this effect.
  29263. */
  29264. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29265. /**
  29266. * Sets a float4 on a uniform variable.
  29267. * @param uniformName Name of the variable.
  29268. * @param x First float in float4.
  29269. * @param y Second float in float4.
  29270. * @param z Third float in float4.
  29271. * @param w Fourth float in float4.
  29272. * @returns this effect.
  29273. */
  29274. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29275. /**
  29276. * Sets a Color3 on a uniform variable.
  29277. * @param uniformName Name of the variable.
  29278. * @param color3 Value to be set.
  29279. * @returns this effect.
  29280. */
  29281. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29282. /**
  29283. * Sets a Color4 on a uniform variable.
  29284. * @param uniformName Name of the variable.
  29285. * @param color3 Value to be set.
  29286. * @param alpha Alpha value to be set.
  29287. * @returns this effect.
  29288. */
  29289. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29290. /**
  29291. * Sets a Color4 on a uniform variable
  29292. * @param uniformName defines the name of the variable
  29293. * @param color4 defines the value to be set
  29294. * @returns this effect.
  29295. */
  29296. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29297. /** Release all associated resources */
  29298. dispose(): void;
  29299. /**
  29300. * This function will add a new shader to the shader store
  29301. * @param name the name of the shader
  29302. * @param pixelShader optional pixel shader content
  29303. * @param vertexShader optional vertex shader content
  29304. */
  29305. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29306. /**
  29307. * Store of each shader (The can be looked up using effect.key)
  29308. */
  29309. static ShadersStore: {
  29310. [key: string]: string;
  29311. };
  29312. /**
  29313. * Store of each included file for a shader (The can be looked up using effect.key)
  29314. */
  29315. static IncludesShadersStore: {
  29316. [key: string]: string;
  29317. };
  29318. /**
  29319. * Resets the cache of effects.
  29320. */
  29321. static ResetCache(): void;
  29322. }
  29323. }
  29324. declare module "babylonjs/Engines/engineCapabilities" {
  29325. import { Nullable } from "babylonjs/types";
  29326. /**
  29327. * Class used to describe the capabilities of the engine relatively to the current browser
  29328. */
  29329. export class EngineCapabilities {
  29330. /** Maximum textures units per fragment shader */
  29331. maxTexturesImageUnits: number;
  29332. /** Maximum texture units per vertex shader */
  29333. maxVertexTextureImageUnits: number;
  29334. /** Maximum textures units in the entire pipeline */
  29335. maxCombinedTexturesImageUnits: number;
  29336. /** Maximum texture size */
  29337. maxTextureSize: number;
  29338. /** Maximum cube texture size */
  29339. maxCubemapTextureSize: number;
  29340. /** Maximum render texture size */
  29341. maxRenderTextureSize: number;
  29342. /** Maximum number of vertex attributes */
  29343. maxVertexAttribs: number;
  29344. /** Maximum number of varyings */
  29345. maxVaryingVectors: number;
  29346. /** Maximum number of uniforms per vertex shader */
  29347. maxVertexUniformVectors: number;
  29348. /** Maximum number of uniforms per fragment shader */
  29349. maxFragmentUniformVectors: number;
  29350. /** Defines if standard derivates (dx/dy) are supported */
  29351. standardDerivatives: boolean;
  29352. /** Defines if s3tc texture compression is supported */
  29353. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29354. /** Defines if pvrtc texture compression is supported */
  29355. pvrtc: any;
  29356. /** Defines if etc1 texture compression is supported */
  29357. etc1: any;
  29358. /** Defines if etc2 texture compression is supported */
  29359. etc2: any;
  29360. /** Defines if astc texture compression is supported */
  29361. astc: any;
  29362. /** Defines if float textures are supported */
  29363. textureFloat: boolean;
  29364. /** Defines if vertex array objects are supported */
  29365. vertexArrayObject: boolean;
  29366. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29367. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29368. /** Gets the maximum level of anisotropy supported */
  29369. maxAnisotropy: number;
  29370. /** Defines if instancing is supported */
  29371. instancedArrays: boolean;
  29372. /** Defines if 32 bits indices are supported */
  29373. uintIndices: boolean;
  29374. /** Defines if high precision shaders are supported */
  29375. highPrecisionShaderSupported: boolean;
  29376. /** Defines if depth reading in the fragment shader is supported */
  29377. fragmentDepthSupported: boolean;
  29378. /** Defines if float texture linear filtering is supported*/
  29379. textureFloatLinearFiltering: boolean;
  29380. /** Defines if rendering to float textures is supported */
  29381. textureFloatRender: boolean;
  29382. /** Defines if half float textures are supported*/
  29383. textureHalfFloat: boolean;
  29384. /** Defines if half float texture linear filtering is supported*/
  29385. textureHalfFloatLinearFiltering: boolean;
  29386. /** Defines if rendering to half float textures is supported */
  29387. textureHalfFloatRender: boolean;
  29388. /** Defines if textureLOD shader command is supported */
  29389. textureLOD: boolean;
  29390. /** Defines if draw buffers extension is supported */
  29391. drawBuffersExtension: boolean;
  29392. /** Defines if depth textures are supported */
  29393. depthTextureExtension: boolean;
  29394. /** Defines if float color buffer are supported */
  29395. colorBufferFloat: boolean;
  29396. /** Gets disjoint timer query extension (null if not supported) */
  29397. timerQuery: EXT_disjoint_timer_query;
  29398. /** Defines if timestamp can be used with timer query */
  29399. canUseTimestampForTimerQuery: boolean;
  29400. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29401. multiview: any;
  29402. /** Function used to let the system compiles shaders in background */
  29403. parallelShaderCompile: {
  29404. COMPLETION_STATUS_KHR: number;
  29405. };
  29406. /** Max number of texture samples for MSAA */
  29407. maxMSAASamples: number;
  29408. /** Defines if the blend min max extension is supported */
  29409. blendMinMax: boolean;
  29410. }
  29411. }
  29412. declare module "babylonjs/States/depthCullingState" {
  29413. import { Nullable } from "babylonjs/types";
  29414. /**
  29415. * @hidden
  29416. **/
  29417. export class DepthCullingState {
  29418. private _isDepthTestDirty;
  29419. private _isDepthMaskDirty;
  29420. private _isDepthFuncDirty;
  29421. private _isCullFaceDirty;
  29422. private _isCullDirty;
  29423. private _isZOffsetDirty;
  29424. private _isFrontFaceDirty;
  29425. private _depthTest;
  29426. private _depthMask;
  29427. private _depthFunc;
  29428. private _cull;
  29429. private _cullFace;
  29430. private _zOffset;
  29431. private _frontFace;
  29432. /**
  29433. * Initializes the state.
  29434. */
  29435. constructor();
  29436. readonly isDirty: boolean;
  29437. zOffset: number;
  29438. cullFace: Nullable<number>;
  29439. cull: Nullable<boolean>;
  29440. depthFunc: Nullable<number>;
  29441. depthMask: boolean;
  29442. depthTest: boolean;
  29443. frontFace: Nullable<number>;
  29444. reset(): void;
  29445. apply(gl: WebGLRenderingContext): void;
  29446. }
  29447. }
  29448. declare module "babylonjs/States/stencilState" {
  29449. /**
  29450. * @hidden
  29451. **/
  29452. export class StencilState {
  29453. /** 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 */
  29454. static readonly ALWAYS: number;
  29455. /** Passed to stencilOperation to specify that stencil value must be kept */
  29456. static readonly KEEP: number;
  29457. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29458. static readonly REPLACE: number;
  29459. private _isStencilTestDirty;
  29460. private _isStencilMaskDirty;
  29461. private _isStencilFuncDirty;
  29462. private _isStencilOpDirty;
  29463. private _stencilTest;
  29464. private _stencilMask;
  29465. private _stencilFunc;
  29466. private _stencilFuncRef;
  29467. private _stencilFuncMask;
  29468. private _stencilOpStencilFail;
  29469. private _stencilOpDepthFail;
  29470. private _stencilOpStencilDepthPass;
  29471. readonly isDirty: boolean;
  29472. stencilFunc: number;
  29473. stencilFuncRef: number;
  29474. stencilFuncMask: number;
  29475. stencilOpStencilFail: number;
  29476. stencilOpDepthFail: number;
  29477. stencilOpStencilDepthPass: number;
  29478. stencilMask: number;
  29479. stencilTest: boolean;
  29480. constructor();
  29481. reset(): void;
  29482. apply(gl: WebGLRenderingContext): void;
  29483. }
  29484. }
  29485. declare module "babylonjs/States/alphaCullingState" {
  29486. /**
  29487. * @hidden
  29488. **/
  29489. export class AlphaState {
  29490. private _isAlphaBlendDirty;
  29491. private _isBlendFunctionParametersDirty;
  29492. private _isBlendEquationParametersDirty;
  29493. private _isBlendConstantsDirty;
  29494. private _alphaBlend;
  29495. private _blendFunctionParameters;
  29496. private _blendEquationParameters;
  29497. private _blendConstants;
  29498. /**
  29499. * Initializes the state.
  29500. */
  29501. constructor();
  29502. readonly isDirty: boolean;
  29503. alphaBlend: boolean;
  29504. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29505. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29506. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29507. reset(): void;
  29508. apply(gl: WebGLRenderingContext): void;
  29509. }
  29510. }
  29511. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29512. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29513. /** @hidden */
  29514. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29515. attributeProcessor(attribute: string): string;
  29516. varyingProcessor(varying: string, isFragment: boolean): string;
  29517. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29518. }
  29519. }
  29520. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29521. /**
  29522. * Interface for attribute information associated with buffer instanciation
  29523. */
  29524. export class InstancingAttributeInfo {
  29525. /**
  29526. * Index/offset of the attribute in the vertex shader
  29527. */
  29528. index: number;
  29529. /**
  29530. * size of the attribute, 1, 2, 3 or 4
  29531. */
  29532. attributeSize: number;
  29533. /**
  29534. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29535. * default is FLOAT
  29536. */
  29537. attribyteType: number;
  29538. /**
  29539. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29540. */
  29541. normalized: boolean;
  29542. /**
  29543. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29544. */
  29545. offset: number;
  29546. /**
  29547. * Name of the GLSL attribute, for debugging purpose only
  29548. */
  29549. attributeName: string;
  29550. }
  29551. }
  29552. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29553. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29554. import { Nullable } from "babylonjs/types";
  29555. module "babylonjs/Engines/thinEngine" {
  29556. interface ThinEngine {
  29557. /**
  29558. * Update a video texture
  29559. * @param texture defines the texture to update
  29560. * @param video defines the video element to use
  29561. * @param invertY defines if data must be stored with Y axis inverted
  29562. */
  29563. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29564. }
  29565. }
  29566. }
  29567. declare module "babylonjs/Materials/Textures/videoTexture" {
  29568. import { Observable } from "babylonjs/Misc/observable";
  29569. import { Nullable } from "babylonjs/types";
  29570. import { Scene } from "babylonjs/scene";
  29571. import { Texture } from "babylonjs/Materials/Textures/texture";
  29572. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29573. /**
  29574. * Settings for finer control over video usage
  29575. */
  29576. export interface VideoTextureSettings {
  29577. /**
  29578. * Applies `autoplay` to video, if specified
  29579. */
  29580. autoPlay?: boolean;
  29581. /**
  29582. * Applies `loop` to video, if specified
  29583. */
  29584. loop?: boolean;
  29585. /**
  29586. * Automatically updates internal texture from video at every frame in the render loop
  29587. */
  29588. autoUpdateTexture: boolean;
  29589. /**
  29590. * Image src displayed during the video loading or until the user interacts with the video.
  29591. */
  29592. poster?: string;
  29593. }
  29594. /**
  29595. * If you want to display a video in your scene, this is the special texture for that.
  29596. * This special texture works similar to other textures, with the exception of a few parameters.
  29597. * @see https://doc.babylonjs.com/how_to/video_texture
  29598. */
  29599. export class VideoTexture extends Texture {
  29600. /**
  29601. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29602. */
  29603. readonly autoUpdateTexture: boolean;
  29604. /**
  29605. * The video instance used by the texture internally
  29606. */
  29607. readonly video: HTMLVideoElement;
  29608. private _onUserActionRequestedObservable;
  29609. /**
  29610. * Event triggerd when a dom action is required by the user to play the video.
  29611. * This happens due to recent changes in browser policies preventing video to auto start.
  29612. */
  29613. readonly onUserActionRequestedObservable: Observable<Texture>;
  29614. private _generateMipMaps;
  29615. private _engine;
  29616. private _stillImageCaptured;
  29617. private _displayingPosterTexture;
  29618. private _settings;
  29619. private _createInternalTextureOnEvent;
  29620. private _frameId;
  29621. /**
  29622. * Creates a video texture.
  29623. * If you want to display a video in your scene, this is the special texture for that.
  29624. * This special texture works similar to other textures, with the exception of a few parameters.
  29625. * @see https://doc.babylonjs.com/how_to/video_texture
  29626. * @param name optional name, will detect from video source, if not defined
  29627. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29628. * @param scene is obviously the current scene.
  29629. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29630. * @param invertY is false by default but can be used to invert video on Y axis
  29631. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29632. * @param settings allows finer control over video usage
  29633. */
  29634. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29635. private _getName;
  29636. private _getVideo;
  29637. private _createInternalTexture;
  29638. private reset;
  29639. /**
  29640. * @hidden Internal method to initiate `update`.
  29641. */
  29642. _rebuild(): void;
  29643. /**
  29644. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29645. */
  29646. update(): void;
  29647. /**
  29648. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29649. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29650. */
  29651. updateTexture(isVisible: boolean): void;
  29652. protected _updateInternalTexture: () => void;
  29653. /**
  29654. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29655. * @param url New url.
  29656. */
  29657. updateURL(url: string): void;
  29658. /**
  29659. * Dispose the texture and release its associated resources.
  29660. */
  29661. dispose(): void;
  29662. /**
  29663. * Creates a video texture straight from a stream.
  29664. * @param scene Define the scene the texture should be created in
  29665. * @param stream Define the stream the texture should be created from
  29666. * @returns The created video texture as a promise
  29667. */
  29668. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29669. /**
  29670. * Creates a video texture straight from your WebCam video feed.
  29671. * @param scene Define the scene the texture should be created in
  29672. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29673. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29674. * @returns The created video texture as a promise
  29675. */
  29676. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29677. minWidth: number;
  29678. maxWidth: number;
  29679. minHeight: number;
  29680. maxHeight: number;
  29681. deviceId: string;
  29682. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29683. /**
  29684. * Creates a video texture straight from your WebCam video feed.
  29685. * @param scene Define the scene the texture should be created in
  29686. * @param onReady Define a callback to triggered once the texture will be ready
  29687. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29688. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29689. */
  29690. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29691. minWidth: number;
  29692. maxWidth: number;
  29693. minHeight: number;
  29694. maxHeight: number;
  29695. deviceId: string;
  29696. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29697. }
  29698. }
  29699. declare module "babylonjs/Engines/thinEngine" {
  29700. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29701. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  29702. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29703. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29704. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  29705. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29706. import { Observable } from "babylonjs/Misc/observable";
  29707. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  29708. import { StencilState } from "babylonjs/States/stencilState";
  29709. import { AlphaState } from "babylonjs/States/alphaCullingState";
  29710. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29711. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29712. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29713. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29714. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29715. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29716. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29717. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29718. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  29719. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29720. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29721. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29722. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  29723. /**
  29724. * Defines the interface used by objects working like Scene
  29725. * @hidden
  29726. */
  29727. interface ISceneLike {
  29728. _addPendingData(data: any): void;
  29729. _removePendingData(data: any): void;
  29730. offlineProvider: IOfflineProvider;
  29731. }
  29732. /** Interface defining initialization parameters for Engine class */
  29733. export interface EngineOptions extends WebGLContextAttributes {
  29734. /**
  29735. * Defines if the engine should no exceed a specified device ratio
  29736. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29737. */
  29738. limitDeviceRatio?: number;
  29739. /**
  29740. * Defines if webvr should be enabled automatically
  29741. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29742. */
  29743. autoEnableWebVR?: boolean;
  29744. /**
  29745. * Defines if webgl2 should be turned off even if supported
  29746. * @see http://doc.babylonjs.com/features/webgl2
  29747. */
  29748. disableWebGL2Support?: boolean;
  29749. /**
  29750. * Defines if webaudio should be initialized as well
  29751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29752. */
  29753. audioEngine?: boolean;
  29754. /**
  29755. * Defines if animations should run using a deterministic lock step
  29756. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29757. */
  29758. deterministicLockstep?: boolean;
  29759. /** Defines the maximum steps to use with deterministic lock step mode */
  29760. lockstepMaxSteps?: number;
  29761. /**
  29762. * Defines that engine should ignore context lost events
  29763. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29764. */
  29765. doNotHandleContextLost?: boolean;
  29766. /**
  29767. * Defines that engine should ignore modifying touch action attribute and style
  29768. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29769. */
  29770. doNotHandleTouchAction?: boolean;
  29771. /**
  29772. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29773. */
  29774. useHighPrecisionFloats?: boolean;
  29775. }
  29776. /**
  29777. * The base engine class (root of all engines)
  29778. */
  29779. export class ThinEngine {
  29780. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29781. static ExceptionList: ({
  29782. key: string;
  29783. capture: string;
  29784. captureConstraint: number;
  29785. targets: string[];
  29786. } | {
  29787. key: string;
  29788. capture: null;
  29789. captureConstraint: null;
  29790. targets: string[];
  29791. })[];
  29792. /** @hidden */
  29793. static _TextureLoaders: IInternalTextureLoader[];
  29794. /**
  29795. * Returns the current npm package of the sdk
  29796. */
  29797. static readonly NpmPackage: string;
  29798. /**
  29799. * Returns the current version of the framework
  29800. */
  29801. static readonly Version: string;
  29802. /**
  29803. * Returns a string describing the current engine
  29804. */
  29805. readonly description: string;
  29806. /**
  29807. * Gets or sets the epsilon value used by collision engine
  29808. */
  29809. static CollisionsEpsilon: number;
  29810. /**
  29811. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29812. */
  29813. static ShadersRepository: string;
  29814. /** @hidden */
  29815. _shaderProcessor: IShaderProcessor;
  29816. /**
  29817. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29818. */
  29819. forcePOTTextures: boolean;
  29820. /**
  29821. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29822. */
  29823. isFullscreen: boolean;
  29824. /**
  29825. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29826. */
  29827. cullBackFaces: boolean;
  29828. /**
  29829. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29830. */
  29831. renderEvenInBackground: boolean;
  29832. /**
  29833. * Gets or sets a boolean indicating that cache can be kept between frames
  29834. */
  29835. preventCacheWipeBetweenFrames: boolean;
  29836. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29837. validateShaderPrograms: boolean;
  29838. /**
  29839. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29840. */
  29841. disableUniformBuffers: boolean;
  29842. /** @hidden */
  29843. _uniformBuffers: UniformBuffer[];
  29844. /**
  29845. * Gets a boolean indicating that the engine supports uniform buffers
  29846. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29847. */
  29848. readonly supportsUniformBuffers: boolean;
  29849. /** @hidden */
  29850. _gl: WebGLRenderingContext;
  29851. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29852. protected _windowIsBackground: boolean;
  29853. protected _webGLVersion: number;
  29854. protected _highPrecisionShadersAllowed: boolean;
  29855. /** @hidden */
  29856. readonly _shouldUseHighPrecisionShader: boolean;
  29857. /**
  29858. * Gets a boolean indicating that only power of 2 textures are supported
  29859. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29860. */
  29861. readonly needPOTTextures: boolean;
  29862. /** @hidden */
  29863. _badOS: boolean;
  29864. /** @hidden */
  29865. _badDesktopOS: boolean;
  29866. private _hardwareScalingLevel;
  29867. /** @hidden */
  29868. _caps: EngineCapabilities;
  29869. private _isStencilEnable;
  29870. protected _colorWrite: boolean;
  29871. private _glVersion;
  29872. private _glRenderer;
  29873. private _glVendor;
  29874. /** @hidden */
  29875. _videoTextureSupported: boolean;
  29876. protected _renderingQueueLaunched: boolean;
  29877. protected _activeRenderLoops: (() => void)[];
  29878. /**
  29879. * Observable signaled when a context lost event is raised
  29880. */
  29881. onContextLostObservable: Observable<ThinEngine>;
  29882. /**
  29883. * Observable signaled when a context restored event is raised
  29884. */
  29885. onContextRestoredObservable: Observable<ThinEngine>;
  29886. private _onContextLost;
  29887. private _onContextRestored;
  29888. protected _contextWasLost: boolean;
  29889. /** @hidden */
  29890. _doNotHandleContextLost: boolean;
  29891. /**
  29892. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29893. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29894. */
  29895. doNotHandleContextLost: boolean;
  29896. /**
  29897. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29898. */
  29899. disableVertexArrayObjects: boolean;
  29900. /** @hidden */
  29901. protected _depthCullingState: DepthCullingState;
  29902. /** @hidden */
  29903. protected _stencilState: StencilState;
  29904. /** @hidden */
  29905. protected _alphaState: AlphaState;
  29906. /** @hidden */
  29907. _internalTexturesCache: InternalTexture[];
  29908. /** @hidden */
  29909. protected _activeChannel: number;
  29910. private _currentTextureChannel;
  29911. /** @hidden */
  29912. protected _boundTexturesCache: {
  29913. [key: string]: Nullable<InternalTexture>;
  29914. };
  29915. /** @hidden */
  29916. protected _currentEffect: Nullable<Effect>;
  29917. /** @hidden */
  29918. protected _currentProgram: Nullable<WebGLProgram>;
  29919. private _compiledEffects;
  29920. private _vertexAttribArraysEnabled;
  29921. /** @hidden */
  29922. protected _cachedViewport: Nullable<IViewportLike>;
  29923. private _cachedVertexArrayObject;
  29924. /** @hidden */
  29925. protected _cachedVertexBuffers: any;
  29926. /** @hidden */
  29927. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29928. /** @hidden */
  29929. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29930. /** @hidden */
  29931. _currentRenderTarget: Nullable<InternalTexture>;
  29932. private _uintIndicesCurrentlySet;
  29933. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29934. /** @hidden */
  29935. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29936. private _currentBufferPointers;
  29937. private _currentInstanceLocations;
  29938. private _currentInstanceBuffers;
  29939. private _textureUnits;
  29940. /** @hidden */
  29941. _workingCanvas: Nullable<HTMLCanvasElement>;
  29942. /** @hidden */
  29943. _workingContext: Nullable<CanvasRenderingContext2D>;
  29944. /** @hidden */
  29945. _bindedRenderFunction: any;
  29946. private _vaoRecordInProgress;
  29947. private _mustWipeVertexAttributes;
  29948. private _emptyTexture;
  29949. private _emptyCubeTexture;
  29950. private _emptyTexture3D;
  29951. /** @hidden */
  29952. _frameHandler: number;
  29953. private _nextFreeTextureSlots;
  29954. private _maxSimultaneousTextures;
  29955. private _activeRequests;
  29956. protected _texturesSupported: string[];
  29957. /** @hidden */
  29958. _textureFormatInUse: Nullable<string>;
  29959. protected readonly _supportsHardwareTextureRescaling: boolean;
  29960. /**
  29961. * Gets the list of texture formats supported
  29962. */
  29963. readonly texturesSupported: Array<string>;
  29964. /**
  29965. * Gets the list of texture formats in use
  29966. */
  29967. readonly textureFormatInUse: Nullable<string>;
  29968. /**
  29969. * Gets the current viewport
  29970. */
  29971. readonly currentViewport: Nullable<IViewportLike>;
  29972. /**
  29973. * Gets the default empty texture
  29974. */
  29975. readonly emptyTexture: InternalTexture;
  29976. /**
  29977. * Gets the default empty 3D texture
  29978. */
  29979. readonly emptyTexture3D: InternalTexture;
  29980. /**
  29981. * Gets the default empty cube texture
  29982. */
  29983. readonly emptyCubeTexture: InternalTexture;
  29984. /**
  29985. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29986. */
  29987. readonly premultipliedAlpha: boolean;
  29988. /**
  29989. * Observable event triggered before each texture is initialized
  29990. */
  29991. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  29992. /**
  29993. * Creates a new engine
  29994. * @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
  29995. * @param antialias defines enable antialiasing (default: false)
  29996. * @param options defines further options to be sent to the getContext() function
  29997. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29998. */
  29999. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30000. private _rebuildInternalTextures;
  30001. private _rebuildEffects;
  30002. /**
  30003. * Gets a boolean indicating if all created effects are ready
  30004. * @returns true if all effects are ready
  30005. */
  30006. areAllEffectsReady(): boolean;
  30007. protected _rebuildBuffers(): void;
  30008. private _initGLContext;
  30009. /**
  30010. * Gets version of the current webGL context
  30011. */
  30012. readonly webGLVersion: number;
  30013. /**
  30014. * Gets a string idenfifying the name of the class
  30015. * @returns "Engine" string
  30016. */
  30017. getClassName(): string;
  30018. /**
  30019. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30020. */
  30021. readonly isStencilEnable: boolean;
  30022. /** @hidden */
  30023. _prepareWorkingCanvas(): void;
  30024. /**
  30025. * Reset the texture cache to empty state
  30026. */
  30027. resetTextureCache(): void;
  30028. /**
  30029. * Gets an object containing information about the current webGL context
  30030. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30031. */
  30032. getGlInfo(): {
  30033. vendor: string;
  30034. renderer: string;
  30035. version: string;
  30036. };
  30037. /**
  30038. * Defines the hardware scaling level.
  30039. * By default the hardware scaling level is computed from the window device ratio.
  30040. * 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.
  30041. * @param level defines the level to use
  30042. */
  30043. setHardwareScalingLevel(level: number): void;
  30044. /**
  30045. * Gets the current hardware scaling level.
  30046. * By default the hardware scaling level is computed from the window device ratio.
  30047. * 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.
  30048. * @returns a number indicating the current hardware scaling level
  30049. */
  30050. getHardwareScalingLevel(): number;
  30051. /**
  30052. * Gets the list of loaded textures
  30053. * @returns an array containing all loaded textures
  30054. */
  30055. getLoadedTexturesCache(): InternalTexture[];
  30056. /**
  30057. * Gets the object containing all engine capabilities
  30058. * @returns the EngineCapabilities object
  30059. */
  30060. getCaps(): EngineCapabilities;
  30061. /**
  30062. * stop executing a render loop function and remove it from the execution array
  30063. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30064. */
  30065. stopRenderLoop(renderFunction?: () => void): void;
  30066. /** @hidden */
  30067. _renderLoop(): void;
  30068. /**
  30069. * Gets the HTML canvas attached with the current webGL context
  30070. * @returns a HTML canvas
  30071. */
  30072. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30073. /**
  30074. * Gets host window
  30075. * @returns the host window object
  30076. */
  30077. getHostWindow(): Window;
  30078. /**
  30079. * Gets the current render width
  30080. * @param useScreen defines if screen size must be used (or the current render target if any)
  30081. * @returns a number defining the current render width
  30082. */
  30083. getRenderWidth(useScreen?: boolean): number;
  30084. /**
  30085. * Gets the current render height
  30086. * @param useScreen defines if screen size must be used (or the current render target if any)
  30087. * @returns a number defining the current render height
  30088. */
  30089. getRenderHeight(useScreen?: boolean): number;
  30090. /**
  30091. * Can be used to override the current requestAnimationFrame requester.
  30092. * @hidden
  30093. */
  30094. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30095. /**
  30096. * Register and execute a render loop. The engine can have more than one render function
  30097. * @param renderFunction defines the function to continuously execute
  30098. */
  30099. runRenderLoop(renderFunction: () => void): void;
  30100. /**
  30101. * Clear the current render buffer or the current render target (if any is set up)
  30102. * @param color defines the color to use
  30103. * @param backBuffer defines if the back buffer must be cleared
  30104. * @param depth defines if the depth buffer must be cleared
  30105. * @param stencil defines if the stencil buffer must be cleared
  30106. */
  30107. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30108. private _viewportCached;
  30109. /** @hidden */
  30110. _viewport(x: number, y: number, width: number, height: number): void;
  30111. /**
  30112. * Set the WebGL's viewport
  30113. * @param viewport defines the viewport element to be used
  30114. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30115. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30116. */
  30117. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30118. /**
  30119. * Begin a new frame
  30120. */
  30121. beginFrame(): void;
  30122. /**
  30123. * Enf the current frame
  30124. */
  30125. endFrame(): void;
  30126. /**
  30127. * Resize the view according to the canvas' size
  30128. */
  30129. resize(): void;
  30130. /**
  30131. * Force a specific size of the canvas
  30132. * @param width defines the new canvas' width
  30133. * @param height defines the new canvas' height
  30134. */
  30135. setSize(width: number, height: number): void;
  30136. /**
  30137. * Binds the frame buffer to the specified texture.
  30138. * @param texture The texture to render to or null for the default canvas
  30139. * @param faceIndex The face of the texture to render to in case of cube texture
  30140. * @param requiredWidth The width of the target to render to
  30141. * @param requiredHeight The height of the target to render to
  30142. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30143. * @param depthStencilTexture The depth stencil texture to use to render
  30144. * @param lodLevel defines le lod level to bind to the frame buffer
  30145. */
  30146. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30147. /** @hidden */
  30148. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30149. /**
  30150. * Unbind the current render target texture from the webGL context
  30151. * @param texture defines the render target texture to unbind
  30152. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30153. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30154. */
  30155. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30156. /**
  30157. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30158. */
  30159. flushFramebuffer(): void;
  30160. /**
  30161. * Unbind the current render target and bind the default framebuffer
  30162. */
  30163. restoreDefaultFramebuffer(): void;
  30164. private _resetVertexBufferBinding;
  30165. /**
  30166. * Creates a vertex buffer
  30167. * @param data the data for the vertex buffer
  30168. * @returns the new WebGL static buffer
  30169. */
  30170. createVertexBuffer(data: DataArray): DataBuffer;
  30171. private _createVertexBuffer;
  30172. /**
  30173. * Creates a dynamic vertex buffer
  30174. * @param data the data for the dynamic vertex buffer
  30175. * @returns the new WebGL dynamic buffer
  30176. */
  30177. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30178. /**
  30179. * Updates a dynamic vertex buffer.
  30180. * @param vertexBuffer the vertex buffer to update
  30181. * @param data the data used to update the vertex buffer
  30182. * @param byteOffset the byte offset of the data
  30183. * @param byteLength the byte length of the data
  30184. */
  30185. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30186. protected _resetIndexBufferBinding(): void;
  30187. /**
  30188. * Creates a new index buffer
  30189. * @param indices defines the content of the index buffer
  30190. * @param updatable defines if the index buffer must be updatable
  30191. * @returns a new webGL buffer
  30192. */
  30193. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30194. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30195. /**
  30196. * Bind a webGL buffer to the webGL context
  30197. * @param buffer defines the buffer to bind
  30198. */
  30199. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30200. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30201. private bindBuffer;
  30202. /**
  30203. * update the bound buffer with the given data
  30204. * @param data defines the data to update
  30205. */
  30206. updateArrayBuffer(data: Float32Array): void;
  30207. private _vertexAttribPointer;
  30208. private _bindIndexBufferWithCache;
  30209. private _bindVertexBuffersAttributes;
  30210. /**
  30211. * Records a vertex array object
  30212. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30213. * @param vertexBuffers defines the list of vertex buffers to store
  30214. * @param indexBuffer defines the index buffer to store
  30215. * @param effect defines the effect to store
  30216. * @returns the new vertex array object
  30217. */
  30218. recordVertexArrayObject(vertexBuffers: {
  30219. [key: string]: VertexBuffer;
  30220. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30221. /**
  30222. * Bind a specific vertex array object
  30223. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30224. * @param vertexArrayObject defines the vertex array object to bind
  30225. * @param indexBuffer defines the index buffer to bind
  30226. */
  30227. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30228. /**
  30229. * Bind webGl buffers directly to the webGL context
  30230. * @param vertexBuffer defines the vertex buffer to bind
  30231. * @param indexBuffer defines the index buffer to bind
  30232. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30233. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30234. * @param effect defines the effect associated with the vertex buffer
  30235. */
  30236. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30237. private _unbindVertexArrayObject;
  30238. /**
  30239. * Bind a list of vertex buffers to the webGL context
  30240. * @param vertexBuffers defines the list of vertex buffers to bind
  30241. * @param indexBuffer defines the index buffer to bind
  30242. * @param effect defines the effect associated with the vertex buffers
  30243. */
  30244. bindBuffers(vertexBuffers: {
  30245. [key: string]: Nullable<VertexBuffer>;
  30246. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30247. /**
  30248. * Unbind all instance attributes
  30249. */
  30250. unbindInstanceAttributes(): void;
  30251. /**
  30252. * Release and free the memory of a vertex array object
  30253. * @param vao defines the vertex array object to delete
  30254. */
  30255. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30256. /** @hidden */
  30257. _releaseBuffer(buffer: DataBuffer): boolean;
  30258. protected _deleteBuffer(buffer: DataBuffer): void;
  30259. /**
  30260. * Creates a webGL buffer to use with instanciation
  30261. * @param capacity defines the size of the buffer
  30262. * @returns the webGL buffer
  30263. */
  30264. createInstancesBuffer(capacity: number): DataBuffer;
  30265. /**
  30266. * Delete a webGL buffer used with instanciation
  30267. * @param buffer defines the webGL buffer to delete
  30268. */
  30269. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30270. /**
  30271. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30272. * @param instancesBuffer defines the webGL buffer to update and bind
  30273. * @param data defines the data to store in the buffer
  30274. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30275. */
  30276. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30277. /**
  30278. * Apply all cached states (depth, culling, stencil and alpha)
  30279. */
  30280. applyStates(): void;
  30281. /**
  30282. * Send a draw order
  30283. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30284. * @param indexStart defines the starting index
  30285. * @param indexCount defines the number of index to draw
  30286. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30287. */
  30288. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30289. /**
  30290. * Draw a list of points
  30291. * @param verticesStart defines the index of first vertex to draw
  30292. * @param verticesCount defines the count of vertices to draw
  30293. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30294. */
  30295. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30296. /**
  30297. * Draw a list of unindexed primitives
  30298. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30299. * @param verticesStart defines the index of first vertex to draw
  30300. * @param verticesCount defines the count of vertices to draw
  30301. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30302. */
  30303. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30304. /**
  30305. * Draw a list of indexed primitives
  30306. * @param fillMode defines the primitive to use
  30307. * @param indexStart defines the starting index
  30308. * @param indexCount defines the number of index to draw
  30309. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30310. */
  30311. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30312. /**
  30313. * Draw a list of unindexed primitives
  30314. * @param fillMode defines the primitive to use
  30315. * @param verticesStart defines the index of first vertex to draw
  30316. * @param verticesCount defines the count of vertices to draw
  30317. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30318. */
  30319. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30320. private _drawMode;
  30321. /** @hidden */
  30322. protected _reportDrawCall(): void;
  30323. /** @hidden */
  30324. _releaseEffect(effect: Effect): void;
  30325. /** @hidden */
  30326. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30327. /**
  30328. * Create a new effect (used to store vertex/fragment shaders)
  30329. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30330. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30331. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30332. * @param samplers defines an array of string used to represent textures
  30333. * @param defines defines the string containing the defines to use to compile the shaders
  30334. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30335. * @param onCompiled defines a function to call when the effect creation is successful
  30336. * @param onError defines a function to call when the effect creation has failed
  30337. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30338. * @returns the new Effect
  30339. */
  30340. 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;
  30341. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30342. private _compileShader;
  30343. private _compileRawShader;
  30344. /**
  30345. * Directly creates a webGL program
  30346. * @param pipelineContext defines the pipeline context to attach to
  30347. * @param vertexCode defines the vertex shader code to use
  30348. * @param fragmentCode defines the fragment shader code to use
  30349. * @param context defines the webGL context to use (if not set, the current one will be used)
  30350. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30351. * @returns the new webGL program
  30352. */
  30353. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30354. /**
  30355. * Creates a webGL program
  30356. * @param pipelineContext defines the pipeline context to attach to
  30357. * @param vertexCode defines the vertex shader code to use
  30358. * @param fragmentCode defines the fragment shader code to use
  30359. * @param defines defines the string containing the defines to use to compile the shaders
  30360. * @param context defines the webGL context to use (if not set, the current one will be used)
  30361. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30362. * @returns the new webGL program
  30363. */
  30364. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30365. /**
  30366. * Creates a new pipeline context
  30367. * @returns the new pipeline
  30368. */
  30369. createPipelineContext(): IPipelineContext;
  30370. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30371. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30372. /** @hidden */
  30373. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30374. /** @hidden */
  30375. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30376. /** @hidden */
  30377. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30378. /**
  30379. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30380. * @param pipelineContext defines the pipeline context to use
  30381. * @param uniformsNames defines the list of uniform names
  30382. * @returns an array of webGL uniform locations
  30383. */
  30384. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30385. /**
  30386. * Gets the lsit of active attributes for a given webGL program
  30387. * @param pipelineContext defines the pipeline context to use
  30388. * @param attributesNames defines the list of attribute names to get
  30389. * @returns an array of indices indicating the offset of each attribute
  30390. */
  30391. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30392. /**
  30393. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30394. * @param effect defines the effect to activate
  30395. */
  30396. enableEffect(effect: Nullable<Effect>): void;
  30397. /**
  30398. * Set the value of an uniform to an array of int32
  30399. * @param uniform defines the webGL uniform location where to store the value
  30400. * @param array defines the array of int32 to store
  30401. */
  30402. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30403. /**
  30404. * Set the value of an uniform to an array of int32 (stored as vec2)
  30405. * @param uniform defines the webGL uniform location where to store the value
  30406. * @param array defines the array of int32 to store
  30407. */
  30408. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30409. /**
  30410. * Set the value of an uniform to an array of int32 (stored as vec3)
  30411. * @param uniform defines the webGL uniform location where to store the value
  30412. * @param array defines the array of int32 to store
  30413. */
  30414. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30415. /**
  30416. * Set the value of an uniform to an array of int32 (stored as vec4)
  30417. * @param uniform defines the webGL uniform location where to store the value
  30418. * @param array defines the array of int32 to store
  30419. */
  30420. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30421. /**
  30422. * Set the value of an uniform to an array of float32
  30423. * @param uniform defines the webGL uniform location where to store the value
  30424. * @param array defines the array of float32 to store
  30425. */
  30426. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30427. /**
  30428. * Set the value of an uniform to an array of float32 (stored as vec2)
  30429. * @param uniform defines the webGL uniform location where to store the value
  30430. * @param array defines the array of float32 to store
  30431. */
  30432. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30433. /**
  30434. * Set the value of an uniform to an array of float32 (stored as vec3)
  30435. * @param uniform defines the webGL uniform location where to store the value
  30436. * @param array defines the array of float32 to store
  30437. */
  30438. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30439. /**
  30440. * Set the value of an uniform to an array of float32 (stored as vec4)
  30441. * @param uniform defines the webGL uniform location where to store the value
  30442. * @param array defines the array of float32 to store
  30443. */
  30444. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30445. /**
  30446. * Set the value of an uniform to an array of number
  30447. * @param uniform defines the webGL uniform location where to store the value
  30448. * @param array defines the array of number to store
  30449. */
  30450. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30451. /**
  30452. * Set the value of an uniform to an array of number (stored as vec2)
  30453. * @param uniform defines the webGL uniform location where to store the value
  30454. * @param array defines the array of number to store
  30455. */
  30456. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30457. /**
  30458. * Set the value of an uniform to an array of number (stored as vec3)
  30459. * @param uniform defines the webGL uniform location where to store the value
  30460. * @param array defines the array of number to store
  30461. */
  30462. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30463. /**
  30464. * Set the value of an uniform to an array of number (stored as vec4)
  30465. * @param uniform defines the webGL uniform location where to store the value
  30466. * @param array defines the array of number to store
  30467. */
  30468. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30469. /**
  30470. * Set the value of an uniform to an array of float32 (stored as matrices)
  30471. * @param uniform defines the webGL uniform location where to store the value
  30472. * @param matrices defines the array of float32 to store
  30473. */
  30474. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30475. /**
  30476. * Set the value of an uniform to a matrix (3x3)
  30477. * @param uniform defines the webGL uniform location where to store the value
  30478. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30479. */
  30480. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30481. /**
  30482. * Set the value of an uniform to a matrix (2x2)
  30483. * @param uniform defines the webGL uniform location where to store the value
  30484. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30485. */
  30486. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30487. /**
  30488. * Set the value of an uniform to a number (int)
  30489. * @param uniform defines the webGL uniform location where to store the value
  30490. * @param value defines the int number to store
  30491. */
  30492. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30493. /**
  30494. * Set the value of an uniform to a number (float)
  30495. * @param uniform defines the webGL uniform location where to store the value
  30496. * @param value defines the float number to store
  30497. */
  30498. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30499. /**
  30500. * Set the value of an uniform to a vec2
  30501. * @param uniform defines the webGL uniform location where to store the value
  30502. * @param x defines the 1st component of the value
  30503. * @param y defines the 2nd component of the value
  30504. */
  30505. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30506. /**
  30507. * Set the value of an uniform to a vec3
  30508. * @param uniform defines the webGL uniform location where to store the value
  30509. * @param x defines the 1st component of the value
  30510. * @param y defines the 2nd component of the value
  30511. * @param z defines the 3rd component of the value
  30512. */
  30513. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30514. /**
  30515. * Set the value of an uniform to a boolean
  30516. * @param uniform defines the webGL uniform location where to store the value
  30517. * @param bool defines the boolean to store
  30518. */
  30519. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30520. /**
  30521. * Set the value of an uniform to a vec4
  30522. * @param uniform defines the webGL uniform location where to store the value
  30523. * @param x defines the 1st component of the value
  30524. * @param y defines the 2nd component of the value
  30525. * @param z defines the 3rd component of the value
  30526. * @param w defines the 4th component of the value
  30527. */
  30528. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30529. /**
  30530. * Sets a Color4 on a uniform variable
  30531. * @param uniform defines the uniform location
  30532. * @param color4 defines the value to be set
  30533. */
  30534. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30535. /**
  30536. * Gets the depth culling state manager
  30537. */
  30538. readonly depthCullingState: DepthCullingState;
  30539. /**
  30540. * Gets the alpha state manager
  30541. */
  30542. readonly alphaState: AlphaState;
  30543. /**
  30544. * Gets the stencil state manager
  30545. */
  30546. readonly stencilState: StencilState;
  30547. /**
  30548. * Clears the list of texture accessible through engine.
  30549. * This can help preventing texture load conflict due to name collision.
  30550. */
  30551. clearInternalTexturesCache(): void;
  30552. /**
  30553. * Force the entire cache to be cleared
  30554. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30555. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30556. */
  30557. wipeCaches(bruteForce?: boolean): void;
  30558. /** @hidden */
  30559. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30560. min: number;
  30561. mag: number;
  30562. };
  30563. /** @hidden */
  30564. _createTexture(): WebGLTexture;
  30565. /**
  30566. * Usually called from Texture.ts.
  30567. * Passed information to create a WebGLTexture
  30568. * @param urlArg defines a value which contains one of the following:
  30569. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30570. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30571. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30572. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30573. * @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)
  30574. * @param scene needed for loading to the correct scene
  30575. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30576. * @param onLoad optional callback to be called upon successful completion
  30577. * @param onError optional callback to be called upon failure
  30578. * @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
  30579. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30580. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30581. * @param forcedExtension defines the extension to use to pick the right loader
  30582. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30583. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30584. */
  30585. 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;
  30586. /**
  30587. * @hidden
  30588. */
  30589. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30590. /**
  30591. * Creates a raw texture
  30592. * @param data defines the data to store in the texture
  30593. * @param width defines the width of the texture
  30594. * @param height defines the height of the texture
  30595. * @param format defines the format of the data
  30596. * @param generateMipMaps defines if the engine should generate the mip levels
  30597. * @param invertY defines if data must be stored with Y axis inverted
  30598. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30599. * @param compression defines the compression used (null by default)
  30600. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30601. * @returns the raw texture inside an InternalTexture
  30602. */
  30603. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30604. /**
  30605. * Creates a new raw cube texture
  30606. * @param data defines the array of data to use to create each face
  30607. * @param size defines the size of the textures
  30608. * @param format defines the format of the data
  30609. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30610. * @param generateMipMaps defines if the engine should generate the mip levels
  30611. * @param invertY defines if data must be stored with Y axis inverted
  30612. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30613. * @param compression defines the compression used (null by default)
  30614. * @returns the cube texture as an InternalTexture
  30615. */
  30616. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30617. /**
  30618. * Creates a new raw 3D texture
  30619. * @param data defines the data used to create the texture
  30620. * @param width defines the width of the texture
  30621. * @param height defines the height of the texture
  30622. * @param depth defines the depth of the texture
  30623. * @param format defines the format of the texture
  30624. * @param generateMipMaps defines if the engine must generate mip levels
  30625. * @param invertY defines if data must be stored with Y axis inverted
  30626. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30627. * @param compression defines the compressed used (can be null)
  30628. * @param textureType defines the compressed used (can be null)
  30629. * @returns a new raw 3D texture (stored in an InternalTexture)
  30630. */
  30631. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30632. private _unpackFlipYCached;
  30633. /**
  30634. * In case you are sharing the context with other applications, it might
  30635. * be interested to not cache the unpack flip y state to ensure a consistent
  30636. * value would be set.
  30637. */
  30638. enableUnpackFlipYCached: boolean;
  30639. /** @hidden */
  30640. _unpackFlipY(value: boolean): void;
  30641. /** @hidden */
  30642. _getUnpackAlignement(): number;
  30643. /**
  30644. * Update the sampling mode of a given texture
  30645. * @param samplingMode defines the required sampling mode
  30646. * @param texture defines the texture to update
  30647. */
  30648. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30649. /**
  30650. * Updates a depth texture Comparison Mode and Function.
  30651. * If the comparison Function is equal to 0, the mode will be set to none.
  30652. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30653. * @param texture The texture to set the comparison function for
  30654. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30655. */
  30656. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30657. /** @hidden */
  30658. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30659. width: number;
  30660. height: number;
  30661. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30662. /**
  30663. * Creates a depth stencil texture.
  30664. * This is only available in WebGL 2 or with the depth texture extension available.
  30665. * @param size The size of face edge in the texture.
  30666. * @param options The options defining the texture.
  30667. * @returns The texture
  30668. */
  30669. createDepthStencilTexture(size: number | {
  30670. width: number;
  30671. height: number;
  30672. }, options: DepthTextureCreationOptions): InternalTexture;
  30673. /**
  30674. * Creates a depth stencil texture.
  30675. * This is only available in WebGL 2 or with the depth texture extension available.
  30676. * @param size The size of face edge in the texture.
  30677. * @param options The options defining the texture.
  30678. * @returns The texture
  30679. */
  30680. private _createDepthStencilTexture;
  30681. /** @hidden */
  30682. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30683. /** @hidden */
  30684. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30685. /** @hidden */
  30686. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30687. /** @hidden */
  30688. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30689. /**
  30690. * @hidden
  30691. */
  30692. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30693. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30694. private _prepareWebGLTexture;
  30695. /** @hidden */
  30696. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30697. /** @hidden */
  30698. _releaseFramebufferObjects(texture: InternalTexture): void;
  30699. /** @hidden */
  30700. _releaseTexture(texture: InternalTexture): void;
  30701. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30702. protected _setProgram(program: WebGLProgram): void;
  30703. protected _boundUniforms: {
  30704. [key: number]: WebGLUniformLocation;
  30705. };
  30706. /**
  30707. * Binds an effect to the webGL context
  30708. * @param effect defines the effect to bind
  30709. */
  30710. bindSamplers(effect: Effect): void;
  30711. private _activateCurrentTexture;
  30712. /** @hidden */
  30713. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30714. /** @hidden */
  30715. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30716. /**
  30717. * Unbind all textures from the webGL context
  30718. */
  30719. unbindAllTextures(): void;
  30720. /**
  30721. * Sets a texture to the according uniform.
  30722. * @param channel The texture channel
  30723. * @param uniform The uniform to set
  30724. * @param texture The texture to apply
  30725. */
  30726. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30727. private _bindSamplerUniformToChannel;
  30728. private _getTextureWrapMode;
  30729. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30730. /**
  30731. * Sets an array of texture to the webGL context
  30732. * @param channel defines the channel where the texture array must be set
  30733. * @param uniform defines the associated uniform location
  30734. * @param textures defines the array of textures to bind
  30735. */
  30736. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30737. /** @hidden */
  30738. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30739. private _setTextureParameterFloat;
  30740. private _setTextureParameterInteger;
  30741. /**
  30742. * Unbind all vertex attributes from the webGL context
  30743. */
  30744. unbindAllAttributes(): void;
  30745. /**
  30746. * 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
  30747. */
  30748. releaseEffects(): void;
  30749. /**
  30750. * Dispose and release all associated resources
  30751. */
  30752. dispose(): void;
  30753. /**
  30754. * Attach a new callback raised when context lost event is fired
  30755. * @param callback defines the callback to call
  30756. */
  30757. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30758. /**
  30759. * Attach a new callback raised when context restored event is fired
  30760. * @param callback defines the callback to call
  30761. */
  30762. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30763. /**
  30764. * Get the current error code of the webGL context
  30765. * @returns the error code
  30766. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30767. */
  30768. getError(): number;
  30769. private _canRenderToFloatFramebuffer;
  30770. private _canRenderToHalfFloatFramebuffer;
  30771. private _canRenderToFramebuffer;
  30772. /** @hidden */
  30773. _getWebGLTextureType(type: number): number;
  30774. /** @hidden */
  30775. _getInternalFormat(format: number): number;
  30776. /** @hidden */
  30777. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30778. /** @hidden */
  30779. _getRGBAMultiSampleBufferFormat(type: number): number;
  30780. /** @hidden */
  30781. _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;
  30782. /**
  30783. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30784. * @returns true if the engine can be created
  30785. * @ignorenaming
  30786. */
  30787. static isSupported(): boolean;
  30788. /**
  30789. * Find the next highest power of two.
  30790. * @param x Number to start search from.
  30791. * @return Next highest power of two.
  30792. */
  30793. static CeilingPOT(x: number): number;
  30794. /**
  30795. * Find the next lowest power of two.
  30796. * @param x Number to start search from.
  30797. * @return Next lowest power of two.
  30798. */
  30799. static FloorPOT(x: number): number;
  30800. /**
  30801. * Find the nearest power of two.
  30802. * @param x Number to start search from.
  30803. * @return Next nearest power of two.
  30804. */
  30805. static NearestPOT(x: number): number;
  30806. /**
  30807. * Get the closest exponent of two
  30808. * @param value defines the value to approximate
  30809. * @param max defines the maximum value to return
  30810. * @param mode defines how to define the closest value
  30811. * @returns closest exponent of two of the given value
  30812. */
  30813. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30814. /**
  30815. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30816. * @param func - the function to be called
  30817. * @param requester - the object that will request the next frame. Falls back to window.
  30818. * @returns frame number
  30819. */
  30820. static QueueNewFrame(func: () => void, requester?: any): number;
  30821. }
  30822. }
  30823. declare module "babylonjs/Maths/sphericalPolynomial" {
  30824. import { Vector3 } from "babylonjs/Maths/math.vector";
  30825. import { Color3 } from "babylonjs/Maths/math.color";
  30826. /**
  30827. * Class representing spherical harmonics coefficients to the 3rd degree
  30828. */
  30829. export class SphericalHarmonics {
  30830. /**
  30831. * Defines whether or not the harmonics have been prescaled for rendering.
  30832. */
  30833. preScaled: boolean;
  30834. /**
  30835. * The l0,0 coefficients of the spherical harmonics
  30836. */
  30837. l00: Vector3;
  30838. /**
  30839. * The l1,-1 coefficients of the spherical harmonics
  30840. */
  30841. l1_1: Vector3;
  30842. /**
  30843. * The l1,0 coefficients of the spherical harmonics
  30844. */
  30845. l10: Vector3;
  30846. /**
  30847. * The l1,1 coefficients of the spherical harmonics
  30848. */
  30849. l11: Vector3;
  30850. /**
  30851. * The l2,-2 coefficients of the spherical harmonics
  30852. */
  30853. l2_2: Vector3;
  30854. /**
  30855. * The l2,-1 coefficients of the spherical harmonics
  30856. */
  30857. l2_1: Vector3;
  30858. /**
  30859. * The l2,0 coefficients of the spherical harmonics
  30860. */
  30861. l20: Vector3;
  30862. /**
  30863. * The l2,1 coefficients of the spherical harmonics
  30864. */
  30865. l21: Vector3;
  30866. /**
  30867. * The l2,2 coefficients of the spherical harmonics
  30868. */
  30869. l22: Vector3;
  30870. /**
  30871. * Adds a light to the spherical harmonics
  30872. * @param direction the direction of the light
  30873. * @param color the color of the light
  30874. * @param deltaSolidAngle the delta solid angle of the light
  30875. */
  30876. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30877. /**
  30878. * Scales the spherical harmonics by the given amount
  30879. * @param scale the amount to scale
  30880. */
  30881. scaleInPlace(scale: number): void;
  30882. /**
  30883. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30884. *
  30885. * ```
  30886. * E_lm = A_l * L_lm
  30887. * ```
  30888. *
  30889. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30890. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30891. * the scaling factors are given in equation 9.
  30892. */
  30893. convertIncidentRadianceToIrradiance(): void;
  30894. /**
  30895. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30896. *
  30897. * ```
  30898. * L = (1/pi) * E * rho
  30899. * ```
  30900. *
  30901. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30902. */
  30903. convertIrradianceToLambertianRadiance(): void;
  30904. /**
  30905. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30906. * required operations at run time.
  30907. *
  30908. * This is simply done by scaling back the SH with Ylm constants parameter.
  30909. * The trigonometric part being applied by the shader at run time.
  30910. */
  30911. preScaleForRendering(): void;
  30912. /**
  30913. * Constructs a spherical harmonics from an array.
  30914. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30915. * @returns the spherical harmonics
  30916. */
  30917. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30918. /**
  30919. * Gets the spherical harmonics from polynomial
  30920. * @param polynomial the spherical polynomial
  30921. * @returns the spherical harmonics
  30922. */
  30923. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30924. }
  30925. /**
  30926. * Class representing spherical polynomial coefficients to the 3rd degree
  30927. */
  30928. export class SphericalPolynomial {
  30929. private _harmonics;
  30930. /**
  30931. * The spherical harmonics used to create the polynomials.
  30932. */
  30933. readonly preScaledHarmonics: SphericalHarmonics;
  30934. /**
  30935. * The x coefficients of the spherical polynomial
  30936. */
  30937. x: Vector3;
  30938. /**
  30939. * The y coefficients of the spherical polynomial
  30940. */
  30941. y: Vector3;
  30942. /**
  30943. * The z coefficients of the spherical polynomial
  30944. */
  30945. z: Vector3;
  30946. /**
  30947. * The xx coefficients of the spherical polynomial
  30948. */
  30949. xx: Vector3;
  30950. /**
  30951. * The yy coefficients of the spherical polynomial
  30952. */
  30953. yy: Vector3;
  30954. /**
  30955. * The zz coefficients of the spherical polynomial
  30956. */
  30957. zz: Vector3;
  30958. /**
  30959. * The xy coefficients of the spherical polynomial
  30960. */
  30961. xy: Vector3;
  30962. /**
  30963. * The yz coefficients of the spherical polynomial
  30964. */
  30965. yz: Vector3;
  30966. /**
  30967. * The zx coefficients of the spherical polynomial
  30968. */
  30969. zx: Vector3;
  30970. /**
  30971. * Adds an ambient color to the spherical polynomial
  30972. * @param color the color to add
  30973. */
  30974. addAmbient(color: Color3): void;
  30975. /**
  30976. * Scales the spherical polynomial by the given amount
  30977. * @param scale the amount to scale
  30978. */
  30979. scaleInPlace(scale: number): void;
  30980. /**
  30981. * Gets the spherical polynomial from harmonics
  30982. * @param harmonics the spherical harmonics
  30983. * @returns the spherical polynomial
  30984. */
  30985. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30986. /**
  30987. * Constructs a spherical polynomial from an array.
  30988. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30989. * @returns the spherical polynomial
  30990. */
  30991. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30992. }
  30993. }
  30994. declare module "babylonjs/Materials/Textures/internalTexture" {
  30995. import { Observable } from "babylonjs/Misc/observable";
  30996. import { Nullable, int } from "babylonjs/types";
  30997. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30998. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30999. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31000. /**
  31001. * Defines the source of the internal texture
  31002. */
  31003. export enum InternalTextureSource {
  31004. /**
  31005. * The source of the texture data is unknown
  31006. */
  31007. Unknown = 0,
  31008. /**
  31009. * Texture data comes from an URL
  31010. */
  31011. Url = 1,
  31012. /**
  31013. * Texture data is only used for temporary storage
  31014. */
  31015. Temp = 2,
  31016. /**
  31017. * Texture data comes from raw data (ArrayBuffer)
  31018. */
  31019. Raw = 3,
  31020. /**
  31021. * Texture content is dynamic (video or dynamic texture)
  31022. */
  31023. Dynamic = 4,
  31024. /**
  31025. * Texture content is generated by rendering to it
  31026. */
  31027. RenderTarget = 5,
  31028. /**
  31029. * Texture content is part of a multi render target process
  31030. */
  31031. MultiRenderTarget = 6,
  31032. /**
  31033. * Texture data comes from a cube data file
  31034. */
  31035. Cube = 7,
  31036. /**
  31037. * Texture data comes from a raw cube data
  31038. */
  31039. CubeRaw = 8,
  31040. /**
  31041. * Texture data come from a prefiltered cube data file
  31042. */
  31043. CubePrefiltered = 9,
  31044. /**
  31045. * Texture content is raw 3D data
  31046. */
  31047. Raw3D = 10,
  31048. /**
  31049. * Texture content is a depth texture
  31050. */
  31051. Depth = 11,
  31052. /**
  31053. * Texture data comes from a raw cube data encoded with RGBD
  31054. */
  31055. CubeRawRGBD = 12
  31056. }
  31057. /**
  31058. * Class used to store data associated with WebGL texture data for the engine
  31059. * This class should not be used directly
  31060. */
  31061. export class InternalTexture {
  31062. /** @hidden */
  31063. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31064. /**
  31065. * Defines if the texture is ready
  31066. */
  31067. isReady: boolean;
  31068. /**
  31069. * Defines if the texture is a cube texture
  31070. */
  31071. isCube: boolean;
  31072. /**
  31073. * Defines if the texture contains 3D data
  31074. */
  31075. is3D: boolean;
  31076. /**
  31077. * Defines if the texture contains multiview data
  31078. */
  31079. isMultiview: boolean;
  31080. /**
  31081. * Gets the URL used to load this texture
  31082. */
  31083. url: string;
  31084. /**
  31085. * Gets the sampling mode of the texture
  31086. */
  31087. samplingMode: number;
  31088. /**
  31089. * Gets a boolean indicating if the texture needs mipmaps generation
  31090. */
  31091. generateMipMaps: boolean;
  31092. /**
  31093. * Gets the number of samples used by the texture (WebGL2+ only)
  31094. */
  31095. samples: number;
  31096. /**
  31097. * Gets the type of the texture (int, float...)
  31098. */
  31099. type: number;
  31100. /**
  31101. * Gets the format of the texture (RGB, RGBA...)
  31102. */
  31103. format: number;
  31104. /**
  31105. * Observable called when the texture is loaded
  31106. */
  31107. onLoadedObservable: Observable<InternalTexture>;
  31108. /**
  31109. * Gets the width of the texture
  31110. */
  31111. width: number;
  31112. /**
  31113. * Gets the height of the texture
  31114. */
  31115. height: number;
  31116. /**
  31117. * Gets the depth of the texture
  31118. */
  31119. depth: number;
  31120. /**
  31121. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31122. */
  31123. baseWidth: number;
  31124. /**
  31125. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31126. */
  31127. baseHeight: number;
  31128. /**
  31129. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31130. */
  31131. baseDepth: number;
  31132. /**
  31133. * Gets a boolean indicating if the texture is inverted on Y axis
  31134. */
  31135. invertY: boolean;
  31136. /** @hidden */
  31137. _invertVScale: boolean;
  31138. /** @hidden */
  31139. _associatedChannel: number;
  31140. /** @hidden */
  31141. _source: InternalTextureSource;
  31142. /** @hidden */
  31143. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  31144. /** @hidden */
  31145. _bufferView: Nullable<ArrayBufferView>;
  31146. /** @hidden */
  31147. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31148. /** @hidden */
  31149. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31150. /** @hidden */
  31151. _size: number;
  31152. /** @hidden */
  31153. _extension: string;
  31154. /** @hidden */
  31155. _files: Nullable<string[]>;
  31156. /** @hidden */
  31157. _workingCanvas: Nullable<HTMLCanvasElement>;
  31158. /** @hidden */
  31159. _workingContext: Nullable<CanvasRenderingContext2D>;
  31160. /** @hidden */
  31161. _framebuffer: Nullable<WebGLFramebuffer>;
  31162. /** @hidden */
  31163. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31164. /** @hidden */
  31165. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31166. /** @hidden */
  31167. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31168. /** @hidden */
  31169. _attachments: Nullable<number[]>;
  31170. /** @hidden */
  31171. _cachedCoordinatesMode: Nullable<number>;
  31172. /** @hidden */
  31173. _cachedWrapU: Nullable<number>;
  31174. /** @hidden */
  31175. _cachedWrapV: Nullable<number>;
  31176. /** @hidden */
  31177. _cachedWrapR: Nullable<number>;
  31178. /** @hidden */
  31179. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31180. /** @hidden */
  31181. _isDisabled: boolean;
  31182. /** @hidden */
  31183. _compression: Nullable<string>;
  31184. /** @hidden */
  31185. _generateStencilBuffer: boolean;
  31186. /** @hidden */
  31187. _generateDepthBuffer: boolean;
  31188. /** @hidden */
  31189. _comparisonFunction: number;
  31190. /** @hidden */
  31191. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31192. /** @hidden */
  31193. _lodGenerationScale: number;
  31194. /** @hidden */
  31195. _lodGenerationOffset: number;
  31196. /** @hidden */
  31197. _colorTextureArray: Nullable<WebGLTexture>;
  31198. /** @hidden */
  31199. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31200. /** @hidden */
  31201. _lodTextureHigh: Nullable<BaseTexture>;
  31202. /** @hidden */
  31203. _lodTextureMid: Nullable<BaseTexture>;
  31204. /** @hidden */
  31205. _lodTextureLow: Nullable<BaseTexture>;
  31206. /** @hidden */
  31207. _isRGBD: boolean;
  31208. /** @hidden */
  31209. _linearSpecularLOD: boolean;
  31210. /** @hidden */
  31211. _irradianceTexture: Nullable<BaseTexture>;
  31212. /** @hidden */
  31213. _webGLTexture: Nullable<WebGLTexture>;
  31214. /** @hidden */
  31215. _references: number;
  31216. private _engine;
  31217. /**
  31218. * Gets the Engine the texture belongs to.
  31219. * @returns The babylon engine
  31220. */
  31221. getEngine(): ThinEngine;
  31222. /**
  31223. * Gets the data source type of the texture
  31224. */
  31225. readonly source: InternalTextureSource;
  31226. /**
  31227. * Creates a new InternalTexture
  31228. * @param engine defines the engine to use
  31229. * @param source defines the type of data that will be used
  31230. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31231. */
  31232. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31233. /**
  31234. * Increments the number of references (ie. the number of Texture that point to it)
  31235. */
  31236. incrementReferences(): void;
  31237. /**
  31238. * Change the size of the texture (not the size of the content)
  31239. * @param width defines the new width
  31240. * @param height defines the new height
  31241. * @param depth defines the new depth (1 by default)
  31242. */
  31243. updateSize(width: int, height: int, depth?: int): void;
  31244. /** @hidden */
  31245. _rebuild(): void;
  31246. /** @hidden */
  31247. _swapAndDie(target: InternalTexture): void;
  31248. /**
  31249. * Dispose the current allocated resources
  31250. */
  31251. dispose(): void;
  31252. }
  31253. }
  31254. declare module "babylonjs/Audio/analyser" {
  31255. import { Scene } from "babylonjs/scene";
  31256. /**
  31257. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31259. */
  31260. export class Analyser {
  31261. /**
  31262. * Gets or sets the smoothing
  31263. * @ignorenaming
  31264. */
  31265. SMOOTHING: number;
  31266. /**
  31267. * Gets or sets the FFT table size
  31268. * @ignorenaming
  31269. */
  31270. FFT_SIZE: number;
  31271. /**
  31272. * Gets or sets the bar graph amplitude
  31273. * @ignorenaming
  31274. */
  31275. BARGRAPHAMPLITUDE: number;
  31276. /**
  31277. * Gets or sets the position of the debug canvas
  31278. * @ignorenaming
  31279. */
  31280. DEBUGCANVASPOS: {
  31281. x: number;
  31282. y: number;
  31283. };
  31284. /**
  31285. * Gets or sets the debug canvas size
  31286. * @ignorenaming
  31287. */
  31288. DEBUGCANVASSIZE: {
  31289. width: number;
  31290. height: number;
  31291. };
  31292. private _byteFreqs;
  31293. private _byteTime;
  31294. private _floatFreqs;
  31295. private _webAudioAnalyser;
  31296. private _debugCanvas;
  31297. private _debugCanvasContext;
  31298. private _scene;
  31299. private _registerFunc;
  31300. private _audioEngine;
  31301. /**
  31302. * Creates a new analyser
  31303. * @param scene defines hosting scene
  31304. */
  31305. constructor(scene: Scene);
  31306. /**
  31307. * Get the number of data values you will have to play with for the visualization
  31308. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31309. * @returns a number
  31310. */
  31311. getFrequencyBinCount(): number;
  31312. /**
  31313. * Gets the current frequency data as a byte array
  31314. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31315. * @returns a Uint8Array
  31316. */
  31317. getByteFrequencyData(): Uint8Array;
  31318. /**
  31319. * Gets the current waveform as a byte array
  31320. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31321. * @returns a Uint8Array
  31322. */
  31323. getByteTimeDomainData(): Uint8Array;
  31324. /**
  31325. * Gets the current frequency data as a float array
  31326. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31327. * @returns a Float32Array
  31328. */
  31329. getFloatFrequencyData(): Float32Array;
  31330. /**
  31331. * Renders the debug canvas
  31332. */
  31333. drawDebugCanvas(): void;
  31334. /**
  31335. * Stops rendering the debug canvas and removes it
  31336. */
  31337. stopDebugCanvas(): void;
  31338. /**
  31339. * Connects two audio nodes
  31340. * @param inputAudioNode defines first node to connect
  31341. * @param outputAudioNode defines second node to connect
  31342. */
  31343. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31344. /**
  31345. * Releases all associated resources
  31346. */
  31347. dispose(): void;
  31348. }
  31349. }
  31350. declare module "babylonjs/Audio/audioEngine" {
  31351. import { IDisposable } from "babylonjs/scene";
  31352. import { Analyser } from "babylonjs/Audio/analyser";
  31353. import { Nullable } from "babylonjs/types";
  31354. import { Observable } from "babylonjs/Misc/observable";
  31355. /**
  31356. * This represents an audio engine and it is responsible
  31357. * to play, synchronize and analyse sounds throughout the application.
  31358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31359. */
  31360. export interface IAudioEngine extends IDisposable {
  31361. /**
  31362. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31363. */
  31364. readonly canUseWebAudio: boolean;
  31365. /**
  31366. * Gets the current AudioContext if available.
  31367. */
  31368. readonly audioContext: Nullable<AudioContext>;
  31369. /**
  31370. * The master gain node defines the global audio volume of your audio engine.
  31371. */
  31372. readonly masterGain: GainNode;
  31373. /**
  31374. * Gets whether or not mp3 are supported by your browser.
  31375. */
  31376. readonly isMP3supported: boolean;
  31377. /**
  31378. * Gets whether or not ogg are supported by your browser.
  31379. */
  31380. readonly isOGGsupported: boolean;
  31381. /**
  31382. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31383. * @ignoreNaming
  31384. */
  31385. WarnedWebAudioUnsupported: boolean;
  31386. /**
  31387. * Defines if the audio engine relies on a custom unlocked button.
  31388. * In this case, the embedded button will not be displayed.
  31389. */
  31390. useCustomUnlockedButton: boolean;
  31391. /**
  31392. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31393. */
  31394. readonly unlocked: boolean;
  31395. /**
  31396. * Event raised when audio has been unlocked on the browser.
  31397. */
  31398. onAudioUnlockedObservable: Observable<AudioEngine>;
  31399. /**
  31400. * Event raised when audio has been locked on the browser.
  31401. */
  31402. onAudioLockedObservable: Observable<AudioEngine>;
  31403. /**
  31404. * Flags the audio engine in Locked state.
  31405. * This happens due to new browser policies preventing audio to autoplay.
  31406. */
  31407. lock(): void;
  31408. /**
  31409. * Unlocks the audio engine once a user action has been done on the dom.
  31410. * This is helpful to resume play once browser policies have been satisfied.
  31411. */
  31412. unlock(): void;
  31413. }
  31414. /**
  31415. * This represents the default audio engine used in babylon.
  31416. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31418. */
  31419. export class AudioEngine implements IAudioEngine {
  31420. private _audioContext;
  31421. private _audioContextInitialized;
  31422. private _muteButton;
  31423. private _hostElement;
  31424. /**
  31425. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31426. */
  31427. canUseWebAudio: boolean;
  31428. /**
  31429. * The master gain node defines the global audio volume of your audio engine.
  31430. */
  31431. masterGain: GainNode;
  31432. /**
  31433. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31434. * @ignoreNaming
  31435. */
  31436. WarnedWebAudioUnsupported: boolean;
  31437. /**
  31438. * Gets whether or not mp3 are supported by your browser.
  31439. */
  31440. isMP3supported: boolean;
  31441. /**
  31442. * Gets whether or not ogg are supported by your browser.
  31443. */
  31444. isOGGsupported: boolean;
  31445. /**
  31446. * Gets whether audio has been unlocked on the device.
  31447. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31448. * a user interaction has happened.
  31449. */
  31450. unlocked: boolean;
  31451. /**
  31452. * Defines if the audio engine relies on a custom unlocked button.
  31453. * In this case, the embedded button will not be displayed.
  31454. */
  31455. useCustomUnlockedButton: boolean;
  31456. /**
  31457. * Event raised when audio has been unlocked on the browser.
  31458. */
  31459. onAudioUnlockedObservable: Observable<AudioEngine>;
  31460. /**
  31461. * Event raised when audio has been locked on the browser.
  31462. */
  31463. onAudioLockedObservable: Observable<AudioEngine>;
  31464. /**
  31465. * Gets the current AudioContext if available.
  31466. */
  31467. readonly audioContext: Nullable<AudioContext>;
  31468. private _connectedAnalyser;
  31469. /**
  31470. * Instantiates a new audio engine.
  31471. *
  31472. * There should be only one per page as some browsers restrict the number
  31473. * of audio contexts you can create.
  31474. * @param hostElement defines the host element where to display the mute icon if necessary
  31475. */
  31476. constructor(hostElement?: Nullable<HTMLElement>);
  31477. /**
  31478. * Flags the audio engine in Locked state.
  31479. * This happens due to new browser policies preventing audio to autoplay.
  31480. */
  31481. lock(): void;
  31482. /**
  31483. * Unlocks the audio engine once a user action has been done on the dom.
  31484. * This is helpful to resume play once browser policies have been satisfied.
  31485. */
  31486. unlock(): void;
  31487. private _resumeAudioContext;
  31488. private _initializeAudioContext;
  31489. private _tryToRun;
  31490. private _triggerRunningState;
  31491. private _triggerSuspendedState;
  31492. private _displayMuteButton;
  31493. private _moveButtonToTopLeft;
  31494. private _onResize;
  31495. private _hideMuteButton;
  31496. /**
  31497. * Destroy and release the resources associated with the audio ccontext.
  31498. */
  31499. dispose(): void;
  31500. /**
  31501. * Gets the global volume sets on the master gain.
  31502. * @returns the global volume if set or -1 otherwise
  31503. */
  31504. getGlobalVolume(): number;
  31505. /**
  31506. * Sets the global volume of your experience (sets on the master gain).
  31507. * @param newVolume Defines the new global volume of the application
  31508. */
  31509. setGlobalVolume(newVolume: number): void;
  31510. /**
  31511. * Connect the audio engine to an audio analyser allowing some amazing
  31512. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31514. * @param analyser The analyser to connect to the engine
  31515. */
  31516. connectToAnalyser(analyser: Analyser): void;
  31517. }
  31518. }
  31519. declare module "babylonjs/Loading/loadingScreen" {
  31520. /**
  31521. * Interface used to present a loading screen while loading a scene
  31522. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31523. */
  31524. export interface ILoadingScreen {
  31525. /**
  31526. * Function called to display the loading screen
  31527. */
  31528. displayLoadingUI: () => void;
  31529. /**
  31530. * Function called to hide the loading screen
  31531. */
  31532. hideLoadingUI: () => void;
  31533. /**
  31534. * Gets or sets the color to use for the background
  31535. */
  31536. loadingUIBackgroundColor: string;
  31537. /**
  31538. * Gets or sets the text to display while loading
  31539. */
  31540. loadingUIText: string;
  31541. }
  31542. /**
  31543. * Class used for the default loading screen
  31544. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31545. */
  31546. export class DefaultLoadingScreen implements ILoadingScreen {
  31547. private _renderingCanvas;
  31548. private _loadingText;
  31549. private _loadingDivBackgroundColor;
  31550. private _loadingDiv;
  31551. private _loadingTextDiv;
  31552. /** Gets or sets the logo url to use for the default loading screen */
  31553. static DefaultLogoUrl: string;
  31554. /** Gets or sets the spinner url to use for the default loading screen */
  31555. static DefaultSpinnerUrl: string;
  31556. /**
  31557. * Creates a new default loading screen
  31558. * @param _renderingCanvas defines the canvas used to render the scene
  31559. * @param _loadingText defines the default text to display
  31560. * @param _loadingDivBackgroundColor defines the default background color
  31561. */
  31562. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31563. /**
  31564. * Function called to display the loading screen
  31565. */
  31566. displayLoadingUI(): void;
  31567. /**
  31568. * Function called to hide the loading screen
  31569. */
  31570. hideLoadingUI(): void;
  31571. /**
  31572. * Gets or sets the text to display while loading
  31573. */
  31574. loadingUIText: string;
  31575. /**
  31576. * Gets or sets the color to use for the background
  31577. */
  31578. loadingUIBackgroundColor: string;
  31579. private _resizeLoadingUI;
  31580. }
  31581. }
  31582. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31583. /**
  31584. * Interface for any object that can request an animation frame
  31585. */
  31586. export interface ICustomAnimationFrameRequester {
  31587. /**
  31588. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31589. */
  31590. renderFunction?: Function;
  31591. /**
  31592. * Called to request the next frame to render to
  31593. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31594. */
  31595. requestAnimationFrame: Function;
  31596. /**
  31597. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31598. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31599. */
  31600. requestID?: number;
  31601. }
  31602. }
  31603. declare module "babylonjs/Misc/performanceMonitor" {
  31604. /**
  31605. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31606. */
  31607. export class PerformanceMonitor {
  31608. private _enabled;
  31609. private _rollingFrameTime;
  31610. private _lastFrameTimeMs;
  31611. /**
  31612. * constructor
  31613. * @param frameSampleSize The number of samples required to saturate the sliding window
  31614. */
  31615. constructor(frameSampleSize?: number);
  31616. /**
  31617. * Samples current frame
  31618. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31619. */
  31620. sampleFrame(timeMs?: number): void;
  31621. /**
  31622. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31623. */
  31624. readonly averageFrameTime: number;
  31625. /**
  31626. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31627. */
  31628. readonly averageFrameTimeVariance: number;
  31629. /**
  31630. * Returns the frame time of the most recent frame
  31631. */
  31632. readonly instantaneousFrameTime: number;
  31633. /**
  31634. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31635. */
  31636. readonly averageFPS: number;
  31637. /**
  31638. * Returns the average framerate in frames per second using the most recent frame time
  31639. */
  31640. readonly instantaneousFPS: number;
  31641. /**
  31642. * Returns true if enough samples have been taken to completely fill the sliding window
  31643. */
  31644. readonly isSaturated: boolean;
  31645. /**
  31646. * Enables contributions to the sliding window sample set
  31647. */
  31648. enable(): void;
  31649. /**
  31650. * Disables contributions to the sliding window sample set
  31651. * Samples will not be interpolated over the disabled period
  31652. */
  31653. disable(): void;
  31654. /**
  31655. * Returns true if sampling is enabled
  31656. */
  31657. readonly isEnabled: boolean;
  31658. /**
  31659. * Resets performance monitor
  31660. */
  31661. reset(): void;
  31662. }
  31663. /**
  31664. * RollingAverage
  31665. *
  31666. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31667. */
  31668. export class RollingAverage {
  31669. /**
  31670. * Current average
  31671. */
  31672. average: number;
  31673. /**
  31674. * Current variance
  31675. */
  31676. variance: number;
  31677. protected _samples: Array<number>;
  31678. protected _sampleCount: number;
  31679. protected _pos: number;
  31680. protected _m2: number;
  31681. /**
  31682. * constructor
  31683. * @param length The number of samples required to saturate the sliding window
  31684. */
  31685. constructor(length: number);
  31686. /**
  31687. * Adds a sample to the sample set
  31688. * @param v The sample value
  31689. */
  31690. add(v: number): void;
  31691. /**
  31692. * Returns previously added values or null if outside of history or outside the sliding window domain
  31693. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31694. * @return Value previously recorded with add() or null if outside of range
  31695. */
  31696. history(i: number): number;
  31697. /**
  31698. * Returns true if enough samples have been taken to completely fill the sliding window
  31699. * @return true if sample-set saturated
  31700. */
  31701. isSaturated(): boolean;
  31702. /**
  31703. * Resets the rolling average (equivalent to 0 samples taken so far)
  31704. */
  31705. reset(): void;
  31706. /**
  31707. * Wraps a value around the sample range boundaries
  31708. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31709. * @return Wrapped position in sample range
  31710. */
  31711. protected _wrapPosition(i: number): number;
  31712. }
  31713. }
  31714. declare module "babylonjs/Misc/perfCounter" {
  31715. /**
  31716. * This class is used to track a performance counter which is number based.
  31717. * The user has access to many properties which give statistics of different nature.
  31718. *
  31719. * The implementer can track two kinds of Performance Counter: time and count.
  31720. * 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.
  31721. * 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.
  31722. */
  31723. export class PerfCounter {
  31724. /**
  31725. * Gets or sets a global boolean to turn on and off all the counters
  31726. */
  31727. static Enabled: boolean;
  31728. /**
  31729. * Returns the smallest value ever
  31730. */
  31731. readonly min: number;
  31732. /**
  31733. * Returns the biggest value ever
  31734. */
  31735. readonly max: number;
  31736. /**
  31737. * Returns the average value since the performance counter is running
  31738. */
  31739. readonly average: number;
  31740. /**
  31741. * Returns the average value of the last second the counter was monitored
  31742. */
  31743. readonly lastSecAverage: number;
  31744. /**
  31745. * Returns the current value
  31746. */
  31747. readonly current: number;
  31748. /**
  31749. * Gets the accumulated total
  31750. */
  31751. readonly total: number;
  31752. /**
  31753. * Gets the total value count
  31754. */
  31755. readonly count: number;
  31756. /**
  31757. * Creates a new counter
  31758. */
  31759. constructor();
  31760. /**
  31761. * Call this method to start monitoring a new frame.
  31762. * 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.
  31763. */
  31764. fetchNewFrame(): void;
  31765. /**
  31766. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31767. * @param newCount the count value to add to the monitored count
  31768. * @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.
  31769. */
  31770. addCount(newCount: number, fetchResult: boolean): void;
  31771. /**
  31772. * Start monitoring this performance counter
  31773. */
  31774. beginMonitoring(): void;
  31775. /**
  31776. * Compute the time lapsed since the previous beginMonitoring() call.
  31777. * @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
  31778. */
  31779. endMonitoring(newFrame?: boolean): void;
  31780. private _fetchResult;
  31781. private _startMonitoringTime;
  31782. private _min;
  31783. private _max;
  31784. private _average;
  31785. private _current;
  31786. private _totalValueCount;
  31787. private _totalAccumulated;
  31788. private _lastSecAverage;
  31789. private _lastSecAccumulated;
  31790. private _lastSecTime;
  31791. private _lastSecValueCount;
  31792. }
  31793. }
  31794. declare module "babylonjs/Engines/engine" {
  31795. import { Observable } from "babylonjs/Misc/observable";
  31796. import { Nullable, IndicesArray } from "babylonjs/types";
  31797. import { Scene } from "babylonjs/scene";
  31798. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31799. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31800. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31801. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31802. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31803. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31804. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31805. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31806. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31807. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31808. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31809. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31810. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  31811. import { Material } from "babylonjs/Materials/material";
  31812. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31813. /**
  31814. * Defines the interface used by display changed events
  31815. */
  31816. export interface IDisplayChangedEventArgs {
  31817. /** Gets the vrDisplay object (if any) */
  31818. vrDisplay: Nullable<any>;
  31819. /** Gets a boolean indicating if webVR is supported */
  31820. vrSupported: boolean;
  31821. }
  31822. /**
  31823. * Defines the interface used by objects containing a viewport (like a camera)
  31824. */
  31825. interface IViewportOwnerLike {
  31826. /**
  31827. * Gets or sets the viewport
  31828. */
  31829. viewport: IViewportLike;
  31830. }
  31831. /**
  31832. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31833. */
  31834. export class Engine extends ThinEngine {
  31835. /** Defines that alpha blending is disabled */
  31836. static readonly ALPHA_DISABLE: number;
  31837. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31838. static readonly ALPHA_ADD: number;
  31839. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31840. static readonly ALPHA_COMBINE: number;
  31841. /** Defines that alpha blending to DEST - SRC * DEST */
  31842. static readonly ALPHA_SUBTRACT: number;
  31843. /** Defines that alpha blending to SRC * DEST */
  31844. static readonly ALPHA_MULTIPLY: number;
  31845. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31846. static readonly ALPHA_MAXIMIZED: number;
  31847. /** Defines that alpha blending to SRC + DEST */
  31848. static readonly ALPHA_ONEONE: number;
  31849. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31850. static readonly ALPHA_PREMULTIPLIED: number;
  31851. /**
  31852. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31853. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31854. */
  31855. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31856. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31857. static readonly ALPHA_INTERPOLATE: number;
  31858. /**
  31859. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31860. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31861. */
  31862. static readonly ALPHA_SCREENMODE: number;
  31863. /** Defines that the ressource is not delayed*/
  31864. static readonly DELAYLOADSTATE_NONE: number;
  31865. /** Defines that the ressource was successfully delay loaded */
  31866. static readonly DELAYLOADSTATE_LOADED: number;
  31867. /** Defines that the ressource is currently delay loading */
  31868. static readonly DELAYLOADSTATE_LOADING: number;
  31869. /** Defines that the ressource is delayed and has not started loading */
  31870. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31871. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31872. static readonly NEVER: number;
  31873. /** 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 */
  31874. static readonly ALWAYS: number;
  31875. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31876. static readonly LESS: number;
  31877. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31878. static readonly EQUAL: number;
  31879. /** 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 */
  31880. static readonly LEQUAL: number;
  31881. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31882. static readonly GREATER: number;
  31883. /** 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 */
  31884. static readonly GEQUAL: number;
  31885. /** 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 */
  31886. static readonly NOTEQUAL: number;
  31887. /** Passed to stencilOperation to specify that stencil value must be kept */
  31888. static readonly KEEP: number;
  31889. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31890. static readonly REPLACE: number;
  31891. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31892. static readonly INCR: number;
  31893. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31894. static readonly DECR: number;
  31895. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31896. static readonly INVERT: number;
  31897. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31898. static readonly INCR_WRAP: number;
  31899. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31900. static readonly DECR_WRAP: number;
  31901. /** Texture is not repeating outside of 0..1 UVs */
  31902. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31903. /** Texture is repeating outside of 0..1 UVs */
  31904. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31905. /** Texture is repeating and mirrored */
  31906. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31907. /** ALPHA */
  31908. static readonly TEXTUREFORMAT_ALPHA: number;
  31909. /** LUMINANCE */
  31910. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31911. /** LUMINANCE_ALPHA */
  31912. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31913. /** RGB */
  31914. static readonly TEXTUREFORMAT_RGB: number;
  31915. /** RGBA */
  31916. static readonly TEXTUREFORMAT_RGBA: number;
  31917. /** RED */
  31918. static readonly TEXTUREFORMAT_RED: number;
  31919. /** RED (2nd reference) */
  31920. static readonly TEXTUREFORMAT_R: number;
  31921. /** RG */
  31922. static readonly TEXTUREFORMAT_RG: number;
  31923. /** RED_INTEGER */
  31924. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31925. /** RED_INTEGER (2nd reference) */
  31926. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31927. /** RG_INTEGER */
  31928. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31929. /** RGB_INTEGER */
  31930. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31931. /** RGBA_INTEGER */
  31932. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31933. /** UNSIGNED_BYTE */
  31934. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31935. /** UNSIGNED_BYTE (2nd reference) */
  31936. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31937. /** FLOAT */
  31938. static readonly TEXTURETYPE_FLOAT: number;
  31939. /** HALF_FLOAT */
  31940. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31941. /** BYTE */
  31942. static readonly TEXTURETYPE_BYTE: number;
  31943. /** SHORT */
  31944. static readonly TEXTURETYPE_SHORT: number;
  31945. /** UNSIGNED_SHORT */
  31946. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31947. /** INT */
  31948. static readonly TEXTURETYPE_INT: number;
  31949. /** UNSIGNED_INT */
  31950. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31951. /** UNSIGNED_SHORT_4_4_4_4 */
  31952. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31953. /** UNSIGNED_SHORT_5_5_5_1 */
  31954. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31955. /** UNSIGNED_SHORT_5_6_5 */
  31956. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31957. /** UNSIGNED_INT_2_10_10_10_REV */
  31958. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31959. /** UNSIGNED_INT_24_8 */
  31960. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31961. /** UNSIGNED_INT_10F_11F_11F_REV */
  31962. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31963. /** UNSIGNED_INT_5_9_9_9_REV */
  31964. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31965. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31966. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31967. /** nearest is mag = nearest and min = nearest and mip = linear */
  31968. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31969. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31970. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31971. /** Trilinear is mag = linear and min = linear and mip = linear */
  31972. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31973. /** nearest is mag = nearest and min = nearest and mip = linear */
  31974. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31975. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31976. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31977. /** Trilinear is mag = linear and min = linear and mip = linear */
  31978. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31979. /** mag = nearest and min = nearest and mip = nearest */
  31980. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31981. /** mag = nearest and min = linear and mip = nearest */
  31982. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31983. /** mag = nearest and min = linear and mip = linear */
  31984. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31985. /** mag = nearest and min = linear and mip = none */
  31986. static readonly TEXTURE_NEAREST_LINEAR: number;
  31987. /** mag = nearest and min = nearest and mip = none */
  31988. static readonly TEXTURE_NEAREST_NEAREST: number;
  31989. /** mag = linear and min = nearest and mip = nearest */
  31990. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31991. /** mag = linear and min = nearest and mip = linear */
  31992. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31993. /** mag = linear and min = linear and mip = none */
  31994. static readonly TEXTURE_LINEAR_LINEAR: number;
  31995. /** mag = linear and min = nearest and mip = none */
  31996. static readonly TEXTURE_LINEAR_NEAREST: number;
  31997. /** Explicit coordinates mode */
  31998. static readonly TEXTURE_EXPLICIT_MODE: number;
  31999. /** Spherical coordinates mode */
  32000. static readonly TEXTURE_SPHERICAL_MODE: number;
  32001. /** Planar coordinates mode */
  32002. static readonly TEXTURE_PLANAR_MODE: number;
  32003. /** Cubic coordinates mode */
  32004. static readonly TEXTURE_CUBIC_MODE: number;
  32005. /** Projection coordinates mode */
  32006. static readonly TEXTURE_PROJECTION_MODE: number;
  32007. /** Skybox coordinates mode */
  32008. static readonly TEXTURE_SKYBOX_MODE: number;
  32009. /** Inverse Cubic coordinates mode */
  32010. static readonly TEXTURE_INVCUBIC_MODE: number;
  32011. /** Equirectangular coordinates mode */
  32012. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32013. /** Equirectangular Fixed coordinates mode */
  32014. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32015. /** Equirectangular Fixed Mirrored coordinates mode */
  32016. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32017. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32018. static readonly SCALEMODE_FLOOR: number;
  32019. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32020. static readonly SCALEMODE_NEAREST: number;
  32021. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32022. static readonly SCALEMODE_CEILING: number;
  32023. /**
  32024. * Returns the current npm package of the sdk
  32025. */
  32026. static readonly NpmPackage: string;
  32027. /**
  32028. * Returns the current version of the framework
  32029. */
  32030. static readonly Version: string;
  32031. /** Gets the list of created engines */
  32032. static readonly Instances: Engine[];
  32033. /**
  32034. * Gets the latest created engine
  32035. */
  32036. static readonly LastCreatedEngine: Nullable<Engine>;
  32037. /**
  32038. * Gets the latest created scene
  32039. */
  32040. static readonly LastCreatedScene: Nullable<Scene>;
  32041. /**
  32042. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32043. * @param flag defines which part of the materials must be marked as dirty
  32044. * @param predicate defines a predicate used to filter which materials should be affected
  32045. */
  32046. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32047. /**
  32048. * Method called to create the default loading screen.
  32049. * This can be overriden in your own app.
  32050. * @param canvas The rendering canvas element
  32051. * @returns The loading screen
  32052. */
  32053. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32054. /**
  32055. * Method called to create the default rescale post process on each engine.
  32056. */
  32057. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32058. /**
  32059. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32060. **/
  32061. enableOfflineSupport: boolean;
  32062. /**
  32063. * 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)
  32064. **/
  32065. disableManifestCheck: boolean;
  32066. /**
  32067. * Gets the list of created scenes
  32068. */
  32069. scenes: Scene[];
  32070. /**
  32071. * Event raised when a new scene is created
  32072. */
  32073. onNewSceneAddedObservable: Observable<Scene>;
  32074. /**
  32075. * Gets the list of created postprocesses
  32076. */
  32077. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32078. /**
  32079. * Gets a boolean indicating if the pointer is currently locked
  32080. */
  32081. isPointerLock: boolean;
  32082. /**
  32083. * Observable event triggered each time the rendering canvas is resized
  32084. */
  32085. onResizeObservable: Observable<Engine>;
  32086. /**
  32087. * Observable event triggered each time the canvas loses focus
  32088. */
  32089. onCanvasBlurObservable: Observable<Engine>;
  32090. /**
  32091. * Observable event triggered each time the canvas gains focus
  32092. */
  32093. onCanvasFocusObservable: Observable<Engine>;
  32094. /**
  32095. * Observable event triggered each time the canvas receives pointerout event
  32096. */
  32097. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32098. /**
  32099. * Observable raised when the engine begins a new frame
  32100. */
  32101. onBeginFrameObservable: Observable<Engine>;
  32102. /**
  32103. * If set, will be used to request the next animation frame for the render loop
  32104. */
  32105. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32106. /**
  32107. * Observable raised when the engine ends the current frame
  32108. */
  32109. onEndFrameObservable: Observable<Engine>;
  32110. /**
  32111. * Observable raised when the engine is about to compile a shader
  32112. */
  32113. onBeforeShaderCompilationObservable: Observable<Engine>;
  32114. /**
  32115. * Observable raised when the engine has jsut compiled a shader
  32116. */
  32117. onAfterShaderCompilationObservable: Observable<Engine>;
  32118. /**
  32119. * Gets the audio engine
  32120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32121. * @ignorenaming
  32122. */
  32123. static audioEngine: IAudioEngine;
  32124. /**
  32125. * Default AudioEngine factory responsible of creating the Audio Engine.
  32126. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32127. */
  32128. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32129. /**
  32130. * Default offline support factory responsible of creating a tool used to store data locally.
  32131. * By default, this will create a Database object if the workload has been embedded.
  32132. */
  32133. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32134. private _loadingScreen;
  32135. private _pointerLockRequested;
  32136. private _dummyFramebuffer;
  32137. private _rescalePostProcess;
  32138. /** @hidden */
  32139. protected _alphaMode: number;
  32140. /** @hidden */
  32141. protected _alphaEquation: number;
  32142. private _deterministicLockstep;
  32143. private _lockstepMaxSteps;
  32144. protected readonly _supportsHardwareTextureRescaling: boolean;
  32145. private _fps;
  32146. private _deltaTime;
  32147. /** @hidden */
  32148. _drawCalls: PerfCounter;
  32149. /**
  32150. * Turn this value on if you want to pause FPS computation when in background
  32151. */
  32152. disablePerformanceMonitorInBackground: boolean;
  32153. private _performanceMonitor;
  32154. /**
  32155. * Gets the performance monitor attached to this engine
  32156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32157. */
  32158. readonly performanceMonitor: PerformanceMonitor;
  32159. private _onFocus;
  32160. private _onBlur;
  32161. private _onCanvasPointerOut;
  32162. private _onCanvasBlur;
  32163. private _onCanvasFocus;
  32164. private _onFullscreenChange;
  32165. private _onPointerLockChange;
  32166. /**
  32167. * Creates a new engine
  32168. * @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
  32169. * @param antialias defines enable antialiasing (default: false)
  32170. * @param options defines further options to be sent to the getContext() function
  32171. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32172. */
  32173. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32174. /**
  32175. * Gets current aspect ratio
  32176. * @param viewportOwner defines the camera to use to get the aspect ratio
  32177. * @param useScreen defines if screen size must be used (or the current render target if any)
  32178. * @returns a number defining the aspect ratio
  32179. */
  32180. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32181. /**
  32182. * Gets current screen aspect ratio
  32183. * @returns a number defining the aspect ratio
  32184. */
  32185. getScreenAspectRatio(): number;
  32186. /**
  32187. * Gets host document
  32188. * @returns the host document object
  32189. */
  32190. getHostDocument(): Document;
  32191. /**
  32192. * Gets the client rect of the HTML canvas attached with the current webGL context
  32193. * @returns a client rectanglee
  32194. */
  32195. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32196. /**
  32197. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32198. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32199. * @returns true if engine is in deterministic lock step mode
  32200. */
  32201. isDeterministicLockStep(): boolean;
  32202. /**
  32203. * Gets the max steps when engine is running in deterministic lock step
  32204. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32205. * @returns the max steps
  32206. */
  32207. getLockstepMaxSteps(): number;
  32208. /**
  32209. * Force the mipmap generation for the given render target texture
  32210. * @param texture defines the render target texture to use
  32211. */
  32212. generateMipMapsForCubemap(texture: InternalTexture): void;
  32213. /** States */
  32214. /**
  32215. * Set various states to the webGL context
  32216. * @param culling defines backface culling state
  32217. * @param zOffset defines the value to apply to zOffset (0 by default)
  32218. * @param force defines if states must be applied even if cache is up to date
  32219. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32220. */
  32221. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32222. /**
  32223. * Set the z offset to apply to current rendering
  32224. * @param value defines the offset to apply
  32225. */
  32226. setZOffset(value: number): void;
  32227. /**
  32228. * Gets the current value of the zOffset
  32229. * @returns the current zOffset state
  32230. */
  32231. getZOffset(): number;
  32232. /**
  32233. * Enable or disable depth buffering
  32234. * @param enable defines the state to set
  32235. */
  32236. setDepthBuffer(enable: boolean): void;
  32237. /**
  32238. * Gets a boolean indicating if depth writing is enabled
  32239. * @returns the current depth writing state
  32240. */
  32241. getDepthWrite(): boolean;
  32242. /**
  32243. * Enable or disable depth writing
  32244. * @param enable defines the state to set
  32245. */
  32246. setDepthWrite(enable: boolean): void;
  32247. /**
  32248. * Enable or disable color writing
  32249. * @param enable defines the state to set
  32250. */
  32251. setColorWrite(enable: boolean): void;
  32252. /**
  32253. * Gets a boolean indicating if color writing is enabled
  32254. * @returns the current color writing state
  32255. */
  32256. getColorWrite(): boolean;
  32257. /**
  32258. * Sets alpha constants used by some alpha blending modes
  32259. * @param r defines the red component
  32260. * @param g defines the green component
  32261. * @param b defines the blue component
  32262. * @param a defines the alpha component
  32263. */
  32264. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32265. /**
  32266. * Sets the current alpha mode
  32267. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32268. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32269. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32270. */
  32271. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32272. /**
  32273. * Gets the current alpha mode
  32274. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32275. * @returns the current alpha mode
  32276. */
  32277. getAlphaMode(): number;
  32278. /**
  32279. * Sets the current alpha equation
  32280. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32281. */
  32282. setAlphaEquation(equation: number): void;
  32283. /**
  32284. * Gets the current alpha equation.
  32285. * @returns the current alpha equation
  32286. */
  32287. getAlphaEquation(): number;
  32288. /**
  32289. * Gets a boolean indicating if stencil buffer is enabled
  32290. * @returns the current stencil buffer state
  32291. */
  32292. getStencilBuffer(): boolean;
  32293. /**
  32294. * Enable or disable the stencil buffer
  32295. * @param enable defines if the stencil buffer must be enabled or disabled
  32296. */
  32297. setStencilBuffer(enable: boolean): void;
  32298. /**
  32299. * Gets the current stencil mask
  32300. * @returns a number defining the new stencil mask to use
  32301. */
  32302. getStencilMask(): number;
  32303. /**
  32304. * Sets the current stencil mask
  32305. * @param mask defines the new stencil mask to use
  32306. */
  32307. setStencilMask(mask: number): void;
  32308. /**
  32309. * Gets the current stencil function
  32310. * @returns a number defining the stencil function to use
  32311. */
  32312. getStencilFunction(): number;
  32313. /**
  32314. * Gets the current stencil reference value
  32315. * @returns a number defining the stencil reference value to use
  32316. */
  32317. getStencilFunctionReference(): number;
  32318. /**
  32319. * Gets the current stencil mask
  32320. * @returns a number defining the stencil mask to use
  32321. */
  32322. getStencilFunctionMask(): number;
  32323. /**
  32324. * Sets the current stencil function
  32325. * @param stencilFunc defines the new stencil function to use
  32326. */
  32327. setStencilFunction(stencilFunc: number): void;
  32328. /**
  32329. * Sets the current stencil reference
  32330. * @param reference defines the new stencil reference to use
  32331. */
  32332. setStencilFunctionReference(reference: number): void;
  32333. /**
  32334. * Sets the current stencil mask
  32335. * @param mask defines the new stencil mask to use
  32336. */
  32337. setStencilFunctionMask(mask: number): void;
  32338. /**
  32339. * Gets the current stencil operation when stencil fails
  32340. * @returns a number defining stencil operation to use when stencil fails
  32341. */
  32342. getStencilOperationFail(): number;
  32343. /**
  32344. * Gets the current stencil operation when depth fails
  32345. * @returns a number defining stencil operation to use when depth fails
  32346. */
  32347. getStencilOperationDepthFail(): number;
  32348. /**
  32349. * Gets the current stencil operation when stencil passes
  32350. * @returns a number defining stencil operation to use when stencil passes
  32351. */
  32352. getStencilOperationPass(): number;
  32353. /**
  32354. * Sets the stencil operation to use when stencil fails
  32355. * @param operation defines the stencil operation to use when stencil fails
  32356. */
  32357. setStencilOperationFail(operation: number): void;
  32358. /**
  32359. * Sets the stencil operation to use when depth fails
  32360. * @param operation defines the stencil operation to use when depth fails
  32361. */
  32362. setStencilOperationDepthFail(operation: number): void;
  32363. /**
  32364. * Sets the stencil operation to use when stencil passes
  32365. * @param operation defines the stencil operation to use when stencil passes
  32366. */
  32367. setStencilOperationPass(operation: number): void;
  32368. /**
  32369. * Sets a boolean indicating if the dithering state is enabled or disabled
  32370. * @param value defines the dithering state
  32371. */
  32372. setDitheringState(value: boolean): void;
  32373. /**
  32374. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32375. * @param value defines the rasterizer state
  32376. */
  32377. setRasterizerState(value: boolean): void;
  32378. /**
  32379. * Gets the current depth function
  32380. * @returns a number defining the depth function
  32381. */
  32382. getDepthFunction(): Nullable<number>;
  32383. /**
  32384. * Sets the current depth function
  32385. * @param depthFunc defines the function to use
  32386. */
  32387. setDepthFunction(depthFunc: number): void;
  32388. /**
  32389. * Sets the current depth function to GREATER
  32390. */
  32391. setDepthFunctionToGreater(): void;
  32392. /**
  32393. * Sets the current depth function to GEQUAL
  32394. */
  32395. setDepthFunctionToGreaterOrEqual(): void;
  32396. /**
  32397. * Sets the current depth function to LESS
  32398. */
  32399. setDepthFunctionToLess(): void;
  32400. /**
  32401. * Sets the current depth function to LEQUAL
  32402. */
  32403. setDepthFunctionToLessOrEqual(): void;
  32404. private _cachedStencilBuffer;
  32405. private _cachedStencilFunction;
  32406. private _cachedStencilMask;
  32407. private _cachedStencilOperationPass;
  32408. private _cachedStencilOperationFail;
  32409. private _cachedStencilOperationDepthFail;
  32410. private _cachedStencilReference;
  32411. /**
  32412. * Caches the the state of the stencil buffer
  32413. */
  32414. cacheStencilState(): void;
  32415. /**
  32416. * Restores the state of the stencil buffer
  32417. */
  32418. restoreStencilState(): void;
  32419. /**
  32420. * Directly set the WebGL Viewport
  32421. * @param x defines the x coordinate of the viewport (in screen space)
  32422. * @param y defines the y coordinate of the viewport (in screen space)
  32423. * @param width defines the width of the viewport (in screen space)
  32424. * @param height defines the height of the viewport (in screen space)
  32425. * @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
  32426. */
  32427. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32428. /**
  32429. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32430. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32431. * @param y defines the y-coordinate of the corner of the clear rectangle
  32432. * @param width defines the width of the clear rectangle
  32433. * @param height defines the height of the clear rectangle
  32434. * @param clearColor defines the clear color
  32435. */
  32436. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32437. /**
  32438. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32439. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32440. * @param y defines the y-coordinate of the corner of the clear rectangle
  32441. * @param width defines the width of the clear rectangle
  32442. * @param height defines the height of the clear rectangle
  32443. */
  32444. enableScissor(x: number, y: number, width: number, height: number): void;
  32445. /**
  32446. * Disable previously set scissor test rectangle
  32447. */
  32448. disableScissor(): void;
  32449. protected _reportDrawCall(): void;
  32450. /**
  32451. * Initializes a webVR display and starts listening to display change events
  32452. * The onVRDisplayChangedObservable will be notified upon these changes
  32453. * @returns The onVRDisplayChangedObservable
  32454. */
  32455. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32456. /** @hidden */
  32457. _prepareVRComponent(): void;
  32458. /** @hidden */
  32459. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32460. /** @hidden */
  32461. _submitVRFrame(): void;
  32462. /**
  32463. * Call this function to leave webVR mode
  32464. * Will do nothing if webVR is not supported or if there is no webVR device
  32465. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32466. */
  32467. disableVR(): void;
  32468. /**
  32469. * Gets a boolean indicating that the system is in VR mode and is presenting
  32470. * @returns true if VR mode is engaged
  32471. */
  32472. isVRPresenting(): boolean;
  32473. /** @hidden */
  32474. _requestVRFrame(): void;
  32475. /** @hidden */
  32476. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32477. /**
  32478. * Gets the source code of the vertex shader associated with a specific webGL program
  32479. * @param program defines the program to use
  32480. * @returns a string containing the source code of the vertex shader associated with the program
  32481. */
  32482. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32483. /**
  32484. * Gets the source code of the fragment shader associated with a specific webGL program
  32485. * @param program defines the program to use
  32486. * @returns a string containing the source code of the fragment shader associated with the program
  32487. */
  32488. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32489. /**
  32490. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32491. * @param x defines the x coordinate of the rectangle where pixels must be read
  32492. * @param y defines the y coordinate of the rectangle where pixels must be read
  32493. * @param width defines the width of the rectangle where pixels must be read
  32494. * @param height defines the height of the rectangle where pixels must be read
  32495. * @returns a Uint8Array containing RGBA colors
  32496. */
  32497. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32498. /**
  32499. * Sets a depth stencil texture from a render target to the according uniform.
  32500. * @param channel The texture channel
  32501. * @param uniform The uniform to set
  32502. * @param texture The render target texture containing the depth stencil texture to apply
  32503. */
  32504. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32505. /**
  32506. * Sets a texture to the webGL context from a postprocess
  32507. * @param channel defines the channel to use
  32508. * @param postProcess defines the source postprocess
  32509. */
  32510. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32511. /**
  32512. * Binds the output of the passed in post process to the texture channel specified
  32513. * @param channel The channel the texture should be bound to
  32514. * @param postProcess The post process which's output should be bound
  32515. */
  32516. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32517. /** @hidden */
  32518. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32519. protected _rebuildBuffers(): void;
  32520. _renderLoop(): void;
  32521. /**
  32522. * Toggle full screen mode
  32523. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32524. */
  32525. switchFullscreen(requestPointerLock: boolean): void;
  32526. /**
  32527. * Enters full screen mode
  32528. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32529. */
  32530. enterFullscreen(requestPointerLock: boolean): void;
  32531. /**
  32532. * Exits full screen mode
  32533. */
  32534. exitFullscreen(): void;
  32535. /**
  32536. * Enters Pointerlock mode
  32537. */
  32538. enterPointerlock(): void;
  32539. /**
  32540. * Exits Pointerlock mode
  32541. */
  32542. exitPointerlock(): void;
  32543. /**
  32544. * Begin a new frame
  32545. */
  32546. beginFrame(): void;
  32547. /**
  32548. * Enf the current frame
  32549. */
  32550. endFrame(): void;
  32551. resize(): void;
  32552. /**
  32553. * Set the compressed texture format to use, based on the formats you have, and the formats
  32554. * supported by the hardware / browser.
  32555. *
  32556. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32557. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32558. * to API arguments needed to compressed textures. This puts the burden on the container
  32559. * generator to house the arcane code for determining these for current & future formats.
  32560. *
  32561. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32562. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32563. *
  32564. * Note: The result of this call is not taken into account when a texture is base64.
  32565. *
  32566. * @param formatsAvailable defines the list of those format families you have created
  32567. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32568. *
  32569. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32570. * @returns The extension selected.
  32571. */
  32572. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32573. /**
  32574. * Force a specific size of the canvas
  32575. * @param width defines the new canvas' width
  32576. * @param height defines the new canvas' height
  32577. */
  32578. setSize(width: number, height: number): void;
  32579. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32580. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32581. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32582. _releaseTexture(texture: InternalTexture): void;
  32583. /**
  32584. * @hidden
  32585. * Rescales a texture
  32586. * @param source input texutre
  32587. * @param destination destination texture
  32588. * @param scene scene to use to render the resize
  32589. * @param internalFormat format to use when resizing
  32590. * @param onComplete callback to be called when resize has completed
  32591. */
  32592. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32593. /**
  32594. * Gets the current framerate
  32595. * @returns a number representing the framerate
  32596. */
  32597. getFps(): number;
  32598. /**
  32599. * Gets the time spent between current and previous frame
  32600. * @returns a number representing the delta time in ms
  32601. */
  32602. getDeltaTime(): number;
  32603. private _measureFps;
  32604. /**
  32605. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32606. * @param renderTarget The render target to set the frame buffer for
  32607. */
  32608. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32609. /**
  32610. * Update a dynamic index buffer
  32611. * @param indexBuffer defines the target index buffer
  32612. * @param indices defines the data to update
  32613. * @param offset defines the offset in the target index buffer where update should start
  32614. */
  32615. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32616. /**
  32617. * Updates the sample count of a render target texture
  32618. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32619. * @param texture defines the texture to update
  32620. * @param samples defines the sample count to set
  32621. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32622. */
  32623. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32624. /** @hidden */
  32625. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32626. dispose(): void;
  32627. private _disableTouchAction;
  32628. /**
  32629. * Display the loading screen
  32630. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32631. */
  32632. displayLoadingUI(): void;
  32633. /**
  32634. * Hide the loading screen
  32635. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32636. */
  32637. hideLoadingUI(): void;
  32638. /**
  32639. * Gets the current loading screen object
  32640. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32641. */
  32642. /**
  32643. * Sets the current loading screen object
  32644. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32645. */
  32646. loadingScreen: ILoadingScreen;
  32647. /**
  32648. * Sets the current loading screen text
  32649. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32650. */
  32651. loadingUIText: string;
  32652. /**
  32653. * Sets the current loading screen background color
  32654. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32655. */
  32656. loadingUIBackgroundColor: string;
  32657. /** Pointerlock and fullscreen */
  32658. /**
  32659. * Ask the browser to promote the current element to pointerlock mode
  32660. * @param element defines the DOM element to promote
  32661. */
  32662. static _RequestPointerlock(element: HTMLElement): void;
  32663. /**
  32664. * Asks the browser to exit pointerlock mode
  32665. */
  32666. static _ExitPointerlock(): void;
  32667. /**
  32668. * Ask the browser to promote the current element to fullscreen rendering mode
  32669. * @param element defines the DOM element to promote
  32670. */
  32671. static _RequestFullscreen(element: HTMLElement): void;
  32672. /**
  32673. * Asks the browser to exit fullscreen mode
  32674. */
  32675. static _ExitFullscreen(): void;
  32676. }
  32677. }
  32678. declare module "babylonjs/Engines/engineStore" {
  32679. import { Nullable } from "babylonjs/types";
  32680. import { Engine } from "babylonjs/Engines/engine";
  32681. import { Scene } from "babylonjs/scene";
  32682. /**
  32683. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32684. * during the life time of the application.
  32685. */
  32686. export class EngineStore {
  32687. /** Gets the list of created engines */
  32688. static Instances: import("babylonjs/Engines/engine").Engine[];
  32689. /** @hidden */
  32690. static _LastCreatedScene: Nullable<Scene>;
  32691. /**
  32692. * Gets the latest created engine
  32693. */
  32694. static readonly LastCreatedEngine: Nullable<Engine>;
  32695. /**
  32696. * Gets the latest created scene
  32697. */
  32698. static readonly LastCreatedScene: Nullable<Scene>;
  32699. /**
  32700. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32701. * @ignorenaming
  32702. */
  32703. static UseFallbackTexture: boolean;
  32704. /**
  32705. * Texture content used if a texture cannot loaded
  32706. * @ignorenaming
  32707. */
  32708. static FallbackTexture: string;
  32709. }
  32710. }
  32711. declare module "babylonjs/Misc/promise" {
  32712. /**
  32713. * Helper class that provides a small promise polyfill
  32714. */
  32715. export class PromisePolyfill {
  32716. /**
  32717. * Static function used to check if the polyfill is required
  32718. * If this is the case then the function will inject the polyfill to window.Promise
  32719. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32720. */
  32721. static Apply(force?: boolean): void;
  32722. }
  32723. }
  32724. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32725. /**
  32726. * Interface for screenshot methods with describe argument called `size` as object with options
  32727. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32728. */
  32729. export interface IScreenshotSize {
  32730. /**
  32731. * number in pixels for canvas height
  32732. */
  32733. height?: number;
  32734. /**
  32735. * multiplier allowing render at a higher or lower resolution
  32736. * If value is defined then height and width will be ignored and taken from camera
  32737. */
  32738. precision?: number;
  32739. /**
  32740. * number in pixels for canvas width
  32741. */
  32742. width?: number;
  32743. }
  32744. }
  32745. declare module "babylonjs/Misc/tools" {
  32746. import { Nullable, float } from "babylonjs/types";
  32747. import { DomManagement } from "babylonjs/Misc/domManagement";
  32748. import { WebRequest } from "babylonjs/Misc/webRequest";
  32749. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32750. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32751. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32752. import { Camera } from "babylonjs/Cameras/camera";
  32753. import { Engine } from "babylonjs/Engines/engine";
  32754. interface IColor4Like {
  32755. r: float;
  32756. g: float;
  32757. b: float;
  32758. a: float;
  32759. }
  32760. /**
  32761. * Class containing a set of static utilities functions
  32762. */
  32763. export class Tools {
  32764. /**
  32765. * Gets or sets the base URL to use to load assets
  32766. */
  32767. static BaseUrl: string;
  32768. /**
  32769. * Enable/Disable Custom HTTP Request Headers globally.
  32770. * default = false
  32771. * @see CustomRequestHeaders
  32772. */
  32773. static UseCustomRequestHeaders: boolean;
  32774. /**
  32775. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32776. * i.e. when loading files, where the server/service expects an Authorization header
  32777. */
  32778. static CustomRequestHeaders: {
  32779. [key: string]: string;
  32780. };
  32781. /**
  32782. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32783. */
  32784. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32785. /**
  32786. * Default behaviour for cors in the application.
  32787. * It can be a string if the expected behavior is identical in the entire app.
  32788. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32789. */
  32790. static CorsBehavior: string | ((url: string | string[]) => string);
  32791. /**
  32792. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32793. * @ignorenaming
  32794. */
  32795. static UseFallbackTexture: boolean;
  32796. /**
  32797. * Use this object to register external classes like custom textures or material
  32798. * to allow the laoders to instantiate them
  32799. */
  32800. static RegisteredExternalClasses: {
  32801. [key: string]: Object;
  32802. };
  32803. /**
  32804. * Texture content used if a texture cannot loaded
  32805. * @ignorenaming
  32806. */
  32807. static fallbackTexture: string;
  32808. /**
  32809. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32810. * @param u defines the coordinate on X axis
  32811. * @param v defines the coordinate on Y axis
  32812. * @param width defines the width of the source data
  32813. * @param height defines the height of the source data
  32814. * @param pixels defines the source byte array
  32815. * @param color defines the output color
  32816. */
  32817. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32818. /**
  32819. * Interpolates between a and b via alpha
  32820. * @param a The lower value (returned when alpha = 0)
  32821. * @param b The upper value (returned when alpha = 1)
  32822. * @param alpha The interpolation-factor
  32823. * @return The mixed value
  32824. */
  32825. static Mix(a: number, b: number, alpha: number): number;
  32826. /**
  32827. * Tries to instantiate a new object from a given class name
  32828. * @param className defines the class name to instantiate
  32829. * @returns the new object or null if the system was not able to do the instantiation
  32830. */
  32831. static Instantiate(className: string): any;
  32832. /**
  32833. * Provides a slice function that will work even on IE
  32834. * @param data defines the array to slice
  32835. * @param start defines the start of the data (optional)
  32836. * @param end defines the end of the data (optional)
  32837. * @returns the new sliced array
  32838. */
  32839. static Slice<T>(data: T, start?: number, end?: number): T;
  32840. /**
  32841. * Polyfill for setImmediate
  32842. * @param action defines the action to execute after the current execution block
  32843. */
  32844. static SetImmediate(action: () => void): void;
  32845. /**
  32846. * Function indicating if a number is an exponent of 2
  32847. * @param value defines the value to test
  32848. * @returns true if the value is an exponent of 2
  32849. */
  32850. static IsExponentOfTwo(value: number): boolean;
  32851. private static _tmpFloatArray;
  32852. /**
  32853. * Returns the nearest 32-bit single precision float representation of a Number
  32854. * @param value A Number. If the parameter is of a different type, it will get converted
  32855. * to a number or to NaN if it cannot be converted
  32856. * @returns number
  32857. */
  32858. static FloatRound(value: number): number;
  32859. /**
  32860. * Extracts the filename from a path
  32861. * @param path defines the path to use
  32862. * @returns the filename
  32863. */
  32864. static GetFilename(path: string): string;
  32865. /**
  32866. * Extracts the "folder" part of a path (everything before the filename).
  32867. * @param uri The URI to extract the info from
  32868. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32869. * @returns The "folder" part of the path
  32870. */
  32871. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32872. /**
  32873. * Extracts text content from a DOM element hierarchy
  32874. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32875. */
  32876. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32877. /**
  32878. * Convert an angle in radians to degrees
  32879. * @param angle defines the angle to convert
  32880. * @returns the angle in degrees
  32881. */
  32882. static ToDegrees(angle: number): number;
  32883. /**
  32884. * Convert an angle in degrees to radians
  32885. * @param angle defines the angle to convert
  32886. * @returns the angle in radians
  32887. */
  32888. static ToRadians(angle: number): number;
  32889. /**
  32890. * Encode a buffer to a base64 string
  32891. * @param buffer defines the buffer to encode
  32892. * @returns the encoded string
  32893. */
  32894. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32895. /**
  32896. * Returns an array if obj is not an array
  32897. * @param obj defines the object to evaluate as an array
  32898. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32899. * @returns either obj directly if obj is an array or a new array containing obj
  32900. */
  32901. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32902. /**
  32903. * Gets the pointer prefix to use
  32904. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32905. */
  32906. static GetPointerPrefix(): string;
  32907. /**
  32908. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32909. * @param url define the url we are trying
  32910. * @param element define the dom element where to configure the cors policy
  32911. */
  32912. static SetCorsBehavior(url: string | string[], element: {
  32913. crossOrigin: string | null;
  32914. }): void;
  32915. /**
  32916. * Removes unwanted characters from an url
  32917. * @param url defines the url to clean
  32918. * @returns the cleaned url
  32919. */
  32920. static CleanUrl(url: string): string;
  32921. /**
  32922. * Gets or sets a function used to pre-process url before using them to load assets
  32923. */
  32924. static PreprocessUrl: (url: string) => string;
  32925. /**
  32926. * Loads an image as an HTMLImageElement.
  32927. * @param input url string, ArrayBuffer, or Blob to load
  32928. * @param onLoad callback called when the image successfully loads
  32929. * @param onError callback called when the image fails to load
  32930. * @param offlineProvider offline provider for caching
  32931. * @returns the HTMLImageElement of the loaded image
  32932. */
  32933. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32934. /**
  32935. * Loads a file
  32936. * @param url url string, ArrayBuffer, or Blob to load
  32937. * @param onSuccess callback called when the file successfully loads
  32938. * @param onProgress callback called while file is loading (if the server supports this mode)
  32939. * @param offlineProvider defines the offline provider for caching
  32940. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32941. * @param onError callback called when the file fails to load
  32942. * @returns a file request object
  32943. */
  32944. 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;
  32945. /**
  32946. * Loads a file from a url
  32947. * @param url the file url to load
  32948. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32949. */
  32950. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32951. /**
  32952. * Load a script (identified by an url). When the url returns, the
  32953. * content of this file is added into a new script element, attached to the DOM (body element)
  32954. * @param scriptUrl defines the url of the script to laod
  32955. * @param onSuccess defines the callback called when the script is loaded
  32956. * @param onError defines the callback to call if an error occurs
  32957. * @param scriptId defines the id of the script element
  32958. */
  32959. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32960. /**
  32961. * Load an asynchronous script (identified by an url). When the url returns, the
  32962. * content of this file is added into a new script element, attached to the DOM (body element)
  32963. * @param scriptUrl defines the url of the script to laod
  32964. * @param scriptId defines the id of the script element
  32965. * @returns a promise request object
  32966. */
  32967. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32968. /**
  32969. * Loads a file from a blob
  32970. * @param fileToLoad defines the blob to use
  32971. * @param callback defines the callback to call when data is loaded
  32972. * @param progressCallback defines the callback to call during loading process
  32973. * @returns a file request object
  32974. */
  32975. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32976. /**
  32977. * Loads a file
  32978. * @param fileToLoad defines the file to load
  32979. * @param callback defines the callback to call when data is loaded
  32980. * @param progressCallBack defines the callback to call during loading process
  32981. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32982. * @returns a file request object
  32983. */
  32984. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32985. /**
  32986. * Creates a data url from a given string content
  32987. * @param content defines the content to convert
  32988. * @returns the new data url link
  32989. */
  32990. static FileAsURL(content: string): string;
  32991. /**
  32992. * Format the given number to a specific decimal format
  32993. * @param value defines the number to format
  32994. * @param decimals defines the number of decimals to use
  32995. * @returns the formatted string
  32996. */
  32997. static Format(value: number, decimals?: number): string;
  32998. /**
  32999. * Tries to copy an object by duplicating every property
  33000. * @param source defines the source object
  33001. * @param destination defines the target object
  33002. * @param doNotCopyList defines a list of properties to avoid
  33003. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33004. */
  33005. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33006. /**
  33007. * Gets a boolean indicating if the given object has no own property
  33008. * @param obj defines the object to test
  33009. * @returns true if object has no own property
  33010. */
  33011. static IsEmpty(obj: any): boolean;
  33012. /**
  33013. * Function used to register events at window level
  33014. * @param windowElement defines the Window object to use
  33015. * @param events defines the events to register
  33016. */
  33017. static RegisterTopRootEvents(windowElement: Window, events: {
  33018. name: string;
  33019. handler: Nullable<(e: FocusEvent) => any>;
  33020. }[]): void;
  33021. /**
  33022. * Function used to unregister events from window level
  33023. * @param windowElement defines the Window object to use
  33024. * @param events defines the events to unregister
  33025. */
  33026. static UnregisterTopRootEvents(windowElement: Window, events: {
  33027. name: string;
  33028. handler: Nullable<(e: FocusEvent) => any>;
  33029. }[]): void;
  33030. /**
  33031. * @ignore
  33032. */
  33033. static _ScreenshotCanvas: HTMLCanvasElement;
  33034. /**
  33035. * Dumps the current bound framebuffer
  33036. * @param width defines the rendering width
  33037. * @param height defines the rendering height
  33038. * @param engine defines the hosting engine
  33039. * @param successCallback defines the callback triggered once the data are available
  33040. * @param mimeType defines the mime type of the result
  33041. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33042. */
  33043. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33044. /**
  33045. * Converts the canvas data to blob.
  33046. * This acts as a polyfill for browsers not supporting the to blob function.
  33047. * @param canvas Defines the canvas to extract the data from
  33048. * @param successCallback Defines the callback triggered once the data are available
  33049. * @param mimeType Defines the mime type of the result
  33050. */
  33051. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33052. /**
  33053. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33054. * @param successCallback defines the callback triggered once the data are available
  33055. * @param mimeType defines the mime type of the result
  33056. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33057. */
  33058. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33059. /**
  33060. * Downloads a blob in the browser
  33061. * @param blob defines the blob to download
  33062. * @param fileName defines the name of the downloaded file
  33063. */
  33064. static Download(blob: Blob, fileName: string): void;
  33065. /**
  33066. * Captures a screenshot of the current rendering
  33067. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33068. * @param engine defines the rendering engine
  33069. * @param camera defines the source camera
  33070. * @param size This parameter can be set to a single number or to an object with the
  33071. * following (optional) properties: precision, width, height. If a single number is passed,
  33072. * it will be used for both width and height. If an object is passed, the screenshot size
  33073. * will be derived from the parameters. The precision property is a multiplier allowing
  33074. * rendering at a higher or lower resolution
  33075. * @param successCallback defines the callback receives a single parameter which contains the
  33076. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33077. * src parameter of an <img> to display it
  33078. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33079. * Check your browser for supported MIME types
  33080. */
  33081. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33082. /**
  33083. * Captures a screenshot of the current rendering
  33084. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33085. * @param engine defines the rendering engine
  33086. * @param camera defines the source camera
  33087. * @param size This parameter can be set to a single number or to an object with the
  33088. * following (optional) properties: precision, width, height. If a single number is passed,
  33089. * it will be used for both width and height. If an object is passed, the screenshot size
  33090. * will be derived from the parameters. The precision property is a multiplier allowing
  33091. * rendering at a higher or lower resolution
  33092. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33093. * Check your browser for supported MIME types
  33094. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33095. * to the src parameter of an <img> to display it
  33096. */
  33097. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33098. /**
  33099. * Generates an image screenshot from the specified camera.
  33100. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33101. * @param engine The engine to use for rendering
  33102. * @param camera The camera to use for rendering
  33103. * @param size This parameter can be set to a single number or to an object with the
  33104. * following (optional) properties: precision, width, height. If a single number is passed,
  33105. * it will be used for both width and height. If an object is passed, the screenshot size
  33106. * will be derived from the parameters. The precision property is a multiplier allowing
  33107. * rendering at a higher or lower resolution
  33108. * @param successCallback The callback receives a single parameter which contains the
  33109. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33110. * src parameter of an <img> to display it
  33111. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33112. * Check your browser for supported MIME types
  33113. * @param samples Texture samples (default: 1)
  33114. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33115. * @param fileName A name for for the downloaded file.
  33116. */
  33117. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33118. /**
  33119. * Generates an image screenshot from the specified camera.
  33120. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33121. * @param engine The engine to use for rendering
  33122. * @param camera The camera to use for rendering
  33123. * @param size This parameter can be set to a single number or to an object with the
  33124. * following (optional) properties: precision, width, height. If a single number is passed,
  33125. * it will be used for both width and height. If an object is passed, the screenshot size
  33126. * will be derived from the parameters. The precision property is a multiplier allowing
  33127. * rendering at a higher or lower resolution
  33128. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33129. * Check your browser for supported MIME types
  33130. * @param samples Texture samples (default: 1)
  33131. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33132. * @param fileName A name for for the downloaded file.
  33133. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33134. * to the src parameter of an <img> to display it
  33135. */
  33136. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33137. /**
  33138. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33139. * Be aware Math.random() could cause collisions, but:
  33140. * "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"
  33141. * @returns a pseudo random id
  33142. */
  33143. static RandomId(): string;
  33144. /**
  33145. * Test if the given uri is a base64 string
  33146. * @param uri The uri to test
  33147. * @return True if the uri is a base64 string or false otherwise
  33148. */
  33149. static IsBase64(uri: string): boolean;
  33150. /**
  33151. * Decode the given base64 uri.
  33152. * @param uri The uri to decode
  33153. * @return The decoded base64 data.
  33154. */
  33155. static DecodeBase64(uri: string): ArrayBuffer;
  33156. /**
  33157. * Gets the absolute url.
  33158. * @param url the input url
  33159. * @return the absolute url
  33160. */
  33161. static GetAbsoluteUrl(url: string): string;
  33162. /**
  33163. * No log
  33164. */
  33165. static readonly NoneLogLevel: number;
  33166. /**
  33167. * Only message logs
  33168. */
  33169. static readonly MessageLogLevel: number;
  33170. /**
  33171. * Only warning logs
  33172. */
  33173. static readonly WarningLogLevel: number;
  33174. /**
  33175. * Only error logs
  33176. */
  33177. static readonly ErrorLogLevel: number;
  33178. /**
  33179. * All logs
  33180. */
  33181. static readonly AllLogLevel: number;
  33182. /**
  33183. * Gets a value indicating the number of loading errors
  33184. * @ignorenaming
  33185. */
  33186. static readonly errorsCount: number;
  33187. /**
  33188. * Callback called when a new log is added
  33189. */
  33190. static OnNewCacheEntry: (entry: string) => void;
  33191. /**
  33192. * Log a message to the console
  33193. * @param message defines the message to log
  33194. */
  33195. static Log(message: string): void;
  33196. /**
  33197. * Write a warning message to the console
  33198. * @param message defines the message to log
  33199. */
  33200. static Warn(message: string): void;
  33201. /**
  33202. * Write an error message to the console
  33203. * @param message defines the message to log
  33204. */
  33205. static Error(message: string): void;
  33206. /**
  33207. * Gets current log cache (list of logs)
  33208. */
  33209. static readonly LogCache: string;
  33210. /**
  33211. * Clears the log cache
  33212. */
  33213. static ClearLogCache(): void;
  33214. /**
  33215. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33216. */
  33217. static LogLevels: number;
  33218. /**
  33219. * Checks if the window object exists
  33220. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33221. */
  33222. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33223. /**
  33224. * No performance log
  33225. */
  33226. static readonly PerformanceNoneLogLevel: number;
  33227. /**
  33228. * Use user marks to log performance
  33229. */
  33230. static readonly PerformanceUserMarkLogLevel: number;
  33231. /**
  33232. * Log performance to the console
  33233. */
  33234. static readonly PerformanceConsoleLogLevel: number;
  33235. private static _performance;
  33236. /**
  33237. * Sets the current performance log level
  33238. */
  33239. static PerformanceLogLevel: number;
  33240. private static _StartPerformanceCounterDisabled;
  33241. private static _EndPerformanceCounterDisabled;
  33242. private static _StartUserMark;
  33243. private static _EndUserMark;
  33244. private static _StartPerformanceConsole;
  33245. private static _EndPerformanceConsole;
  33246. /**
  33247. * Starts a performance counter
  33248. */
  33249. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33250. /**
  33251. * Ends a specific performance coutner
  33252. */
  33253. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33254. /**
  33255. * Gets either window.performance.now() if supported or Date.now() else
  33256. */
  33257. static readonly Now: number;
  33258. /**
  33259. * This method will return the name of the class used to create the instance of the given object.
  33260. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33261. * @param object the object to get the class name from
  33262. * @param isType defines if the object is actually a type
  33263. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33264. */
  33265. static GetClassName(object: any, isType?: boolean): string;
  33266. /**
  33267. * Gets the first element of an array satisfying a given predicate
  33268. * @param array defines the array to browse
  33269. * @param predicate defines the predicate to use
  33270. * @returns null if not found or the element
  33271. */
  33272. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33273. /**
  33274. * This method will return the name of the full name of the class, including its owning module (if any).
  33275. * 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).
  33276. * @param object the object to get the class name from
  33277. * @param isType defines if the object is actually a type
  33278. * @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.
  33279. * @ignorenaming
  33280. */
  33281. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33282. /**
  33283. * Returns a promise that resolves after the given amount of time.
  33284. * @param delay Number of milliseconds to delay
  33285. * @returns Promise that resolves after the given amount of time
  33286. */
  33287. static DelayAsync(delay: number): Promise<void>;
  33288. }
  33289. /**
  33290. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33291. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33292. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33293. * @param name The name of the class, case should be preserved
  33294. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33295. */
  33296. export function className(name: string, module?: string): (target: Object) => void;
  33297. /**
  33298. * An implementation of a loop for asynchronous functions.
  33299. */
  33300. export class AsyncLoop {
  33301. /**
  33302. * Defines the number of iterations for the loop
  33303. */
  33304. iterations: number;
  33305. /**
  33306. * Defines the current index of the loop.
  33307. */
  33308. index: number;
  33309. private _done;
  33310. private _fn;
  33311. private _successCallback;
  33312. /**
  33313. * Constructor.
  33314. * @param iterations the number of iterations.
  33315. * @param func the function to run each iteration
  33316. * @param successCallback the callback that will be called upon succesful execution
  33317. * @param offset starting offset.
  33318. */
  33319. constructor(
  33320. /**
  33321. * Defines the number of iterations for the loop
  33322. */
  33323. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33324. /**
  33325. * Execute the next iteration. Must be called after the last iteration was finished.
  33326. */
  33327. executeNext(): void;
  33328. /**
  33329. * Break the loop and run the success callback.
  33330. */
  33331. breakLoop(): void;
  33332. /**
  33333. * Create and run an async loop.
  33334. * @param iterations the number of iterations.
  33335. * @param fn the function to run each iteration
  33336. * @param successCallback the callback that will be called upon succesful execution
  33337. * @param offset starting offset.
  33338. * @returns the created async loop object
  33339. */
  33340. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33341. /**
  33342. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33343. * @param iterations total number of iterations
  33344. * @param syncedIterations number of synchronous iterations in each async iteration.
  33345. * @param fn the function to call each iteration.
  33346. * @param callback a success call back that will be called when iterating stops.
  33347. * @param breakFunction a break condition (optional)
  33348. * @param timeout timeout settings for the setTimeout function. default - 0.
  33349. * @returns the created async loop object
  33350. */
  33351. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33352. }
  33353. }
  33354. declare module "babylonjs/Misc/stringDictionary" {
  33355. import { Nullable } from "babylonjs/types";
  33356. /**
  33357. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33358. * The underlying implementation relies on an associative array to ensure the best performances.
  33359. * The value can be anything including 'null' but except 'undefined'
  33360. */
  33361. export class StringDictionary<T> {
  33362. /**
  33363. * This will clear this dictionary and copy the content from the 'source' one.
  33364. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33365. * @param source the dictionary to take the content from and copy to this dictionary
  33366. */
  33367. copyFrom(source: StringDictionary<T>): void;
  33368. /**
  33369. * Get a value based from its key
  33370. * @param key the given key to get the matching value from
  33371. * @return the value if found, otherwise undefined is returned
  33372. */
  33373. get(key: string): T | undefined;
  33374. /**
  33375. * Get a value from its key or add it if it doesn't exist.
  33376. * This method will ensure you that a given key/data will be present in the dictionary.
  33377. * @param key the given key to get the matching value from
  33378. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33379. * The factory will only be invoked if there's no data for the given key.
  33380. * @return the value corresponding to the key.
  33381. */
  33382. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33383. /**
  33384. * Get a value from its key if present in the dictionary otherwise add it
  33385. * @param key the key to get the value from
  33386. * @param val if there's no such key/value pair in the dictionary add it with this value
  33387. * @return the value corresponding to the key
  33388. */
  33389. getOrAdd(key: string, val: T): T;
  33390. /**
  33391. * Check if there's a given key in the dictionary
  33392. * @param key the key to check for
  33393. * @return true if the key is present, false otherwise
  33394. */
  33395. contains(key: string): boolean;
  33396. /**
  33397. * Add a new key and its corresponding value
  33398. * @param key the key to add
  33399. * @param value the value corresponding to the key
  33400. * @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
  33401. */
  33402. add(key: string, value: T): boolean;
  33403. /**
  33404. * Update a specific value associated to a key
  33405. * @param key defines the key to use
  33406. * @param value defines the value to store
  33407. * @returns true if the value was updated (or false if the key was not found)
  33408. */
  33409. set(key: string, value: T): boolean;
  33410. /**
  33411. * Get the element of the given key and remove it from the dictionary
  33412. * @param key defines the key to search
  33413. * @returns the value associated with the key or null if not found
  33414. */
  33415. getAndRemove(key: string): Nullable<T>;
  33416. /**
  33417. * Remove a key/value from the dictionary.
  33418. * @param key the key to remove
  33419. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33420. */
  33421. remove(key: string): boolean;
  33422. /**
  33423. * Clear the whole content of the dictionary
  33424. */
  33425. clear(): void;
  33426. /**
  33427. * Gets the current count
  33428. */
  33429. readonly count: number;
  33430. /**
  33431. * Execute a callback on each key/val of the dictionary.
  33432. * Note that you can remove any element in this dictionary in the callback implementation
  33433. * @param callback the callback to execute on a given key/value pair
  33434. */
  33435. forEach(callback: (key: string, val: T) => void): void;
  33436. /**
  33437. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33438. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33439. * Note that you can remove any element in this dictionary in the callback implementation
  33440. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33441. * @returns the first item
  33442. */
  33443. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33444. private _count;
  33445. private _data;
  33446. }
  33447. }
  33448. declare module "babylonjs/Collisions/collisionCoordinator" {
  33449. import { Nullable } from "babylonjs/types";
  33450. import { Scene } from "babylonjs/scene";
  33451. import { Vector3 } from "babylonjs/Maths/math.vector";
  33452. import { Collider } from "babylonjs/Collisions/collider";
  33453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33454. /** @hidden */
  33455. export interface ICollisionCoordinator {
  33456. createCollider(): Collider;
  33457. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33458. init(scene: Scene): void;
  33459. }
  33460. /** @hidden */
  33461. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33462. private _scene;
  33463. private _scaledPosition;
  33464. private _scaledVelocity;
  33465. private _finalPosition;
  33466. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33467. createCollider(): Collider;
  33468. init(scene: Scene): void;
  33469. private _collideWithWorld;
  33470. }
  33471. }
  33472. declare module "babylonjs/Inputs/scene.inputManager" {
  33473. import { Nullable } from "babylonjs/types";
  33474. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33475. import { Vector2 } from "babylonjs/Maths/math.vector";
  33476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33477. import { Scene } from "babylonjs/scene";
  33478. /**
  33479. * Class used to manage all inputs for the scene.
  33480. */
  33481. export class InputManager {
  33482. /** The distance in pixel that you have to move to prevent some events */
  33483. static DragMovementThreshold: number;
  33484. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33485. static LongPressDelay: number;
  33486. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33487. static DoubleClickDelay: number;
  33488. /** If you need to check double click without raising a single click at first click, enable this flag */
  33489. static ExclusiveDoubleClickMode: boolean;
  33490. private _wheelEventName;
  33491. private _onPointerMove;
  33492. private _onPointerDown;
  33493. private _onPointerUp;
  33494. private _initClickEvent;
  33495. private _initActionManager;
  33496. private _delayedSimpleClick;
  33497. private _delayedSimpleClickTimeout;
  33498. private _previousDelayedSimpleClickTimeout;
  33499. private _meshPickProceed;
  33500. private _previousButtonPressed;
  33501. private _currentPickResult;
  33502. private _previousPickResult;
  33503. private _totalPointersPressed;
  33504. private _doubleClickOccured;
  33505. private _pointerOverMesh;
  33506. private _pickedDownMesh;
  33507. private _pickedUpMesh;
  33508. private _pointerX;
  33509. private _pointerY;
  33510. private _unTranslatedPointerX;
  33511. private _unTranslatedPointerY;
  33512. private _startingPointerPosition;
  33513. private _previousStartingPointerPosition;
  33514. private _startingPointerTime;
  33515. private _previousStartingPointerTime;
  33516. private _pointerCaptures;
  33517. private _onKeyDown;
  33518. private _onKeyUp;
  33519. private _onCanvasFocusObserver;
  33520. private _onCanvasBlurObserver;
  33521. private _scene;
  33522. /**
  33523. * Creates a new InputManager
  33524. * @param scene defines the hosting scene
  33525. */
  33526. constructor(scene: Scene);
  33527. /**
  33528. * Gets the mesh that is currently under the pointer
  33529. */
  33530. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33531. /**
  33532. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33533. */
  33534. readonly unTranslatedPointer: Vector2;
  33535. /**
  33536. * Gets or sets the current on-screen X position of the pointer
  33537. */
  33538. pointerX: number;
  33539. /**
  33540. * Gets or sets the current on-screen Y position of the pointer
  33541. */
  33542. pointerY: number;
  33543. private _updatePointerPosition;
  33544. private _processPointerMove;
  33545. private _setRayOnPointerInfo;
  33546. private _checkPrePointerObservable;
  33547. /**
  33548. * Use this method to simulate a pointer move on a mesh
  33549. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33550. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33551. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33552. */
  33553. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33554. /**
  33555. * Use this method to simulate a pointer down on a mesh
  33556. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33557. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33558. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33559. */
  33560. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33561. private _processPointerDown;
  33562. /** @hidden */
  33563. _isPointerSwiping(): boolean;
  33564. /**
  33565. * Use this method to simulate a pointer up on a mesh
  33566. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33567. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33568. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33569. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33570. */
  33571. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33572. private _processPointerUp;
  33573. /**
  33574. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33575. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33576. * @returns true if the pointer was captured
  33577. */
  33578. isPointerCaptured(pointerId?: number): boolean;
  33579. /**
  33580. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33581. * @param attachUp defines if you want to attach events to pointerup
  33582. * @param attachDown defines if you want to attach events to pointerdown
  33583. * @param attachMove defines if you want to attach events to pointermove
  33584. */
  33585. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33586. /**
  33587. * Detaches all event handlers
  33588. */
  33589. detachControl(): void;
  33590. /**
  33591. * Force the value of meshUnderPointer
  33592. * @param mesh defines the mesh to use
  33593. */
  33594. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33595. /**
  33596. * Gets the mesh under the pointer
  33597. * @returns a Mesh or null if no mesh is under the pointer
  33598. */
  33599. getPointerOverMesh(): Nullable<AbstractMesh>;
  33600. }
  33601. }
  33602. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33603. /**
  33604. * Helper class used to generate session unique ID
  33605. */
  33606. export class UniqueIdGenerator {
  33607. private static _UniqueIdCounter;
  33608. /**
  33609. * Gets an unique (relatively to the current scene) Id
  33610. */
  33611. static readonly UniqueId: number;
  33612. }
  33613. }
  33614. declare module "babylonjs/Animations/animationGroup" {
  33615. import { Animatable } from "babylonjs/Animations/animatable";
  33616. import { Animation } from "babylonjs/Animations/animation";
  33617. import { Scene, IDisposable } from "babylonjs/scene";
  33618. import { Observable } from "babylonjs/Misc/observable";
  33619. import { Nullable } from "babylonjs/types";
  33620. import "babylonjs/Animations/animatable";
  33621. /**
  33622. * This class defines the direct association between an animation and a target
  33623. */
  33624. export class TargetedAnimation {
  33625. /**
  33626. * Animation to perform
  33627. */
  33628. animation: Animation;
  33629. /**
  33630. * Target to animate
  33631. */
  33632. target: any;
  33633. /**
  33634. * Serialize the object
  33635. * @returns the JSON object representing the current entity
  33636. */
  33637. serialize(): any;
  33638. }
  33639. /**
  33640. * Use this class to create coordinated animations on multiple targets
  33641. */
  33642. export class AnimationGroup implements IDisposable {
  33643. /** The name of the animation group */
  33644. name: string;
  33645. private _scene;
  33646. private _targetedAnimations;
  33647. private _animatables;
  33648. private _from;
  33649. private _to;
  33650. private _isStarted;
  33651. private _isPaused;
  33652. private _speedRatio;
  33653. private _loopAnimation;
  33654. /**
  33655. * Gets or sets the unique id of the node
  33656. */
  33657. uniqueId: number;
  33658. /**
  33659. * This observable will notify when one animation have ended
  33660. */
  33661. onAnimationEndObservable: Observable<TargetedAnimation>;
  33662. /**
  33663. * Observer raised when one animation loops
  33664. */
  33665. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33666. /**
  33667. * This observable will notify when all animations have ended.
  33668. */
  33669. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33670. /**
  33671. * This observable will notify when all animations have paused.
  33672. */
  33673. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33674. /**
  33675. * This observable will notify when all animations are playing.
  33676. */
  33677. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33678. /**
  33679. * Gets the first frame
  33680. */
  33681. readonly from: number;
  33682. /**
  33683. * Gets the last frame
  33684. */
  33685. readonly to: number;
  33686. /**
  33687. * Define if the animations are started
  33688. */
  33689. readonly isStarted: boolean;
  33690. /**
  33691. * Gets a value indicating that the current group is playing
  33692. */
  33693. readonly isPlaying: boolean;
  33694. /**
  33695. * Gets or sets the speed ratio to use for all animations
  33696. */
  33697. /**
  33698. * Gets or sets the speed ratio to use for all animations
  33699. */
  33700. speedRatio: number;
  33701. /**
  33702. * Gets or sets if all animations should loop or not
  33703. */
  33704. loopAnimation: boolean;
  33705. /**
  33706. * Gets the targeted animations for this animation group
  33707. */
  33708. readonly targetedAnimations: Array<TargetedAnimation>;
  33709. /**
  33710. * returning the list of animatables controlled by this animation group.
  33711. */
  33712. readonly animatables: Array<Animatable>;
  33713. /**
  33714. * Instantiates a new Animation Group.
  33715. * This helps managing several animations at once.
  33716. * @see http://doc.babylonjs.com/how_to/group
  33717. * @param name Defines the name of the group
  33718. * @param scene Defines the scene the group belongs to
  33719. */
  33720. constructor(
  33721. /** The name of the animation group */
  33722. name: string, scene?: Nullable<Scene>);
  33723. /**
  33724. * Add an animation (with its target) in the group
  33725. * @param animation defines the animation we want to add
  33726. * @param target defines the target of the animation
  33727. * @returns the TargetedAnimation object
  33728. */
  33729. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33730. /**
  33731. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33732. * It can add constant keys at begin or end
  33733. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33734. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33735. * @returns the animation group
  33736. */
  33737. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33738. /**
  33739. * Start all animations on given targets
  33740. * @param loop defines if animations must loop
  33741. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33742. * @param from defines the from key (optional)
  33743. * @param to defines the to key (optional)
  33744. * @returns the current animation group
  33745. */
  33746. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33747. /**
  33748. * Pause all animations
  33749. * @returns the animation group
  33750. */
  33751. pause(): AnimationGroup;
  33752. /**
  33753. * Play all animations to initial state
  33754. * This function will start() the animations if they were not started or will restart() them if they were paused
  33755. * @param loop defines if animations must loop
  33756. * @returns the animation group
  33757. */
  33758. play(loop?: boolean): AnimationGroup;
  33759. /**
  33760. * Reset all animations to initial state
  33761. * @returns the animation group
  33762. */
  33763. reset(): AnimationGroup;
  33764. /**
  33765. * Restart animations from key 0
  33766. * @returns the animation group
  33767. */
  33768. restart(): AnimationGroup;
  33769. /**
  33770. * Stop all animations
  33771. * @returns the animation group
  33772. */
  33773. stop(): AnimationGroup;
  33774. /**
  33775. * Set animation weight for all animatables
  33776. * @param weight defines the weight to use
  33777. * @return the animationGroup
  33778. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33779. */
  33780. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33781. /**
  33782. * Synchronize and normalize all animatables with a source animatable
  33783. * @param root defines the root animatable to synchronize with
  33784. * @return the animationGroup
  33785. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33786. */
  33787. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33788. /**
  33789. * Goes to a specific frame in this animation group
  33790. * @param frame the frame number to go to
  33791. * @return the animationGroup
  33792. */
  33793. goToFrame(frame: number): AnimationGroup;
  33794. /**
  33795. * Dispose all associated resources
  33796. */
  33797. dispose(): void;
  33798. private _checkAnimationGroupEnded;
  33799. /**
  33800. * Clone the current animation group and returns a copy
  33801. * @param newName defines the name of the new group
  33802. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33803. * @returns the new aniamtion group
  33804. */
  33805. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33806. /**
  33807. * Serializes the animationGroup to an object
  33808. * @returns Serialized object
  33809. */
  33810. serialize(): any;
  33811. /**
  33812. * Returns a new AnimationGroup object parsed from the source provided.
  33813. * @param parsedAnimationGroup defines the source
  33814. * @param scene defines the scene that will receive the animationGroup
  33815. * @returns a new AnimationGroup
  33816. */
  33817. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33818. /**
  33819. * Returns the string "AnimationGroup"
  33820. * @returns "AnimationGroup"
  33821. */
  33822. getClassName(): string;
  33823. /**
  33824. * Creates a detailled string about the object
  33825. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33826. * @returns a string representing the object
  33827. */
  33828. toString(fullDetails?: boolean): string;
  33829. }
  33830. }
  33831. declare module "babylonjs/scene" {
  33832. import { Nullable } from "babylonjs/types";
  33833. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33834. import { Observable } from "babylonjs/Misc/observable";
  33835. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33836. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33837. import { Geometry } from "babylonjs/Meshes/geometry";
  33838. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33839. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33841. import { Mesh } from "babylonjs/Meshes/mesh";
  33842. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33843. import { Bone } from "babylonjs/Bones/bone";
  33844. import { Skeleton } from "babylonjs/Bones/skeleton";
  33845. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33846. import { Camera } from "babylonjs/Cameras/camera";
  33847. import { AbstractScene } from "babylonjs/abstractScene";
  33848. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33849. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33850. import { Material } from "babylonjs/Materials/material";
  33851. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33852. import { Effect } from "babylonjs/Materials/effect";
  33853. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33854. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33855. import { Light } from "babylonjs/Lights/light";
  33856. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33857. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33858. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33859. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33860. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33861. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33862. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33863. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33864. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33865. import { Engine } from "babylonjs/Engines/engine";
  33866. import { Node } from "babylonjs/node";
  33867. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33868. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33869. import { WebRequest } from "babylonjs/Misc/webRequest";
  33870. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33871. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33872. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33873. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33874. import { Plane } from "babylonjs/Maths/math.plane";
  33875. import { Ray } from "babylonjs/Culling/ray";
  33876. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33877. import { Animation } from "babylonjs/Animations/animation";
  33878. import { Animatable } from "babylonjs/Animations/animatable";
  33879. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33880. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33881. import { Collider } from "babylonjs/Collisions/collider";
  33882. /**
  33883. * Define an interface for all classes that will hold resources
  33884. */
  33885. export interface IDisposable {
  33886. /**
  33887. * Releases all held resources
  33888. */
  33889. dispose(): void;
  33890. }
  33891. /** Interface defining initialization parameters for Scene class */
  33892. export interface SceneOptions {
  33893. /**
  33894. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33895. * It will improve performance when the number of geometries becomes important.
  33896. */
  33897. useGeometryUniqueIdsMap?: boolean;
  33898. /**
  33899. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33900. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33901. */
  33902. useMaterialMeshMap?: boolean;
  33903. /**
  33904. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33905. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33906. */
  33907. useClonedMeshhMap?: boolean;
  33908. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33909. virtual?: boolean;
  33910. }
  33911. /**
  33912. * Represents a scene to be rendered by the engine.
  33913. * @see http://doc.babylonjs.com/features/scene
  33914. */
  33915. export class Scene extends AbstractScene implements IAnimatable {
  33916. /** The fog is deactivated */
  33917. static readonly FOGMODE_NONE: number;
  33918. /** The fog density is following an exponential function */
  33919. static readonly FOGMODE_EXP: number;
  33920. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33921. static readonly FOGMODE_EXP2: number;
  33922. /** The fog density is following a linear function. */
  33923. static readonly FOGMODE_LINEAR: number;
  33924. /**
  33925. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33926. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33927. */
  33928. static MinDeltaTime: number;
  33929. /**
  33930. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33931. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33932. */
  33933. static MaxDeltaTime: number;
  33934. /**
  33935. * Factory used to create the default material.
  33936. * @param name The name of the material to create
  33937. * @param scene The scene to create the material for
  33938. * @returns The default material
  33939. */
  33940. static DefaultMaterialFactory(scene: Scene): Material;
  33941. /**
  33942. * Factory used to create the a collision coordinator.
  33943. * @returns The collision coordinator
  33944. */
  33945. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33946. /** @hidden */
  33947. _inputManager: InputManager;
  33948. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33949. cameraToUseForPointers: Nullable<Camera>;
  33950. /** @hidden */
  33951. readonly _isScene: boolean;
  33952. /**
  33953. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33954. */
  33955. autoClear: boolean;
  33956. /**
  33957. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33958. */
  33959. autoClearDepthAndStencil: boolean;
  33960. /**
  33961. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33962. */
  33963. clearColor: Color4;
  33964. /**
  33965. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33966. */
  33967. ambientColor: Color3;
  33968. /**
  33969. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33970. * It should only be one of the following (if not the default embedded one):
  33971. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33972. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33973. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33974. * The material properties need to be setup according to the type of texture in use.
  33975. */
  33976. environmentBRDFTexture: BaseTexture;
  33977. /** @hidden */
  33978. protected _environmentTexture: Nullable<BaseTexture>;
  33979. /**
  33980. * Texture used in all pbr material as the reflection texture.
  33981. * As in the majority of the scene they are the same (exception for multi room and so on),
  33982. * this is easier to reference from here than from all the materials.
  33983. */
  33984. /**
  33985. * Texture used in all pbr material as the reflection texture.
  33986. * As in the majority of the scene they are the same (exception for multi room and so on),
  33987. * this is easier to set here than in all the materials.
  33988. */
  33989. environmentTexture: Nullable<BaseTexture>;
  33990. /** @hidden */
  33991. protected _environmentIntensity: number;
  33992. /**
  33993. * Intensity of the environment in all pbr material.
  33994. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33995. * As in the majority of the scene they are the same (exception for multi room and so on),
  33996. * this is easier to reference from here than from all the materials.
  33997. */
  33998. /**
  33999. * Intensity of the environment in all pbr material.
  34000. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34001. * As in the majority of the scene they are the same (exception for multi room and so on),
  34002. * this is easier to set here than in all the materials.
  34003. */
  34004. environmentIntensity: number;
  34005. /** @hidden */
  34006. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34007. /**
  34008. * Default image processing configuration used either in the rendering
  34009. * Forward main pass or through the imageProcessingPostProcess if present.
  34010. * As in the majority of the scene they are the same (exception for multi camera),
  34011. * this is easier to reference from here than from all the materials and post process.
  34012. *
  34013. * No setter as we it is a shared configuration, you can set the values instead.
  34014. */
  34015. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34016. private _forceWireframe;
  34017. /**
  34018. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34019. */
  34020. forceWireframe: boolean;
  34021. private _forcePointsCloud;
  34022. /**
  34023. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34024. */
  34025. forcePointsCloud: boolean;
  34026. /**
  34027. * Gets or sets the active clipplane 1
  34028. */
  34029. clipPlane: Nullable<Plane>;
  34030. /**
  34031. * Gets or sets the active clipplane 2
  34032. */
  34033. clipPlane2: Nullable<Plane>;
  34034. /**
  34035. * Gets or sets the active clipplane 3
  34036. */
  34037. clipPlane3: Nullable<Plane>;
  34038. /**
  34039. * Gets or sets the active clipplane 4
  34040. */
  34041. clipPlane4: Nullable<Plane>;
  34042. /**
  34043. * Gets or sets a boolean indicating if animations are enabled
  34044. */
  34045. animationsEnabled: boolean;
  34046. private _animationPropertiesOverride;
  34047. /**
  34048. * Gets or sets the animation properties override
  34049. */
  34050. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34051. /**
  34052. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34053. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34054. */
  34055. useConstantAnimationDeltaTime: boolean;
  34056. /**
  34057. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34058. * Please note that it requires to run a ray cast through the scene on every frame
  34059. */
  34060. constantlyUpdateMeshUnderPointer: boolean;
  34061. /**
  34062. * Defines the HTML cursor to use when hovering over interactive elements
  34063. */
  34064. hoverCursor: string;
  34065. /**
  34066. * Defines the HTML default cursor to use (empty by default)
  34067. */
  34068. defaultCursor: string;
  34069. /**
  34070. * This is used to call preventDefault() on pointer down
  34071. * in order to block unwanted artifacts like system double clicks
  34072. */
  34073. preventDefaultOnPointerDown: boolean;
  34074. /**
  34075. * This is used to call preventDefault() on pointer up
  34076. * in order to block unwanted artifacts like system double clicks
  34077. */
  34078. preventDefaultOnPointerUp: boolean;
  34079. /**
  34080. * Gets or sets user defined metadata
  34081. */
  34082. metadata: any;
  34083. /**
  34084. * For internal use only. Please do not use.
  34085. */
  34086. reservedDataStore: any;
  34087. /**
  34088. * Gets the name of the plugin used to load this scene (null by default)
  34089. */
  34090. loadingPluginName: string;
  34091. /**
  34092. * Use this array to add regular expressions used to disable offline support for specific urls
  34093. */
  34094. disableOfflineSupportExceptionRules: RegExp[];
  34095. /**
  34096. * An event triggered when the scene is disposed.
  34097. */
  34098. onDisposeObservable: Observable<Scene>;
  34099. private _onDisposeObserver;
  34100. /** Sets a function to be executed when this scene is disposed. */
  34101. onDispose: () => void;
  34102. /**
  34103. * An event triggered before rendering the scene (right after animations and physics)
  34104. */
  34105. onBeforeRenderObservable: Observable<Scene>;
  34106. private _onBeforeRenderObserver;
  34107. /** Sets a function to be executed before rendering this scene */
  34108. beforeRender: Nullable<() => void>;
  34109. /**
  34110. * An event triggered after rendering the scene
  34111. */
  34112. onAfterRenderObservable: Observable<Scene>;
  34113. /**
  34114. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34115. */
  34116. onAfterRenderCameraObservable: Observable<Camera>;
  34117. private _onAfterRenderObserver;
  34118. /** Sets a function to be executed after rendering this scene */
  34119. afterRender: Nullable<() => void>;
  34120. /**
  34121. * An event triggered before animating the scene
  34122. */
  34123. onBeforeAnimationsObservable: Observable<Scene>;
  34124. /**
  34125. * An event triggered after animations processing
  34126. */
  34127. onAfterAnimationsObservable: Observable<Scene>;
  34128. /**
  34129. * An event triggered before draw calls are ready to be sent
  34130. */
  34131. onBeforeDrawPhaseObservable: Observable<Scene>;
  34132. /**
  34133. * An event triggered after draw calls have been sent
  34134. */
  34135. onAfterDrawPhaseObservable: Observable<Scene>;
  34136. /**
  34137. * An event triggered when the scene is ready
  34138. */
  34139. onReadyObservable: Observable<Scene>;
  34140. /**
  34141. * An event triggered before rendering a camera
  34142. */
  34143. onBeforeCameraRenderObservable: Observable<Camera>;
  34144. private _onBeforeCameraRenderObserver;
  34145. /** Sets a function to be executed before rendering a camera*/
  34146. beforeCameraRender: () => void;
  34147. /**
  34148. * An event triggered after rendering a camera
  34149. */
  34150. onAfterCameraRenderObservable: Observable<Camera>;
  34151. private _onAfterCameraRenderObserver;
  34152. /** Sets a function to be executed after rendering a camera*/
  34153. afterCameraRender: () => void;
  34154. /**
  34155. * An event triggered when active meshes evaluation is about to start
  34156. */
  34157. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34158. /**
  34159. * An event triggered when active meshes evaluation is done
  34160. */
  34161. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34162. /**
  34163. * An event triggered when particles rendering is about to start
  34164. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34165. */
  34166. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34167. /**
  34168. * An event triggered when particles rendering is done
  34169. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34170. */
  34171. onAfterParticlesRenderingObservable: Observable<Scene>;
  34172. /**
  34173. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34174. */
  34175. onDataLoadedObservable: Observable<Scene>;
  34176. /**
  34177. * An event triggered when a camera is created
  34178. */
  34179. onNewCameraAddedObservable: Observable<Camera>;
  34180. /**
  34181. * An event triggered when a camera is removed
  34182. */
  34183. onCameraRemovedObservable: Observable<Camera>;
  34184. /**
  34185. * An event triggered when a light is created
  34186. */
  34187. onNewLightAddedObservable: Observable<Light>;
  34188. /**
  34189. * An event triggered when a light is removed
  34190. */
  34191. onLightRemovedObservable: Observable<Light>;
  34192. /**
  34193. * An event triggered when a geometry is created
  34194. */
  34195. onNewGeometryAddedObservable: Observable<Geometry>;
  34196. /**
  34197. * An event triggered when a geometry is removed
  34198. */
  34199. onGeometryRemovedObservable: Observable<Geometry>;
  34200. /**
  34201. * An event triggered when a transform node is created
  34202. */
  34203. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34204. /**
  34205. * An event triggered when a transform node is removed
  34206. */
  34207. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34208. /**
  34209. * An event triggered when a mesh is created
  34210. */
  34211. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34212. /**
  34213. * An event triggered when a mesh is removed
  34214. */
  34215. onMeshRemovedObservable: Observable<AbstractMesh>;
  34216. /**
  34217. * An event triggered when a skeleton is created
  34218. */
  34219. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34220. /**
  34221. * An event triggered when a skeleton is removed
  34222. */
  34223. onSkeletonRemovedObservable: Observable<Skeleton>;
  34224. /**
  34225. * An event triggered when a material is created
  34226. */
  34227. onNewMaterialAddedObservable: Observable<Material>;
  34228. /**
  34229. * An event triggered when a material is removed
  34230. */
  34231. onMaterialRemovedObservable: Observable<Material>;
  34232. /**
  34233. * An event triggered when a texture is created
  34234. */
  34235. onNewTextureAddedObservable: Observable<BaseTexture>;
  34236. /**
  34237. * An event triggered when a texture is removed
  34238. */
  34239. onTextureRemovedObservable: Observable<BaseTexture>;
  34240. /**
  34241. * An event triggered when render targets are about to be rendered
  34242. * Can happen multiple times per frame.
  34243. */
  34244. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34245. /**
  34246. * An event triggered when render targets were rendered.
  34247. * Can happen multiple times per frame.
  34248. */
  34249. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34250. /**
  34251. * An event triggered before calculating deterministic simulation step
  34252. */
  34253. onBeforeStepObservable: Observable<Scene>;
  34254. /**
  34255. * An event triggered after calculating deterministic simulation step
  34256. */
  34257. onAfterStepObservable: Observable<Scene>;
  34258. /**
  34259. * An event triggered when the activeCamera property is updated
  34260. */
  34261. onActiveCameraChanged: Observable<Scene>;
  34262. /**
  34263. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34264. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34265. * 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)
  34266. */
  34267. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34268. /**
  34269. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34270. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34271. * 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)
  34272. */
  34273. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34274. /**
  34275. * This Observable will when a mesh has been imported into the scene.
  34276. */
  34277. onMeshImportedObservable: Observable<AbstractMesh>;
  34278. /**
  34279. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34280. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34281. */
  34282. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34283. /** @hidden */
  34284. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34285. /**
  34286. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34287. */
  34288. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34289. /**
  34290. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34291. */
  34292. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34293. /**
  34294. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34295. */
  34296. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34297. /** Callback called when a pointer move is detected */
  34298. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34299. /** Callback called when a pointer down is detected */
  34300. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34301. /** Callback called when a pointer up is detected */
  34302. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34303. /** Callback called when a pointer pick is detected */
  34304. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34305. /**
  34306. * 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).
  34307. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34308. */
  34309. onPrePointerObservable: Observable<PointerInfoPre>;
  34310. /**
  34311. * Observable event triggered each time an input event is received from the rendering canvas
  34312. */
  34313. onPointerObservable: Observable<PointerInfo>;
  34314. /**
  34315. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34316. */
  34317. readonly unTranslatedPointer: Vector2;
  34318. /**
  34319. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34320. */
  34321. static DragMovementThreshold: number;
  34322. /**
  34323. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34324. */
  34325. static LongPressDelay: number;
  34326. /**
  34327. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34328. */
  34329. static DoubleClickDelay: number;
  34330. /** If you need to check double click without raising a single click at first click, enable this flag */
  34331. static ExclusiveDoubleClickMode: boolean;
  34332. /** @hidden */
  34333. _mirroredCameraPosition: Nullable<Vector3>;
  34334. /**
  34335. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34336. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34337. */
  34338. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34339. /**
  34340. * Observable event triggered each time an keyboard event is received from the hosting window
  34341. */
  34342. onKeyboardObservable: Observable<KeyboardInfo>;
  34343. private _useRightHandedSystem;
  34344. /**
  34345. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34346. */
  34347. useRightHandedSystem: boolean;
  34348. private _timeAccumulator;
  34349. private _currentStepId;
  34350. private _currentInternalStep;
  34351. /**
  34352. * Sets the step Id used by deterministic lock step
  34353. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34354. * @param newStepId defines the step Id
  34355. */
  34356. setStepId(newStepId: number): void;
  34357. /**
  34358. * Gets the step Id used by deterministic lock step
  34359. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34360. * @returns the step Id
  34361. */
  34362. getStepId(): number;
  34363. /**
  34364. * Gets the internal step used by deterministic lock step
  34365. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34366. * @returns the internal step
  34367. */
  34368. getInternalStep(): number;
  34369. private _fogEnabled;
  34370. /**
  34371. * Gets or sets a boolean indicating if fog is enabled on this scene
  34372. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34373. * (Default is true)
  34374. */
  34375. fogEnabled: boolean;
  34376. private _fogMode;
  34377. /**
  34378. * Gets or sets the fog mode to use
  34379. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34380. * | mode | value |
  34381. * | --- | --- |
  34382. * | FOGMODE_NONE | 0 |
  34383. * | FOGMODE_EXP | 1 |
  34384. * | FOGMODE_EXP2 | 2 |
  34385. * | FOGMODE_LINEAR | 3 |
  34386. */
  34387. fogMode: number;
  34388. /**
  34389. * Gets or sets the fog color to use
  34390. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34391. * (Default is Color3(0.2, 0.2, 0.3))
  34392. */
  34393. fogColor: Color3;
  34394. /**
  34395. * Gets or sets the fog density to use
  34396. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34397. * (Default is 0.1)
  34398. */
  34399. fogDensity: number;
  34400. /**
  34401. * Gets or sets the fog start distance to use
  34402. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34403. * (Default is 0)
  34404. */
  34405. fogStart: number;
  34406. /**
  34407. * Gets or sets the fog end distance to use
  34408. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34409. * (Default is 1000)
  34410. */
  34411. fogEnd: number;
  34412. private _shadowsEnabled;
  34413. /**
  34414. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34415. */
  34416. shadowsEnabled: boolean;
  34417. private _lightsEnabled;
  34418. /**
  34419. * Gets or sets a boolean indicating if lights are enabled on this scene
  34420. */
  34421. lightsEnabled: boolean;
  34422. /** All of the active cameras added to this scene. */
  34423. activeCameras: Camera[];
  34424. /** @hidden */
  34425. _activeCamera: Nullable<Camera>;
  34426. /** Gets or sets the current active camera */
  34427. activeCamera: Nullable<Camera>;
  34428. private _defaultMaterial;
  34429. /** The default material used on meshes when no material is affected */
  34430. /** The default material used on meshes when no material is affected */
  34431. defaultMaterial: Material;
  34432. private _texturesEnabled;
  34433. /**
  34434. * Gets or sets a boolean indicating if textures are enabled on this scene
  34435. */
  34436. texturesEnabled: boolean;
  34437. /**
  34438. * Gets or sets a boolean indicating if particles are enabled on this scene
  34439. */
  34440. particlesEnabled: boolean;
  34441. /**
  34442. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34443. */
  34444. spritesEnabled: boolean;
  34445. private _skeletonsEnabled;
  34446. /**
  34447. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34448. */
  34449. skeletonsEnabled: boolean;
  34450. /**
  34451. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34452. */
  34453. lensFlaresEnabled: boolean;
  34454. /**
  34455. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34456. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34457. */
  34458. collisionsEnabled: boolean;
  34459. private _collisionCoordinator;
  34460. /** @hidden */
  34461. readonly collisionCoordinator: ICollisionCoordinator;
  34462. /**
  34463. * Defines the gravity applied to this scene (used only for collisions)
  34464. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34465. */
  34466. gravity: Vector3;
  34467. /**
  34468. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34469. */
  34470. postProcessesEnabled: boolean;
  34471. /**
  34472. * The list of postprocesses added to the scene
  34473. */
  34474. postProcesses: PostProcess[];
  34475. /**
  34476. * Gets the current postprocess manager
  34477. */
  34478. postProcessManager: PostProcessManager;
  34479. /**
  34480. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34481. */
  34482. renderTargetsEnabled: boolean;
  34483. /**
  34484. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34485. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34486. */
  34487. dumpNextRenderTargets: boolean;
  34488. /**
  34489. * The list of user defined render targets added to the scene
  34490. */
  34491. customRenderTargets: RenderTargetTexture[];
  34492. /**
  34493. * Defines if texture loading must be delayed
  34494. * If true, textures will only be loaded when they need to be rendered
  34495. */
  34496. useDelayedTextureLoading: boolean;
  34497. /**
  34498. * Gets the list of meshes imported to the scene through SceneLoader
  34499. */
  34500. importedMeshesFiles: String[];
  34501. /**
  34502. * Gets or sets a boolean indicating if probes are enabled on this scene
  34503. */
  34504. probesEnabled: boolean;
  34505. /**
  34506. * Gets or sets the current offline provider to use to store scene data
  34507. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34508. */
  34509. offlineProvider: IOfflineProvider;
  34510. /**
  34511. * Gets or sets the action manager associated with the scene
  34512. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34513. */
  34514. actionManager: AbstractActionManager;
  34515. private _meshesForIntersections;
  34516. /**
  34517. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34518. */
  34519. proceduralTexturesEnabled: boolean;
  34520. private _engine;
  34521. private _totalVertices;
  34522. /** @hidden */
  34523. _activeIndices: PerfCounter;
  34524. /** @hidden */
  34525. _activeParticles: PerfCounter;
  34526. /** @hidden */
  34527. _activeBones: PerfCounter;
  34528. private _animationRatio;
  34529. /** @hidden */
  34530. _animationTimeLast: number;
  34531. /** @hidden */
  34532. _animationTime: number;
  34533. /**
  34534. * Gets or sets a general scale for animation speed
  34535. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34536. */
  34537. animationTimeScale: number;
  34538. /** @hidden */
  34539. _cachedMaterial: Nullable<Material>;
  34540. /** @hidden */
  34541. _cachedEffect: Nullable<Effect>;
  34542. /** @hidden */
  34543. _cachedVisibility: Nullable<number>;
  34544. private _renderId;
  34545. private _frameId;
  34546. private _executeWhenReadyTimeoutId;
  34547. private _intermediateRendering;
  34548. private _viewUpdateFlag;
  34549. private _projectionUpdateFlag;
  34550. /** @hidden */
  34551. _toBeDisposed: Nullable<IDisposable>[];
  34552. private _activeRequests;
  34553. /** @hidden */
  34554. _pendingData: any[];
  34555. private _isDisposed;
  34556. /**
  34557. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34558. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34559. */
  34560. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34561. private _activeMeshes;
  34562. private _processedMaterials;
  34563. private _renderTargets;
  34564. /** @hidden */
  34565. _activeParticleSystems: SmartArray<IParticleSystem>;
  34566. private _activeSkeletons;
  34567. private _softwareSkinnedMeshes;
  34568. private _renderingManager;
  34569. /** @hidden */
  34570. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34571. private _transformMatrix;
  34572. private _sceneUbo;
  34573. /** @hidden */
  34574. _viewMatrix: Matrix;
  34575. private _projectionMatrix;
  34576. /** @hidden */
  34577. _forcedViewPosition: Nullable<Vector3>;
  34578. /** @hidden */
  34579. _frustumPlanes: Plane[];
  34580. /**
  34581. * Gets the list of frustum planes (built from the active camera)
  34582. */
  34583. readonly frustumPlanes: Plane[];
  34584. /**
  34585. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34586. * This is useful if there are more lights that the maximum simulteanous authorized
  34587. */
  34588. requireLightSorting: boolean;
  34589. /** @hidden */
  34590. readonly useMaterialMeshMap: boolean;
  34591. /** @hidden */
  34592. readonly useClonedMeshhMap: boolean;
  34593. private _externalData;
  34594. private _uid;
  34595. /**
  34596. * @hidden
  34597. * Backing store of defined scene components.
  34598. */
  34599. _components: ISceneComponent[];
  34600. /**
  34601. * @hidden
  34602. * Backing store of defined scene components.
  34603. */
  34604. _serializableComponents: ISceneSerializableComponent[];
  34605. /**
  34606. * List of components to register on the next registration step.
  34607. */
  34608. private _transientComponents;
  34609. /**
  34610. * Registers the transient components if needed.
  34611. */
  34612. private _registerTransientComponents;
  34613. /**
  34614. * @hidden
  34615. * Add a component to the scene.
  34616. * Note that the ccomponent could be registered on th next frame if this is called after
  34617. * the register component stage.
  34618. * @param component Defines the component to add to the scene
  34619. */
  34620. _addComponent(component: ISceneComponent): void;
  34621. /**
  34622. * @hidden
  34623. * Gets a component from the scene.
  34624. * @param name defines the name of the component to retrieve
  34625. * @returns the component or null if not present
  34626. */
  34627. _getComponent(name: string): Nullable<ISceneComponent>;
  34628. /**
  34629. * @hidden
  34630. * Defines the actions happening before camera updates.
  34631. */
  34632. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34633. /**
  34634. * @hidden
  34635. * Defines the actions happening before clear the canvas.
  34636. */
  34637. _beforeClearStage: Stage<SimpleStageAction>;
  34638. /**
  34639. * @hidden
  34640. * Defines the actions when collecting render targets for the frame.
  34641. */
  34642. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34643. /**
  34644. * @hidden
  34645. * Defines the actions happening for one camera in the frame.
  34646. */
  34647. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34648. /**
  34649. * @hidden
  34650. * Defines the actions happening during the per mesh ready checks.
  34651. */
  34652. _isReadyForMeshStage: Stage<MeshStageAction>;
  34653. /**
  34654. * @hidden
  34655. * Defines the actions happening before evaluate active mesh checks.
  34656. */
  34657. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34658. /**
  34659. * @hidden
  34660. * Defines the actions happening during the evaluate sub mesh checks.
  34661. */
  34662. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34663. /**
  34664. * @hidden
  34665. * Defines the actions happening during the active mesh stage.
  34666. */
  34667. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34668. /**
  34669. * @hidden
  34670. * Defines the actions happening during the per camera render target step.
  34671. */
  34672. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34673. /**
  34674. * @hidden
  34675. * Defines the actions happening just before the active camera is drawing.
  34676. */
  34677. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34678. /**
  34679. * @hidden
  34680. * Defines the actions happening just before a render target is drawing.
  34681. */
  34682. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34683. /**
  34684. * @hidden
  34685. * Defines the actions happening just before a rendering group is drawing.
  34686. */
  34687. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34688. /**
  34689. * @hidden
  34690. * Defines the actions happening just before a mesh is drawing.
  34691. */
  34692. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34693. /**
  34694. * @hidden
  34695. * Defines the actions happening just after a mesh has been drawn.
  34696. */
  34697. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34698. /**
  34699. * @hidden
  34700. * Defines the actions happening just after a rendering group has been drawn.
  34701. */
  34702. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34703. /**
  34704. * @hidden
  34705. * Defines the actions happening just after the active camera has been drawn.
  34706. */
  34707. _afterCameraDrawStage: Stage<CameraStageAction>;
  34708. /**
  34709. * @hidden
  34710. * Defines the actions happening just after a render target has been drawn.
  34711. */
  34712. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34713. /**
  34714. * @hidden
  34715. * Defines the actions happening just after rendering all cameras and computing intersections.
  34716. */
  34717. _afterRenderStage: Stage<SimpleStageAction>;
  34718. /**
  34719. * @hidden
  34720. * Defines the actions happening when a pointer move event happens.
  34721. */
  34722. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34723. /**
  34724. * @hidden
  34725. * Defines the actions happening when a pointer down event happens.
  34726. */
  34727. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34728. /**
  34729. * @hidden
  34730. * Defines the actions happening when a pointer up event happens.
  34731. */
  34732. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34733. /**
  34734. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34735. */
  34736. private geometriesByUniqueId;
  34737. /**
  34738. * Creates a new Scene
  34739. * @param engine defines the engine to use to render this scene
  34740. * @param options defines the scene options
  34741. */
  34742. constructor(engine: Engine, options?: SceneOptions);
  34743. /**
  34744. * Gets a string idenfifying the name of the class
  34745. * @returns "Scene" string
  34746. */
  34747. getClassName(): string;
  34748. private _defaultMeshCandidates;
  34749. /**
  34750. * @hidden
  34751. */
  34752. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34753. private _defaultSubMeshCandidates;
  34754. /**
  34755. * @hidden
  34756. */
  34757. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34758. /**
  34759. * Sets the default candidate providers for the scene.
  34760. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34761. * and getCollidingSubMeshCandidates to their default function
  34762. */
  34763. setDefaultCandidateProviders(): void;
  34764. /**
  34765. * Gets the mesh that is currently under the pointer
  34766. */
  34767. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34768. /**
  34769. * Gets or sets the current on-screen X position of the pointer
  34770. */
  34771. pointerX: number;
  34772. /**
  34773. * Gets or sets the current on-screen Y position of the pointer
  34774. */
  34775. pointerY: number;
  34776. /**
  34777. * Gets the cached material (ie. the latest rendered one)
  34778. * @returns the cached material
  34779. */
  34780. getCachedMaterial(): Nullable<Material>;
  34781. /**
  34782. * Gets the cached effect (ie. the latest rendered one)
  34783. * @returns the cached effect
  34784. */
  34785. getCachedEffect(): Nullable<Effect>;
  34786. /**
  34787. * Gets the cached visibility state (ie. the latest rendered one)
  34788. * @returns the cached visibility state
  34789. */
  34790. getCachedVisibility(): Nullable<number>;
  34791. /**
  34792. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34793. * @param material defines the current material
  34794. * @param effect defines the current effect
  34795. * @param visibility defines the current visibility state
  34796. * @returns true if one parameter is not cached
  34797. */
  34798. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34799. /**
  34800. * Gets the engine associated with the scene
  34801. * @returns an Engine
  34802. */
  34803. getEngine(): Engine;
  34804. /**
  34805. * Gets the total number of vertices rendered per frame
  34806. * @returns the total number of vertices rendered per frame
  34807. */
  34808. getTotalVertices(): number;
  34809. /**
  34810. * Gets the performance counter for total vertices
  34811. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34812. */
  34813. readonly totalVerticesPerfCounter: PerfCounter;
  34814. /**
  34815. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34816. * @returns the total number of active indices rendered per frame
  34817. */
  34818. getActiveIndices(): number;
  34819. /**
  34820. * Gets the performance counter for active indices
  34821. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34822. */
  34823. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34824. /**
  34825. * Gets the total number of active particles rendered per frame
  34826. * @returns the total number of active particles rendered per frame
  34827. */
  34828. getActiveParticles(): number;
  34829. /**
  34830. * Gets the performance counter for active particles
  34831. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34832. */
  34833. readonly activeParticlesPerfCounter: PerfCounter;
  34834. /**
  34835. * Gets the total number of active bones rendered per frame
  34836. * @returns the total number of active bones rendered per frame
  34837. */
  34838. getActiveBones(): number;
  34839. /**
  34840. * Gets the performance counter for active bones
  34841. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34842. */
  34843. readonly activeBonesPerfCounter: PerfCounter;
  34844. /**
  34845. * Gets the array of active meshes
  34846. * @returns an array of AbstractMesh
  34847. */
  34848. getActiveMeshes(): SmartArray<AbstractMesh>;
  34849. /**
  34850. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34851. * @returns a number
  34852. */
  34853. getAnimationRatio(): number;
  34854. /**
  34855. * Gets an unique Id for the current render phase
  34856. * @returns a number
  34857. */
  34858. getRenderId(): number;
  34859. /**
  34860. * Gets an unique Id for the current frame
  34861. * @returns a number
  34862. */
  34863. getFrameId(): number;
  34864. /** Call this function if you want to manually increment the render Id*/
  34865. incrementRenderId(): void;
  34866. private _createUbo;
  34867. /**
  34868. * Use this method to simulate a pointer move on a mesh
  34869. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34870. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34871. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34872. * @returns the current scene
  34873. */
  34874. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34875. /**
  34876. * Use this method to simulate a pointer down on a mesh
  34877. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34878. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34879. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34880. * @returns the current scene
  34881. */
  34882. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34883. /**
  34884. * Use this method to simulate a pointer up on a mesh
  34885. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34886. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34887. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34888. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34889. * @returns the current scene
  34890. */
  34891. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34892. /**
  34893. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34894. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34895. * @returns true if the pointer was captured
  34896. */
  34897. isPointerCaptured(pointerId?: number): boolean;
  34898. /**
  34899. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34900. * @param attachUp defines if you want to attach events to pointerup
  34901. * @param attachDown defines if you want to attach events to pointerdown
  34902. * @param attachMove defines if you want to attach events to pointermove
  34903. */
  34904. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34905. /** Detaches all event handlers*/
  34906. detachControl(): void;
  34907. /**
  34908. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34909. * Delay loaded resources are not taking in account
  34910. * @return true if all required resources are ready
  34911. */
  34912. isReady(): boolean;
  34913. /** Resets all cached information relative to material (including effect and visibility) */
  34914. resetCachedMaterial(): void;
  34915. /**
  34916. * Registers a function to be called before every frame render
  34917. * @param func defines the function to register
  34918. */
  34919. registerBeforeRender(func: () => void): void;
  34920. /**
  34921. * Unregisters a function called before every frame render
  34922. * @param func defines the function to unregister
  34923. */
  34924. unregisterBeforeRender(func: () => void): void;
  34925. /**
  34926. * Registers a function to be called after every frame render
  34927. * @param func defines the function to register
  34928. */
  34929. registerAfterRender(func: () => void): void;
  34930. /**
  34931. * Unregisters a function called after every frame render
  34932. * @param func defines the function to unregister
  34933. */
  34934. unregisterAfterRender(func: () => void): void;
  34935. private _executeOnceBeforeRender;
  34936. /**
  34937. * The provided function will run before render once and will be disposed afterwards.
  34938. * A timeout delay can be provided so that the function will be executed in N ms.
  34939. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34940. * @param func The function to be executed.
  34941. * @param timeout optional delay in ms
  34942. */
  34943. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34944. /** @hidden */
  34945. _addPendingData(data: any): void;
  34946. /** @hidden */
  34947. _removePendingData(data: any): void;
  34948. /**
  34949. * Returns the number of items waiting to be loaded
  34950. * @returns the number of items waiting to be loaded
  34951. */
  34952. getWaitingItemsCount(): number;
  34953. /**
  34954. * Returns a boolean indicating if the scene is still loading data
  34955. */
  34956. readonly isLoading: boolean;
  34957. /**
  34958. * Registers a function to be executed when the scene is ready
  34959. * @param {Function} func - the function to be executed
  34960. */
  34961. executeWhenReady(func: () => void): void;
  34962. /**
  34963. * Returns a promise that resolves when the scene is ready
  34964. * @returns A promise that resolves when the scene is ready
  34965. */
  34966. whenReadyAsync(): Promise<void>;
  34967. /** @hidden */
  34968. _checkIsReady(): void;
  34969. /**
  34970. * Gets all animatable attached to the scene
  34971. */
  34972. readonly animatables: Animatable[];
  34973. /**
  34974. * Resets the last animation time frame.
  34975. * Useful to override when animations start running when loading a scene for the first time.
  34976. */
  34977. resetLastAnimationTimeFrame(): void;
  34978. /**
  34979. * Gets the current view matrix
  34980. * @returns a Matrix
  34981. */
  34982. getViewMatrix(): Matrix;
  34983. /**
  34984. * Gets the current projection matrix
  34985. * @returns a Matrix
  34986. */
  34987. getProjectionMatrix(): Matrix;
  34988. /**
  34989. * Gets the current transform matrix
  34990. * @returns a Matrix made of View * Projection
  34991. */
  34992. getTransformMatrix(): Matrix;
  34993. /**
  34994. * Sets the current transform matrix
  34995. * @param viewL defines the View matrix to use
  34996. * @param projectionL defines the Projection matrix to use
  34997. * @param viewR defines the right View matrix to use (if provided)
  34998. * @param projectionR defines the right Projection matrix to use (if provided)
  34999. */
  35000. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35001. /**
  35002. * Gets the uniform buffer used to store scene data
  35003. * @returns a UniformBuffer
  35004. */
  35005. getSceneUniformBuffer(): UniformBuffer;
  35006. /**
  35007. * Gets an unique (relatively to the current scene) Id
  35008. * @returns an unique number for the scene
  35009. */
  35010. getUniqueId(): number;
  35011. /**
  35012. * Add a mesh to the list of scene's meshes
  35013. * @param newMesh defines the mesh to add
  35014. * @param recursive if all child meshes should also be added to the scene
  35015. */
  35016. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35017. /**
  35018. * Remove a mesh for the list of scene's meshes
  35019. * @param toRemove defines the mesh to remove
  35020. * @param recursive if all child meshes should also be removed from the scene
  35021. * @returns the index where the mesh was in the mesh list
  35022. */
  35023. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35024. /**
  35025. * Add a transform node to the list of scene's transform nodes
  35026. * @param newTransformNode defines the transform node to add
  35027. */
  35028. addTransformNode(newTransformNode: TransformNode): void;
  35029. /**
  35030. * Remove a transform node for the list of scene's transform nodes
  35031. * @param toRemove defines the transform node to remove
  35032. * @returns the index where the transform node was in the transform node list
  35033. */
  35034. removeTransformNode(toRemove: TransformNode): number;
  35035. /**
  35036. * Remove a skeleton for the list of scene's skeletons
  35037. * @param toRemove defines the skeleton to remove
  35038. * @returns the index where the skeleton was in the skeleton list
  35039. */
  35040. removeSkeleton(toRemove: Skeleton): number;
  35041. /**
  35042. * Remove a morph target for the list of scene's morph targets
  35043. * @param toRemove defines the morph target to remove
  35044. * @returns the index where the morph target was in the morph target list
  35045. */
  35046. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35047. /**
  35048. * Remove a light for the list of scene's lights
  35049. * @param toRemove defines the light to remove
  35050. * @returns the index where the light was in the light list
  35051. */
  35052. removeLight(toRemove: Light): number;
  35053. /**
  35054. * Remove a camera for the list of scene's cameras
  35055. * @param toRemove defines the camera to remove
  35056. * @returns the index where the camera was in the camera list
  35057. */
  35058. removeCamera(toRemove: Camera): number;
  35059. /**
  35060. * Remove a particle system for the list of scene's particle systems
  35061. * @param toRemove defines the particle system to remove
  35062. * @returns the index where the particle system was in the particle system list
  35063. */
  35064. removeParticleSystem(toRemove: IParticleSystem): number;
  35065. /**
  35066. * Remove a animation for the list of scene's animations
  35067. * @param toRemove defines the animation to remove
  35068. * @returns the index where the animation was in the animation list
  35069. */
  35070. removeAnimation(toRemove: Animation): number;
  35071. /**
  35072. * Will stop the animation of the given target
  35073. * @param target - the target
  35074. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35075. * @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)
  35076. */
  35077. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35078. /**
  35079. * Removes the given animation group from this scene.
  35080. * @param toRemove The animation group to remove
  35081. * @returns The index of the removed animation group
  35082. */
  35083. removeAnimationGroup(toRemove: AnimationGroup): number;
  35084. /**
  35085. * Removes the given multi-material from this scene.
  35086. * @param toRemove The multi-material to remove
  35087. * @returns The index of the removed multi-material
  35088. */
  35089. removeMultiMaterial(toRemove: MultiMaterial): number;
  35090. /**
  35091. * Removes the given material from this scene.
  35092. * @param toRemove The material to remove
  35093. * @returns The index of the removed material
  35094. */
  35095. removeMaterial(toRemove: Material): number;
  35096. /**
  35097. * Removes the given action manager from this scene.
  35098. * @param toRemove The action manager to remove
  35099. * @returns The index of the removed action manager
  35100. */
  35101. removeActionManager(toRemove: AbstractActionManager): number;
  35102. /**
  35103. * Removes the given texture from this scene.
  35104. * @param toRemove The texture to remove
  35105. * @returns The index of the removed texture
  35106. */
  35107. removeTexture(toRemove: BaseTexture): number;
  35108. /**
  35109. * Adds the given light to this scene
  35110. * @param newLight The light to add
  35111. */
  35112. addLight(newLight: Light): void;
  35113. /**
  35114. * Sorts the list list based on light priorities
  35115. */
  35116. sortLightsByPriority(): void;
  35117. /**
  35118. * Adds the given camera to this scene
  35119. * @param newCamera The camera to add
  35120. */
  35121. addCamera(newCamera: Camera): void;
  35122. /**
  35123. * Adds the given skeleton to this scene
  35124. * @param newSkeleton The skeleton to add
  35125. */
  35126. addSkeleton(newSkeleton: Skeleton): void;
  35127. /**
  35128. * Adds the given particle system to this scene
  35129. * @param newParticleSystem The particle system to add
  35130. */
  35131. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35132. /**
  35133. * Adds the given animation to this scene
  35134. * @param newAnimation The animation to add
  35135. */
  35136. addAnimation(newAnimation: Animation): void;
  35137. /**
  35138. * Adds the given animation group to this scene.
  35139. * @param newAnimationGroup The animation group to add
  35140. */
  35141. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35142. /**
  35143. * Adds the given multi-material to this scene
  35144. * @param newMultiMaterial The multi-material to add
  35145. */
  35146. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35147. /**
  35148. * Adds the given material to this scene
  35149. * @param newMaterial The material to add
  35150. */
  35151. addMaterial(newMaterial: Material): void;
  35152. /**
  35153. * Adds the given morph target to this scene
  35154. * @param newMorphTargetManager The morph target to add
  35155. */
  35156. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35157. /**
  35158. * Adds the given geometry to this scene
  35159. * @param newGeometry The geometry to add
  35160. */
  35161. addGeometry(newGeometry: Geometry): void;
  35162. /**
  35163. * Adds the given action manager to this scene
  35164. * @param newActionManager The action manager to add
  35165. */
  35166. addActionManager(newActionManager: AbstractActionManager): void;
  35167. /**
  35168. * Adds the given texture to this scene.
  35169. * @param newTexture The texture to add
  35170. */
  35171. addTexture(newTexture: BaseTexture): void;
  35172. /**
  35173. * Switch active camera
  35174. * @param newCamera defines the new active camera
  35175. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35176. */
  35177. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35178. /**
  35179. * sets the active camera of the scene using its ID
  35180. * @param id defines the camera's ID
  35181. * @return the new active camera or null if none found.
  35182. */
  35183. setActiveCameraByID(id: string): Nullable<Camera>;
  35184. /**
  35185. * sets the active camera of the scene using its name
  35186. * @param name defines the camera's name
  35187. * @returns the new active camera or null if none found.
  35188. */
  35189. setActiveCameraByName(name: string): Nullable<Camera>;
  35190. /**
  35191. * get an animation group using its name
  35192. * @param name defines the material's name
  35193. * @return the animation group or null if none found.
  35194. */
  35195. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35196. /**
  35197. * Get a material using its unique id
  35198. * @param uniqueId defines the material's unique id
  35199. * @return the material or null if none found.
  35200. */
  35201. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35202. /**
  35203. * get a material using its id
  35204. * @param id defines the material's ID
  35205. * @return the material or null if none found.
  35206. */
  35207. getMaterialByID(id: string): Nullable<Material>;
  35208. /**
  35209. * Gets a the last added material using a given id
  35210. * @param id defines the material's ID
  35211. * @return the last material with the given id or null if none found.
  35212. */
  35213. getLastMaterialByID(id: string): Nullable<Material>;
  35214. /**
  35215. * Gets a material using its name
  35216. * @param name defines the material's name
  35217. * @return the material or null if none found.
  35218. */
  35219. getMaterialByName(name: string): Nullable<Material>;
  35220. /**
  35221. * Get a texture using its unique id
  35222. * @param uniqueId defines the texture's unique id
  35223. * @return the texture or null if none found.
  35224. */
  35225. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35226. /**
  35227. * Gets a camera using its id
  35228. * @param id defines the id to look for
  35229. * @returns the camera or null if not found
  35230. */
  35231. getCameraByID(id: string): Nullable<Camera>;
  35232. /**
  35233. * Gets a camera using its unique id
  35234. * @param uniqueId defines the unique id to look for
  35235. * @returns the camera or null if not found
  35236. */
  35237. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35238. /**
  35239. * Gets a camera using its name
  35240. * @param name defines the camera's name
  35241. * @return the camera or null if none found.
  35242. */
  35243. getCameraByName(name: string): Nullable<Camera>;
  35244. /**
  35245. * Gets a bone using its id
  35246. * @param id defines the bone's id
  35247. * @return the bone or null if not found
  35248. */
  35249. getBoneByID(id: string): Nullable<Bone>;
  35250. /**
  35251. * Gets a bone using its id
  35252. * @param name defines the bone's name
  35253. * @return the bone or null if not found
  35254. */
  35255. getBoneByName(name: string): Nullable<Bone>;
  35256. /**
  35257. * Gets a light node using its name
  35258. * @param name defines the the light's name
  35259. * @return the light or null if none found.
  35260. */
  35261. getLightByName(name: string): Nullable<Light>;
  35262. /**
  35263. * Gets a light node using its id
  35264. * @param id defines the light's id
  35265. * @return the light or null if none found.
  35266. */
  35267. getLightByID(id: string): Nullable<Light>;
  35268. /**
  35269. * Gets a light node using its scene-generated unique ID
  35270. * @param uniqueId defines the light's unique id
  35271. * @return the light or null if none found.
  35272. */
  35273. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35274. /**
  35275. * Gets a particle system by id
  35276. * @param id defines the particle system id
  35277. * @return the corresponding system or null if none found
  35278. */
  35279. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35280. /**
  35281. * Gets a geometry using its ID
  35282. * @param id defines the geometry's id
  35283. * @return the geometry or null if none found.
  35284. */
  35285. getGeometryByID(id: string): Nullable<Geometry>;
  35286. private _getGeometryByUniqueID;
  35287. /**
  35288. * Add a new geometry to this scene
  35289. * @param geometry defines the geometry to be added to the scene.
  35290. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35291. * @return a boolean defining if the geometry was added or not
  35292. */
  35293. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35294. /**
  35295. * Removes an existing geometry
  35296. * @param geometry defines the geometry to be removed from the scene
  35297. * @return a boolean defining if the geometry was removed or not
  35298. */
  35299. removeGeometry(geometry: Geometry): boolean;
  35300. /**
  35301. * Gets the list of geometries attached to the scene
  35302. * @returns an array of Geometry
  35303. */
  35304. getGeometries(): Geometry[];
  35305. /**
  35306. * Gets the first added mesh found of a given ID
  35307. * @param id defines the id to search for
  35308. * @return the mesh found or null if not found at all
  35309. */
  35310. getMeshByID(id: string): Nullable<AbstractMesh>;
  35311. /**
  35312. * Gets a list of meshes using their id
  35313. * @param id defines the id to search for
  35314. * @returns a list of meshes
  35315. */
  35316. getMeshesByID(id: string): Array<AbstractMesh>;
  35317. /**
  35318. * Gets the first added transform node found of a given ID
  35319. * @param id defines the id to search for
  35320. * @return the found transform node or null if not found at all.
  35321. */
  35322. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35323. /**
  35324. * Gets a transform node with its auto-generated unique id
  35325. * @param uniqueId efines the unique id to search for
  35326. * @return the found transform node or null if not found at all.
  35327. */
  35328. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35329. /**
  35330. * Gets a list of transform nodes using their id
  35331. * @param id defines the id to search for
  35332. * @returns a list of transform nodes
  35333. */
  35334. getTransformNodesByID(id: string): Array<TransformNode>;
  35335. /**
  35336. * Gets a mesh with its auto-generated unique id
  35337. * @param uniqueId defines the unique id to search for
  35338. * @return the found mesh or null if not found at all.
  35339. */
  35340. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35341. /**
  35342. * Gets a the last added mesh using a given id
  35343. * @param id defines the id to search for
  35344. * @return the found mesh or null if not found at all.
  35345. */
  35346. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35347. /**
  35348. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35349. * @param id defines the id to search for
  35350. * @return the found node or null if not found at all
  35351. */
  35352. getLastEntryByID(id: string): Nullable<Node>;
  35353. /**
  35354. * Gets a node (Mesh, Camera, Light) using a given id
  35355. * @param id defines the id to search for
  35356. * @return the found node or null if not found at all
  35357. */
  35358. getNodeByID(id: string): Nullable<Node>;
  35359. /**
  35360. * Gets a node (Mesh, Camera, Light) using a given name
  35361. * @param name defines the name to search for
  35362. * @return the found node or null if not found at all.
  35363. */
  35364. getNodeByName(name: string): Nullable<Node>;
  35365. /**
  35366. * Gets a mesh using a given name
  35367. * @param name defines the name to search for
  35368. * @return the found mesh or null if not found at all.
  35369. */
  35370. getMeshByName(name: string): Nullable<AbstractMesh>;
  35371. /**
  35372. * Gets a transform node using a given name
  35373. * @param name defines the name to search for
  35374. * @return the found transform node or null if not found at all.
  35375. */
  35376. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35377. /**
  35378. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35379. * @param id defines the id to search for
  35380. * @return the found skeleton or null if not found at all.
  35381. */
  35382. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35383. /**
  35384. * Gets a skeleton using a given auto generated unique id
  35385. * @param uniqueId defines the unique id to search for
  35386. * @return the found skeleton or null if not found at all.
  35387. */
  35388. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35389. /**
  35390. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35391. * @param id defines the id to search for
  35392. * @return the found skeleton or null if not found at all.
  35393. */
  35394. getSkeletonById(id: string): Nullable<Skeleton>;
  35395. /**
  35396. * Gets a skeleton using a given name
  35397. * @param name defines the name to search for
  35398. * @return the found skeleton or null if not found at all.
  35399. */
  35400. getSkeletonByName(name: string): Nullable<Skeleton>;
  35401. /**
  35402. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35403. * @param id defines the id to search for
  35404. * @return the found morph target manager or null if not found at all.
  35405. */
  35406. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35407. /**
  35408. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35409. * @param id defines the id to search for
  35410. * @return the found morph target or null if not found at all.
  35411. */
  35412. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35413. /**
  35414. * Gets a boolean indicating if the given mesh is active
  35415. * @param mesh defines the mesh to look for
  35416. * @returns true if the mesh is in the active list
  35417. */
  35418. isActiveMesh(mesh: AbstractMesh): boolean;
  35419. /**
  35420. * Return a unique id as a string which can serve as an identifier for the scene
  35421. */
  35422. readonly uid: string;
  35423. /**
  35424. * Add an externaly attached data from its key.
  35425. * This method call will fail and return false, if such key already exists.
  35426. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35427. * @param key the unique key that identifies the data
  35428. * @param data the data object to associate to the key for this Engine instance
  35429. * @return true if no such key were already present and the data was added successfully, false otherwise
  35430. */
  35431. addExternalData<T>(key: string, data: T): boolean;
  35432. /**
  35433. * Get an externaly attached data from its key
  35434. * @param key the unique key that identifies the data
  35435. * @return the associated data, if present (can be null), or undefined if not present
  35436. */
  35437. getExternalData<T>(key: string): Nullable<T>;
  35438. /**
  35439. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35440. * @param key the unique key that identifies the data
  35441. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35442. * @return the associated data, can be null if the factory returned null.
  35443. */
  35444. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35445. /**
  35446. * Remove an externaly attached data from the Engine instance
  35447. * @param key the unique key that identifies the data
  35448. * @return true if the data was successfully removed, false if it doesn't exist
  35449. */
  35450. removeExternalData(key: string): boolean;
  35451. private _evaluateSubMesh;
  35452. /**
  35453. * Clear the processed materials smart array preventing retention point in material dispose.
  35454. */
  35455. freeProcessedMaterials(): void;
  35456. private _preventFreeActiveMeshesAndRenderingGroups;
  35457. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35458. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35459. * when disposing several meshes in a row or a hierarchy of meshes.
  35460. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35461. */
  35462. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35463. /**
  35464. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35465. */
  35466. freeActiveMeshes(): void;
  35467. /**
  35468. * Clear the info related to rendering groups preventing retention points during dispose.
  35469. */
  35470. freeRenderingGroups(): void;
  35471. /** @hidden */
  35472. _isInIntermediateRendering(): boolean;
  35473. /**
  35474. * Lambda returning the list of potentially active meshes.
  35475. */
  35476. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35477. /**
  35478. * Lambda returning the list of potentially active sub meshes.
  35479. */
  35480. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35481. /**
  35482. * Lambda returning the list of potentially intersecting sub meshes.
  35483. */
  35484. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35485. /**
  35486. * Lambda returning the list of potentially colliding sub meshes.
  35487. */
  35488. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35489. private _activeMeshesFrozen;
  35490. /**
  35491. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35492. * @returns the current scene
  35493. */
  35494. freezeActiveMeshes(): Scene;
  35495. /**
  35496. * Use this function to restart evaluating active meshes on every frame
  35497. * @returns the current scene
  35498. */
  35499. unfreezeActiveMeshes(): Scene;
  35500. private _evaluateActiveMeshes;
  35501. private _activeMesh;
  35502. /**
  35503. * Update the transform matrix to update from the current active camera
  35504. * @param force defines a boolean used to force the update even if cache is up to date
  35505. */
  35506. updateTransformMatrix(force?: boolean): void;
  35507. private _bindFrameBuffer;
  35508. /** @hidden */
  35509. _allowPostProcessClearColor: boolean;
  35510. /** @hidden */
  35511. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35512. private _processSubCameras;
  35513. private _checkIntersections;
  35514. /** @hidden */
  35515. _advancePhysicsEngineStep(step: number): void;
  35516. /**
  35517. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35518. */
  35519. getDeterministicFrameTime: () => number;
  35520. /** @hidden */
  35521. _animate(): void;
  35522. /** Execute all animations (for a frame) */
  35523. animate(): void;
  35524. /**
  35525. * Render the scene
  35526. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35527. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35528. */
  35529. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35530. /**
  35531. * Freeze all materials
  35532. * A frozen material will not be updatable but should be faster to render
  35533. */
  35534. freezeMaterials(): void;
  35535. /**
  35536. * Unfreeze all materials
  35537. * A frozen material will not be updatable but should be faster to render
  35538. */
  35539. unfreezeMaterials(): void;
  35540. /**
  35541. * Releases all held ressources
  35542. */
  35543. dispose(): void;
  35544. /**
  35545. * Gets if the scene is already disposed
  35546. */
  35547. readonly isDisposed: boolean;
  35548. /**
  35549. * Call this function to reduce memory footprint of the scene.
  35550. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35551. */
  35552. clearCachedVertexData(): void;
  35553. /**
  35554. * This function will remove the local cached buffer data from texture.
  35555. * It will save memory but will prevent the texture from being rebuilt
  35556. */
  35557. cleanCachedTextureBuffer(): void;
  35558. /**
  35559. * Get the world extend vectors with an optional filter
  35560. *
  35561. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35562. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35563. */
  35564. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35565. min: Vector3;
  35566. max: Vector3;
  35567. };
  35568. /**
  35569. * Creates a ray that can be used to pick in the scene
  35570. * @param x defines the x coordinate of the origin (on-screen)
  35571. * @param y defines the y coordinate of the origin (on-screen)
  35572. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35573. * @param camera defines the camera to use for the picking
  35574. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35575. * @returns a Ray
  35576. */
  35577. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35578. /**
  35579. * Creates a ray that can be used to pick in the scene
  35580. * @param x defines the x coordinate of the origin (on-screen)
  35581. * @param y defines the y coordinate of the origin (on-screen)
  35582. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35583. * @param result defines the ray where to store the picking ray
  35584. * @param camera defines the camera to use for the picking
  35585. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35586. * @returns the current scene
  35587. */
  35588. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35589. /**
  35590. * Creates a ray that can be used to pick in the scene
  35591. * @param x defines the x coordinate of the origin (on-screen)
  35592. * @param y defines the y coordinate of the origin (on-screen)
  35593. * @param camera defines the camera to use for the picking
  35594. * @returns a Ray
  35595. */
  35596. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35597. /**
  35598. * Creates a ray that can be used to pick in the scene
  35599. * @param x defines the x coordinate of the origin (on-screen)
  35600. * @param y defines the y coordinate of the origin (on-screen)
  35601. * @param result defines the ray where to store the picking ray
  35602. * @param camera defines the camera to use for the picking
  35603. * @returns the current scene
  35604. */
  35605. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35606. /** Launch a ray to try to pick a mesh in the scene
  35607. * @param x position on screen
  35608. * @param y position on screen
  35609. * @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
  35610. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35611. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35612. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35613. * @returns a PickingInfo
  35614. */
  35615. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35616. /** Use the given ray to pick a mesh in the scene
  35617. * @param ray The ray to use to pick meshes
  35618. * @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
  35619. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35620. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35621. * @returns a PickingInfo
  35622. */
  35623. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35624. /**
  35625. * Launch a ray to try to pick a mesh in the scene
  35626. * @param x X position on screen
  35627. * @param y Y position on screen
  35628. * @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
  35629. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35630. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35631. * @returns an array of PickingInfo
  35632. */
  35633. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35634. /**
  35635. * Launch a ray to try to pick a mesh in the scene
  35636. * @param ray Ray to use
  35637. * @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
  35638. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35639. * @returns an array of PickingInfo
  35640. */
  35641. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35642. /**
  35643. * Force the value of meshUnderPointer
  35644. * @param mesh defines the mesh to use
  35645. */
  35646. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35647. /**
  35648. * Gets the mesh under the pointer
  35649. * @returns a Mesh or null if no mesh is under the pointer
  35650. */
  35651. getPointerOverMesh(): Nullable<AbstractMesh>;
  35652. /** @hidden */
  35653. _rebuildGeometries(): void;
  35654. /** @hidden */
  35655. _rebuildTextures(): void;
  35656. private _getByTags;
  35657. /**
  35658. * Get a list of meshes by tags
  35659. * @param tagsQuery defines the tags query to use
  35660. * @param forEach defines a predicate used to filter results
  35661. * @returns an array of Mesh
  35662. */
  35663. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35664. /**
  35665. * Get a list of cameras by tags
  35666. * @param tagsQuery defines the tags query to use
  35667. * @param forEach defines a predicate used to filter results
  35668. * @returns an array of Camera
  35669. */
  35670. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35671. /**
  35672. * Get a list of lights by tags
  35673. * @param tagsQuery defines the tags query to use
  35674. * @param forEach defines a predicate used to filter results
  35675. * @returns an array of Light
  35676. */
  35677. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35678. /**
  35679. * Get a list of materials by tags
  35680. * @param tagsQuery defines the tags query to use
  35681. * @param forEach defines a predicate used to filter results
  35682. * @returns an array of Material
  35683. */
  35684. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35685. /**
  35686. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35687. * This allowed control for front to back rendering or reversly depending of the special needs.
  35688. *
  35689. * @param renderingGroupId The rendering group id corresponding to its index
  35690. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35691. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35692. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35693. */
  35694. 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;
  35695. /**
  35696. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35697. *
  35698. * @param renderingGroupId The rendering group id corresponding to its index
  35699. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35700. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35701. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35702. */
  35703. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35704. /**
  35705. * Gets the current auto clear configuration for one rendering group of the rendering
  35706. * manager.
  35707. * @param index the rendering group index to get the information for
  35708. * @returns The auto clear setup for the requested rendering group
  35709. */
  35710. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35711. private _blockMaterialDirtyMechanism;
  35712. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35713. blockMaterialDirtyMechanism: boolean;
  35714. /**
  35715. * Will flag all materials as dirty to trigger new shader compilation
  35716. * @param flag defines the flag used to specify which material part must be marked as dirty
  35717. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35718. */
  35719. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35720. /** @hidden */
  35721. _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;
  35722. /** @hidden */
  35723. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35724. }
  35725. }
  35726. declare module "babylonjs/assetContainer" {
  35727. import { AbstractScene } from "babylonjs/abstractScene";
  35728. import { Scene } from "babylonjs/scene";
  35729. import { Mesh } from "babylonjs/Meshes/mesh";
  35730. /**
  35731. * Set of assets to keep when moving a scene into an asset container.
  35732. */
  35733. export class KeepAssets extends AbstractScene {
  35734. }
  35735. /**
  35736. * Container with a set of assets that can be added or removed from a scene.
  35737. */
  35738. export class AssetContainer extends AbstractScene {
  35739. /**
  35740. * The scene the AssetContainer belongs to.
  35741. */
  35742. scene: Scene;
  35743. /**
  35744. * Instantiates an AssetContainer.
  35745. * @param scene The scene the AssetContainer belongs to.
  35746. */
  35747. constructor(scene: Scene);
  35748. /**
  35749. * Adds all the assets from the container to the scene.
  35750. */
  35751. addAllToScene(): void;
  35752. /**
  35753. * Removes all the assets in the container from the scene
  35754. */
  35755. removeAllFromScene(): void;
  35756. /**
  35757. * Disposes all the assets in the container
  35758. */
  35759. dispose(): void;
  35760. private _moveAssets;
  35761. /**
  35762. * Removes all the assets contained in the scene and adds them to the container.
  35763. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35764. */
  35765. moveAllFromScene(keepAssets?: KeepAssets): void;
  35766. /**
  35767. * 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.
  35768. * @returns the root mesh
  35769. */
  35770. createRootMesh(): Mesh;
  35771. }
  35772. }
  35773. declare module "babylonjs/abstractScene" {
  35774. import { Scene } from "babylonjs/scene";
  35775. import { Nullable } from "babylonjs/types";
  35776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35777. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35778. import { Geometry } from "babylonjs/Meshes/geometry";
  35779. import { Skeleton } from "babylonjs/Bones/skeleton";
  35780. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35781. import { AssetContainer } from "babylonjs/assetContainer";
  35782. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35783. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35784. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35785. import { Material } from "babylonjs/Materials/material";
  35786. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35787. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35788. import { Camera } from "babylonjs/Cameras/camera";
  35789. import { Light } from "babylonjs/Lights/light";
  35790. import { Node } from "babylonjs/node";
  35791. import { Animation } from "babylonjs/Animations/animation";
  35792. /**
  35793. * Defines how the parser contract is defined.
  35794. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35795. */
  35796. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35797. /**
  35798. * Defines how the individual parser contract is defined.
  35799. * These parser can parse an individual asset
  35800. */
  35801. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35802. /**
  35803. * Base class of the scene acting as a container for the different elements composing a scene.
  35804. * This class is dynamically extended by the different components of the scene increasing
  35805. * flexibility and reducing coupling
  35806. */
  35807. export abstract class AbstractScene {
  35808. /**
  35809. * Stores the list of available parsers in the application.
  35810. */
  35811. private static _BabylonFileParsers;
  35812. /**
  35813. * Stores the list of available individual parsers in the application.
  35814. */
  35815. private static _IndividualBabylonFileParsers;
  35816. /**
  35817. * Adds a parser in the list of available ones
  35818. * @param name Defines the name of the parser
  35819. * @param parser Defines the parser to add
  35820. */
  35821. static AddParser(name: string, parser: BabylonFileParser): void;
  35822. /**
  35823. * Gets a general parser from the list of avaialble ones
  35824. * @param name Defines the name of the parser
  35825. * @returns the requested parser or null
  35826. */
  35827. static GetParser(name: string): Nullable<BabylonFileParser>;
  35828. /**
  35829. * Adds n individual parser in the list of available ones
  35830. * @param name Defines the name of the parser
  35831. * @param parser Defines the parser to add
  35832. */
  35833. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35834. /**
  35835. * Gets an individual parser from the list of avaialble ones
  35836. * @param name Defines the name of the parser
  35837. * @returns the requested parser or null
  35838. */
  35839. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35840. /**
  35841. * Parser json data and populate both a scene and its associated container object
  35842. * @param jsonData Defines the data to parse
  35843. * @param scene Defines the scene to parse the data for
  35844. * @param container Defines the container attached to the parsing sequence
  35845. * @param rootUrl Defines the root url of the data
  35846. */
  35847. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35848. /**
  35849. * Gets the list of root nodes (ie. nodes with no parent)
  35850. */
  35851. rootNodes: Node[];
  35852. /** All of the cameras added to this scene
  35853. * @see http://doc.babylonjs.com/babylon101/cameras
  35854. */
  35855. cameras: Camera[];
  35856. /**
  35857. * All of the lights added to this scene
  35858. * @see http://doc.babylonjs.com/babylon101/lights
  35859. */
  35860. lights: Light[];
  35861. /**
  35862. * All of the (abstract) meshes added to this scene
  35863. */
  35864. meshes: AbstractMesh[];
  35865. /**
  35866. * The list of skeletons added to the scene
  35867. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35868. */
  35869. skeletons: Skeleton[];
  35870. /**
  35871. * All of the particle systems added to this scene
  35872. * @see http://doc.babylonjs.com/babylon101/particles
  35873. */
  35874. particleSystems: IParticleSystem[];
  35875. /**
  35876. * Gets a list of Animations associated with the scene
  35877. */
  35878. animations: Animation[];
  35879. /**
  35880. * All of the animation groups added to this scene
  35881. * @see http://doc.babylonjs.com/how_to/group
  35882. */
  35883. animationGroups: AnimationGroup[];
  35884. /**
  35885. * All of the multi-materials added to this scene
  35886. * @see http://doc.babylonjs.com/how_to/multi_materials
  35887. */
  35888. multiMaterials: MultiMaterial[];
  35889. /**
  35890. * All of the materials added to this scene
  35891. * In the context of a Scene, it is not supposed to be modified manually.
  35892. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35893. * Note also that the order of the Material wihin the array is not significant and might change.
  35894. * @see http://doc.babylonjs.com/babylon101/materials
  35895. */
  35896. materials: Material[];
  35897. /**
  35898. * The list of morph target managers added to the scene
  35899. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35900. */
  35901. morphTargetManagers: MorphTargetManager[];
  35902. /**
  35903. * The list of geometries used in the scene.
  35904. */
  35905. geometries: Geometry[];
  35906. /**
  35907. * All of the tranform nodes added to this scene
  35908. * In the context of a Scene, it is not supposed to be modified manually.
  35909. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35910. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35911. * @see http://doc.babylonjs.com/how_to/transformnode
  35912. */
  35913. transformNodes: TransformNode[];
  35914. /**
  35915. * ActionManagers available on the scene.
  35916. */
  35917. actionManagers: AbstractActionManager[];
  35918. /**
  35919. * Textures to keep.
  35920. */
  35921. textures: BaseTexture[];
  35922. /**
  35923. * Environment texture for the scene
  35924. */
  35925. environmentTexture: Nullable<BaseTexture>;
  35926. }
  35927. }
  35928. declare module "babylonjs/Audio/sound" {
  35929. import { Observable } from "babylonjs/Misc/observable";
  35930. import { Vector3 } from "babylonjs/Maths/math.vector";
  35931. import { Nullable } from "babylonjs/types";
  35932. import { Scene } from "babylonjs/scene";
  35933. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35934. /**
  35935. * Interface used to define options for Sound class
  35936. */
  35937. export interface ISoundOptions {
  35938. /**
  35939. * Does the sound autoplay once loaded.
  35940. */
  35941. autoplay?: boolean;
  35942. /**
  35943. * Does the sound loop after it finishes playing once.
  35944. */
  35945. loop?: boolean;
  35946. /**
  35947. * Sound's volume
  35948. */
  35949. volume?: number;
  35950. /**
  35951. * Is it a spatial sound?
  35952. */
  35953. spatialSound?: boolean;
  35954. /**
  35955. * Maximum distance to hear that sound
  35956. */
  35957. maxDistance?: number;
  35958. /**
  35959. * Uses user defined attenuation function
  35960. */
  35961. useCustomAttenuation?: boolean;
  35962. /**
  35963. * Define the roll off factor of spatial sounds.
  35964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35965. */
  35966. rolloffFactor?: number;
  35967. /**
  35968. * Define the reference distance the sound should be heard perfectly.
  35969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35970. */
  35971. refDistance?: number;
  35972. /**
  35973. * Define the distance attenuation model the sound will follow.
  35974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35975. */
  35976. distanceModel?: string;
  35977. /**
  35978. * Defines the playback speed (1 by default)
  35979. */
  35980. playbackRate?: number;
  35981. /**
  35982. * Defines if the sound is from a streaming source
  35983. */
  35984. streaming?: boolean;
  35985. /**
  35986. * Defines an optional length (in seconds) inside the sound file
  35987. */
  35988. length?: number;
  35989. /**
  35990. * Defines an optional offset (in seconds) inside the sound file
  35991. */
  35992. offset?: number;
  35993. /**
  35994. * If true, URLs will not be required to state the audio file codec to use.
  35995. */
  35996. skipCodecCheck?: boolean;
  35997. }
  35998. /**
  35999. * Defines a sound that can be played in the application.
  36000. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36002. */
  36003. export class Sound {
  36004. /**
  36005. * The name of the sound in the scene.
  36006. */
  36007. name: string;
  36008. /**
  36009. * Does the sound autoplay once loaded.
  36010. */
  36011. autoplay: boolean;
  36012. /**
  36013. * Does the sound loop after it finishes playing once.
  36014. */
  36015. loop: boolean;
  36016. /**
  36017. * Does the sound use a custom attenuation curve to simulate the falloff
  36018. * happening when the source gets further away from the camera.
  36019. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36020. */
  36021. useCustomAttenuation: boolean;
  36022. /**
  36023. * The sound track id this sound belongs to.
  36024. */
  36025. soundTrackId: number;
  36026. /**
  36027. * Is this sound currently played.
  36028. */
  36029. isPlaying: boolean;
  36030. /**
  36031. * Is this sound currently paused.
  36032. */
  36033. isPaused: boolean;
  36034. /**
  36035. * Does this sound enables spatial sound.
  36036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36037. */
  36038. spatialSound: boolean;
  36039. /**
  36040. * Define the reference distance the sound should be heard perfectly.
  36041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36042. */
  36043. refDistance: number;
  36044. /**
  36045. * Define the roll off factor of spatial sounds.
  36046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36047. */
  36048. rolloffFactor: number;
  36049. /**
  36050. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36052. */
  36053. maxDistance: number;
  36054. /**
  36055. * Define the distance attenuation model the sound will follow.
  36056. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36057. */
  36058. distanceModel: string;
  36059. /**
  36060. * @hidden
  36061. * Back Compat
  36062. **/
  36063. onended: () => any;
  36064. /**
  36065. * Observable event when the current playing sound finishes.
  36066. */
  36067. onEndedObservable: Observable<Sound>;
  36068. private _panningModel;
  36069. private _playbackRate;
  36070. private _streaming;
  36071. private _startTime;
  36072. private _startOffset;
  36073. private _position;
  36074. /** @hidden */
  36075. _positionInEmitterSpace: boolean;
  36076. private _localDirection;
  36077. private _volume;
  36078. private _isReadyToPlay;
  36079. private _isDirectional;
  36080. private _readyToPlayCallback;
  36081. private _audioBuffer;
  36082. private _soundSource;
  36083. private _streamingSource;
  36084. private _soundPanner;
  36085. private _soundGain;
  36086. private _inputAudioNode;
  36087. private _outputAudioNode;
  36088. private _coneInnerAngle;
  36089. private _coneOuterAngle;
  36090. private _coneOuterGain;
  36091. private _scene;
  36092. private _connectedTransformNode;
  36093. private _customAttenuationFunction;
  36094. private _registerFunc;
  36095. private _isOutputConnected;
  36096. private _htmlAudioElement;
  36097. private _urlType;
  36098. private _length?;
  36099. private _offset?;
  36100. /** @hidden */
  36101. static _SceneComponentInitialization: (scene: Scene) => void;
  36102. /**
  36103. * Create a sound and attach it to a scene
  36104. * @param name Name of your sound
  36105. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36106. * @param scene defines the scene the sound belongs to
  36107. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36108. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36109. */
  36110. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36111. /**
  36112. * Release the sound and its associated resources
  36113. */
  36114. dispose(): void;
  36115. /**
  36116. * Gets if the sounds is ready to be played or not.
  36117. * @returns true if ready, otherwise false
  36118. */
  36119. isReady(): boolean;
  36120. private _soundLoaded;
  36121. /**
  36122. * Sets the data of the sound from an audiobuffer
  36123. * @param audioBuffer The audioBuffer containing the data
  36124. */
  36125. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36126. /**
  36127. * Updates the current sounds options such as maxdistance, loop...
  36128. * @param options A JSON object containing values named as the object properties
  36129. */
  36130. updateOptions(options: ISoundOptions): void;
  36131. private _createSpatialParameters;
  36132. private _updateSpatialParameters;
  36133. /**
  36134. * Switch the panning model to HRTF:
  36135. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36136. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36137. */
  36138. switchPanningModelToHRTF(): void;
  36139. /**
  36140. * Switch the panning model to Equal Power:
  36141. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36143. */
  36144. switchPanningModelToEqualPower(): void;
  36145. private _switchPanningModel;
  36146. /**
  36147. * Connect this sound to a sound track audio node like gain...
  36148. * @param soundTrackAudioNode the sound track audio node to connect to
  36149. */
  36150. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36151. /**
  36152. * Transform this sound into a directional source
  36153. * @param coneInnerAngle Size of the inner cone in degree
  36154. * @param coneOuterAngle Size of the outer cone in degree
  36155. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36156. */
  36157. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36158. /**
  36159. * Gets or sets the inner angle for the directional cone.
  36160. */
  36161. /**
  36162. * Gets or sets the inner angle for the directional cone.
  36163. */
  36164. directionalConeInnerAngle: number;
  36165. /**
  36166. * Gets or sets the outer angle for the directional cone.
  36167. */
  36168. /**
  36169. * Gets or sets the outer angle for the directional cone.
  36170. */
  36171. directionalConeOuterAngle: number;
  36172. /**
  36173. * Sets the position of the emitter if spatial sound is enabled
  36174. * @param newPosition Defines the new posisiton
  36175. */
  36176. setPosition(newPosition: Vector3): void;
  36177. /**
  36178. * Sets the local direction of the emitter if spatial sound is enabled
  36179. * @param newLocalDirection Defines the new local direction
  36180. */
  36181. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36182. private _updateDirection;
  36183. /** @hidden */
  36184. updateDistanceFromListener(): void;
  36185. /**
  36186. * Sets a new custom attenuation function for the sound.
  36187. * @param callback Defines the function used for the attenuation
  36188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36189. */
  36190. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36191. /**
  36192. * Play the sound
  36193. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36194. * @param offset (optional) Start the sound at a specific time in seconds
  36195. * @param length (optional) Sound duration (in seconds)
  36196. */
  36197. play(time?: number, offset?: number, length?: number): void;
  36198. private _onended;
  36199. /**
  36200. * Stop the sound
  36201. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36202. */
  36203. stop(time?: number): void;
  36204. /**
  36205. * Put the sound in pause
  36206. */
  36207. pause(): void;
  36208. /**
  36209. * Sets a dedicated volume for this sounds
  36210. * @param newVolume Define the new volume of the sound
  36211. * @param time Define time for gradual change to new volume
  36212. */
  36213. setVolume(newVolume: number, time?: number): void;
  36214. /**
  36215. * Set the sound play back rate
  36216. * @param newPlaybackRate Define the playback rate the sound should be played at
  36217. */
  36218. setPlaybackRate(newPlaybackRate: number): void;
  36219. /**
  36220. * Gets the volume of the sound.
  36221. * @returns the volume of the sound
  36222. */
  36223. getVolume(): number;
  36224. /**
  36225. * Attach the sound to a dedicated mesh
  36226. * @param transformNode The transform node to connect the sound with
  36227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36228. */
  36229. attachToMesh(transformNode: TransformNode): void;
  36230. /**
  36231. * Detach the sound from the previously attached mesh
  36232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36233. */
  36234. detachFromMesh(): void;
  36235. private _onRegisterAfterWorldMatrixUpdate;
  36236. /**
  36237. * Clone the current sound in the scene.
  36238. * @returns the new sound clone
  36239. */
  36240. clone(): Nullable<Sound>;
  36241. /**
  36242. * Gets the current underlying audio buffer containing the data
  36243. * @returns the audio buffer
  36244. */
  36245. getAudioBuffer(): Nullable<AudioBuffer>;
  36246. /**
  36247. * Serializes the Sound in a JSON representation
  36248. * @returns the JSON representation of the sound
  36249. */
  36250. serialize(): any;
  36251. /**
  36252. * Parse a JSON representation of a sound to innstantiate in a given scene
  36253. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36254. * @param scene Define the scene the new parsed sound should be created in
  36255. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36256. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36257. * @returns the newly parsed sound
  36258. */
  36259. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36260. }
  36261. }
  36262. declare module "babylonjs/Actions/directAudioActions" {
  36263. import { Action } from "babylonjs/Actions/action";
  36264. import { Condition } from "babylonjs/Actions/condition";
  36265. import { Sound } from "babylonjs/Audio/sound";
  36266. /**
  36267. * This defines an action helpful to play a defined sound on a triggered action.
  36268. */
  36269. export class PlaySoundAction extends Action {
  36270. private _sound;
  36271. /**
  36272. * Instantiate the action
  36273. * @param triggerOptions defines the trigger options
  36274. * @param sound defines the sound to play
  36275. * @param condition defines the trigger related conditions
  36276. */
  36277. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36278. /** @hidden */
  36279. _prepare(): void;
  36280. /**
  36281. * Execute the action and play the sound.
  36282. */
  36283. execute(): void;
  36284. /**
  36285. * Serializes the actions and its related information.
  36286. * @param parent defines the object to serialize in
  36287. * @returns the serialized object
  36288. */
  36289. serialize(parent: any): any;
  36290. }
  36291. /**
  36292. * This defines an action helpful to stop a defined sound on a triggered action.
  36293. */
  36294. export class StopSoundAction extends Action {
  36295. private _sound;
  36296. /**
  36297. * Instantiate the action
  36298. * @param triggerOptions defines the trigger options
  36299. * @param sound defines the sound to stop
  36300. * @param condition defines the trigger related conditions
  36301. */
  36302. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36303. /** @hidden */
  36304. _prepare(): void;
  36305. /**
  36306. * Execute the action and stop the sound.
  36307. */
  36308. execute(): void;
  36309. /**
  36310. * Serializes the actions and its related information.
  36311. * @param parent defines the object to serialize in
  36312. * @returns the serialized object
  36313. */
  36314. serialize(parent: any): any;
  36315. }
  36316. }
  36317. declare module "babylonjs/Actions/interpolateValueAction" {
  36318. import { Action } from "babylonjs/Actions/action";
  36319. import { Condition } from "babylonjs/Actions/condition";
  36320. import { Observable } from "babylonjs/Misc/observable";
  36321. /**
  36322. * This defines an action responsible to change the value of a property
  36323. * by interpolating between its current value and the newly set one once triggered.
  36324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36325. */
  36326. export class InterpolateValueAction extends Action {
  36327. /**
  36328. * Defines the path of the property where the value should be interpolated
  36329. */
  36330. propertyPath: string;
  36331. /**
  36332. * Defines the target value at the end of the interpolation.
  36333. */
  36334. value: any;
  36335. /**
  36336. * Defines the time it will take for the property to interpolate to the value.
  36337. */
  36338. duration: number;
  36339. /**
  36340. * Defines if the other scene animations should be stopped when the action has been triggered
  36341. */
  36342. stopOtherAnimations?: boolean;
  36343. /**
  36344. * Defines a callback raised once the interpolation animation has been done.
  36345. */
  36346. onInterpolationDone?: () => void;
  36347. /**
  36348. * Observable triggered once the interpolation animation has been done.
  36349. */
  36350. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36351. private _target;
  36352. private _effectiveTarget;
  36353. private _property;
  36354. /**
  36355. * Instantiate the action
  36356. * @param triggerOptions defines the trigger options
  36357. * @param target defines the object containing the value to interpolate
  36358. * @param propertyPath defines the path to the property in the target object
  36359. * @param value defines the target value at the end of the interpolation
  36360. * @param duration deines the time it will take for the property to interpolate to the value.
  36361. * @param condition defines the trigger related conditions
  36362. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36363. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36364. */
  36365. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36366. /** @hidden */
  36367. _prepare(): void;
  36368. /**
  36369. * Execute the action starts the value interpolation.
  36370. */
  36371. execute(): void;
  36372. /**
  36373. * Serializes the actions and its related information.
  36374. * @param parent defines the object to serialize in
  36375. * @returns the serialized object
  36376. */
  36377. serialize(parent: any): any;
  36378. }
  36379. }
  36380. declare module "babylonjs/Actions/index" {
  36381. export * from "babylonjs/Actions/abstractActionManager";
  36382. export * from "babylonjs/Actions/action";
  36383. export * from "babylonjs/Actions/actionEvent";
  36384. export * from "babylonjs/Actions/actionManager";
  36385. export * from "babylonjs/Actions/condition";
  36386. export * from "babylonjs/Actions/directActions";
  36387. export * from "babylonjs/Actions/directAudioActions";
  36388. export * from "babylonjs/Actions/interpolateValueAction";
  36389. }
  36390. declare module "babylonjs/Animations/index" {
  36391. export * from "babylonjs/Animations/animatable";
  36392. export * from "babylonjs/Animations/animation";
  36393. export * from "babylonjs/Animations/animationGroup";
  36394. export * from "babylonjs/Animations/animationPropertiesOverride";
  36395. export * from "babylonjs/Animations/easing";
  36396. export * from "babylonjs/Animations/runtimeAnimation";
  36397. export * from "babylonjs/Animations/animationEvent";
  36398. export * from "babylonjs/Animations/animationGroup";
  36399. export * from "babylonjs/Animations/animationKey";
  36400. export * from "babylonjs/Animations/animationRange";
  36401. export * from "babylonjs/Animations/animatable.interface";
  36402. }
  36403. declare module "babylonjs/Audio/soundTrack" {
  36404. import { Sound } from "babylonjs/Audio/sound";
  36405. import { Analyser } from "babylonjs/Audio/analyser";
  36406. import { Scene } from "babylonjs/scene";
  36407. /**
  36408. * Options allowed during the creation of a sound track.
  36409. */
  36410. export interface ISoundTrackOptions {
  36411. /**
  36412. * The volume the sound track should take during creation
  36413. */
  36414. volume?: number;
  36415. /**
  36416. * Define if the sound track is the main sound track of the scene
  36417. */
  36418. mainTrack?: boolean;
  36419. }
  36420. /**
  36421. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36422. * It will be also used in a future release to apply effects on a specific track.
  36423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36424. */
  36425. export class SoundTrack {
  36426. /**
  36427. * The unique identifier of the sound track in the scene.
  36428. */
  36429. id: number;
  36430. /**
  36431. * The list of sounds included in the sound track.
  36432. */
  36433. soundCollection: Array<Sound>;
  36434. private _outputAudioNode;
  36435. private _scene;
  36436. private _isMainTrack;
  36437. private _connectedAnalyser;
  36438. private _options;
  36439. private _isInitialized;
  36440. /**
  36441. * Creates a new sound track.
  36442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36443. * @param scene Define the scene the sound track belongs to
  36444. * @param options
  36445. */
  36446. constructor(scene: Scene, options?: ISoundTrackOptions);
  36447. private _initializeSoundTrackAudioGraph;
  36448. /**
  36449. * Release the sound track and its associated resources
  36450. */
  36451. dispose(): void;
  36452. /**
  36453. * Adds a sound to this sound track
  36454. * @param sound define the cound to add
  36455. * @ignoreNaming
  36456. */
  36457. AddSound(sound: Sound): void;
  36458. /**
  36459. * Removes a sound to this sound track
  36460. * @param sound define the cound to remove
  36461. * @ignoreNaming
  36462. */
  36463. RemoveSound(sound: Sound): void;
  36464. /**
  36465. * Set a global volume for the full sound track.
  36466. * @param newVolume Define the new volume of the sound track
  36467. */
  36468. setVolume(newVolume: number): void;
  36469. /**
  36470. * Switch the panning model to HRTF:
  36471. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36472. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36473. */
  36474. switchPanningModelToHRTF(): void;
  36475. /**
  36476. * Switch the panning model to Equal Power:
  36477. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36479. */
  36480. switchPanningModelToEqualPower(): void;
  36481. /**
  36482. * Connect the sound track to an audio analyser allowing some amazing
  36483. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36484. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36485. * @param analyser The analyser to connect to the engine
  36486. */
  36487. connectToAnalyser(analyser: Analyser): void;
  36488. }
  36489. }
  36490. declare module "babylonjs/Audio/audioSceneComponent" {
  36491. import { Sound } from "babylonjs/Audio/sound";
  36492. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36493. import { Nullable } from "babylonjs/types";
  36494. import { Vector3 } from "babylonjs/Maths/math.vector";
  36495. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36496. import { Scene } from "babylonjs/scene";
  36497. import { AbstractScene } from "babylonjs/abstractScene";
  36498. import "babylonjs/Audio/audioEngine";
  36499. module "babylonjs/abstractScene" {
  36500. interface AbstractScene {
  36501. /**
  36502. * The list of sounds used in the scene.
  36503. */
  36504. sounds: Nullable<Array<Sound>>;
  36505. }
  36506. }
  36507. module "babylonjs/scene" {
  36508. interface Scene {
  36509. /**
  36510. * @hidden
  36511. * Backing field
  36512. */
  36513. _mainSoundTrack: SoundTrack;
  36514. /**
  36515. * The main sound track played by the scene.
  36516. * It cotains your primary collection of sounds.
  36517. */
  36518. mainSoundTrack: SoundTrack;
  36519. /**
  36520. * The list of sound tracks added to the scene
  36521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36522. */
  36523. soundTracks: Nullable<Array<SoundTrack>>;
  36524. /**
  36525. * Gets a sound using a given name
  36526. * @param name defines the name to search for
  36527. * @return the found sound or null if not found at all.
  36528. */
  36529. getSoundByName(name: string): Nullable<Sound>;
  36530. /**
  36531. * Gets or sets if audio support is enabled
  36532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36533. */
  36534. audioEnabled: boolean;
  36535. /**
  36536. * Gets or sets if audio will be output to headphones
  36537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36538. */
  36539. headphone: boolean;
  36540. /**
  36541. * Gets or sets custom audio listener position provider
  36542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36543. */
  36544. audioListenerPositionProvider: Nullable<() => Vector3>;
  36545. }
  36546. }
  36547. /**
  36548. * Defines the sound scene component responsible to manage any sounds
  36549. * in a given scene.
  36550. */
  36551. export class AudioSceneComponent implements ISceneSerializableComponent {
  36552. /**
  36553. * The component name helpfull to identify the component in the list of scene components.
  36554. */
  36555. readonly name: string;
  36556. /**
  36557. * The scene the component belongs to.
  36558. */
  36559. scene: Scene;
  36560. private _audioEnabled;
  36561. /**
  36562. * Gets whether audio is enabled or not.
  36563. * Please use related enable/disable method to switch state.
  36564. */
  36565. readonly audioEnabled: boolean;
  36566. private _headphone;
  36567. /**
  36568. * Gets whether audio is outputing to headphone or not.
  36569. * Please use the according Switch methods to change output.
  36570. */
  36571. readonly headphone: boolean;
  36572. private _audioListenerPositionProvider;
  36573. /**
  36574. * Gets the current audio listener position provider
  36575. */
  36576. /**
  36577. * Sets a custom listener position for all sounds in the scene
  36578. * By default, this is the position of the first active camera
  36579. */
  36580. audioListenerPositionProvider: Nullable<() => Vector3>;
  36581. /**
  36582. * Creates a new instance of the component for the given scene
  36583. * @param scene Defines the scene to register the component in
  36584. */
  36585. constructor(scene: Scene);
  36586. /**
  36587. * Registers the component in a given scene
  36588. */
  36589. register(): void;
  36590. /**
  36591. * Rebuilds the elements related to this component in case of
  36592. * context lost for instance.
  36593. */
  36594. rebuild(): void;
  36595. /**
  36596. * Serializes the component data to the specified json object
  36597. * @param serializationObject The object to serialize to
  36598. */
  36599. serialize(serializationObject: any): void;
  36600. /**
  36601. * Adds all the elements from the container to the scene
  36602. * @param container the container holding the elements
  36603. */
  36604. addFromContainer(container: AbstractScene): void;
  36605. /**
  36606. * Removes all the elements in the container from the scene
  36607. * @param container contains the elements to remove
  36608. * @param dispose if the removed element should be disposed (default: false)
  36609. */
  36610. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36611. /**
  36612. * Disposes the component and the associated ressources.
  36613. */
  36614. dispose(): void;
  36615. /**
  36616. * Disables audio in the associated scene.
  36617. */
  36618. disableAudio(): void;
  36619. /**
  36620. * Enables audio in the associated scene.
  36621. */
  36622. enableAudio(): void;
  36623. /**
  36624. * Switch audio to headphone output.
  36625. */
  36626. switchAudioModeForHeadphones(): void;
  36627. /**
  36628. * Switch audio to normal speakers.
  36629. */
  36630. switchAudioModeForNormalSpeakers(): void;
  36631. private _afterRender;
  36632. }
  36633. }
  36634. declare module "babylonjs/Audio/weightedsound" {
  36635. import { Sound } from "babylonjs/Audio/sound";
  36636. /**
  36637. * Wraps one or more Sound objects and selects one with random weight for playback.
  36638. */
  36639. export class WeightedSound {
  36640. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36641. loop: boolean;
  36642. private _coneInnerAngle;
  36643. private _coneOuterAngle;
  36644. private _volume;
  36645. /** A Sound is currently playing. */
  36646. isPlaying: boolean;
  36647. /** A Sound is currently paused. */
  36648. isPaused: boolean;
  36649. private _sounds;
  36650. private _weights;
  36651. private _currentIndex?;
  36652. /**
  36653. * Creates a new WeightedSound from the list of sounds given.
  36654. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36655. * @param sounds Array of Sounds that will be selected from.
  36656. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36657. */
  36658. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36659. /**
  36660. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36661. */
  36662. /**
  36663. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36664. */
  36665. directionalConeInnerAngle: number;
  36666. /**
  36667. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36668. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36669. */
  36670. /**
  36671. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36672. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36673. */
  36674. directionalConeOuterAngle: number;
  36675. /**
  36676. * Playback volume.
  36677. */
  36678. /**
  36679. * Playback volume.
  36680. */
  36681. volume: number;
  36682. private _onended;
  36683. /**
  36684. * Suspend playback
  36685. */
  36686. pause(): void;
  36687. /**
  36688. * Stop playback
  36689. */
  36690. stop(): void;
  36691. /**
  36692. * Start playback.
  36693. * @param startOffset Position the clip head at a specific time in seconds.
  36694. */
  36695. play(startOffset?: number): void;
  36696. }
  36697. }
  36698. declare module "babylonjs/Audio/index" {
  36699. export * from "babylonjs/Audio/analyser";
  36700. export * from "babylonjs/Audio/audioEngine";
  36701. export * from "babylonjs/Audio/audioSceneComponent";
  36702. export * from "babylonjs/Audio/sound";
  36703. export * from "babylonjs/Audio/soundTrack";
  36704. export * from "babylonjs/Audio/weightedsound";
  36705. }
  36706. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36707. import { Behavior } from "babylonjs/Behaviors/behavior";
  36708. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36709. import { BackEase } from "babylonjs/Animations/easing";
  36710. /**
  36711. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36712. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36713. */
  36714. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36715. /**
  36716. * Gets the name of the behavior.
  36717. */
  36718. readonly name: string;
  36719. /**
  36720. * The easing function used by animations
  36721. */
  36722. static EasingFunction: BackEase;
  36723. /**
  36724. * The easing mode used by animations
  36725. */
  36726. static EasingMode: number;
  36727. /**
  36728. * The duration of the animation, in milliseconds
  36729. */
  36730. transitionDuration: number;
  36731. /**
  36732. * Length of the distance animated by the transition when lower radius is reached
  36733. */
  36734. lowerRadiusTransitionRange: number;
  36735. /**
  36736. * Length of the distance animated by the transition when upper radius is reached
  36737. */
  36738. upperRadiusTransitionRange: number;
  36739. private _autoTransitionRange;
  36740. /**
  36741. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36742. */
  36743. /**
  36744. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36745. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36746. */
  36747. autoTransitionRange: boolean;
  36748. private _attachedCamera;
  36749. private _onAfterCheckInputsObserver;
  36750. private _onMeshTargetChangedObserver;
  36751. /**
  36752. * Initializes the behavior.
  36753. */
  36754. init(): void;
  36755. /**
  36756. * Attaches the behavior to its arc rotate camera.
  36757. * @param camera Defines the camera to attach the behavior to
  36758. */
  36759. attach(camera: ArcRotateCamera): void;
  36760. /**
  36761. * Detaches the behavior from its current arc rotate camera.
  36762. */
  36763. detach(): void;
  36764. private _radiusIsAnimating;
  36765. private _radiusBounceTransition;
  36766. private _animatables;
  36767. private _cachedWheelPrecision;
  36768. /**
  36769. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36770. * @param radiusLimit The limit to check against.
  36771. * @return Bool to indicate if at limit.
  36772. */
  36773. private _isRadiusAtLimit;
  36774. /**
  36775. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36776. * @param radiusDelta The delta by which to animate to. Can be negative.
  36777. */
  36778. private _applyBoundRadiusAnimation;
  36779. /**
  36780. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36781. */
  36782. protected _clearAnimationLocks(): void;
  36783. /**
  36784. * Stops and removes all animations that have been applied to the camera
  36785. */
  36786. stopAllAnimations(): void;
  36787. }
  36788. }
  36789. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36790. import { Behavior } from "babylonjs/Behaviors/behavior";
  36791. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36792. import { ExponentialEase } from "babylonjs/Animations/easing";
  36793. import { Nullable } from "babylonjs/types";
  36794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36795. import { Vector3 } from "babylonjs/Maths/math.vector";
  36796. /**
  36797. * 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.
  36798. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36799. */
  36800. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36801. /**
  36802. * Gets the name of the behavior.
  36803. */
  36804. readonly name: string;
  36805. private _mode;
  36806. private _radiusScale;
  36807. private _positionScale;
  36808. private _defaultElevation;
  36809. private _elevationReturnTime;
  36810. private _elevationReturnWaitTime;
  36811. private _zoomStopsAnimation;
  36812. private _framingTime;
  36813. /**
  36814. * The easing function used by animations
  36815. */
  36816. static EasingFunction: ExponentialEase;
  36817. /**
  36818. * The easing mode used by animations
  36819. */
  36820. static EasingMode: number;
  36821. /**
  36822. * Sets the current mode used by the behavior
  36823. */
  36824. /**
  36825. * Gets current mode used by the behavior.
  36826. */
  36827. mode: number;
  36828. /**
  36829. * Sets the scale applied to the radius (1 by default)
  36830. */
  36831. /**
  36832. * Gets the scale applied to the radius
  36833. */
  36834. radiusScale: number;
  36835. /**
  36836. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36837. */
  36838. /**
  36839. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36840. */
  36841. positionScale: number;
  36842. /**
  36843. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36844. * behaviour is triggered, in radians.
  36845. */
  36846. /**
  36847. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36848. * behaviour is triggered, in radians.
  36849. */
  36850. defaultElevation: number;
  36851. /**
  36852. * Sets the time (in milliseconds) taken to return to the default beta position.
  36853. * Negative value indicates camera should not return to default.
  36854. */
  36855. /**
  36856. * Gets the time (in milliseconds) taken to return to the default beta position.
  36857. * Negative value indicates camera should not return to default.
  36858. */
  36859. elevationReturnTime: number;
  36860. /**
  36861. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36862. */
  36863. /**
  36864. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36865. */
  36866. elevationReturnWaitTime: number;
  36867. /**
  36868. * Sets the flag that indicates if user zooming should stop animation.
  36869. */
  36870. /**
  36871. * Gets the flag that indicates if user zooming should stop animation.
  36872. */
  36873. zoomStopsAnimation: boolean;
  36874. /**
  36875. * Sets the transition time when framing the mesh, in milliseconds
  36876. */
  36877. /**
  36878. * Gets the transition time when framing the mesh, in milliseconds
  36879. */
  36880. framingTime: number;
  36881. /**
  36882. * Define if the behavior should automatically change the configured
  36883. * camera limits and sensibilities.
  36884. */
  36885. autoCorrectCameraLimitsAndSensibility: boolean;
  36886. private _onPrePointerObservableObserver;
  36887. private _onAfterCheckInputsObserver;
  36888. private _onMeshTargetChangedObserver;
  36889. private _attachedCamera;
  36890. private _isPointerDown;
  36891. private _lastInteractionTime;
  36892. /**
  36893. * Initializes the behavior.
  36894. */
  36895. init(): void;
  36896. /**
  36897. * Attaches the behavior to its arc rotate camera.
  36898. * @param camera Defines the camera to attach the behavior to
  36899. */
  36900. attach(camera: ArcRotateCamera): void;
  36901. /**
  36902. * Detaches the behavior from its current arc rotate camera.
  36903. */
  36904. detach(): void;
  36905. private _animatables;
  36906. private _betaIsAnimating;
  36907. private _betaTransition;
  36908. private _radiusTransition;
  36909. private _vectorTransition;
  36910. /**
  36911. * Targets the given mesh and updates zoom level accordingly.
  36912. * @param mesh The mesh to target.
  36913. * @param radius Optional. If a cached radius position already exists, overrides default.
  36914. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36915. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36916. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36917. */
  36918. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36919. /**
  36920. * Targets the given mesh with its children and updates zoom level accordingly.
  36921. * @param mesh The mesh to target.
  36922. * @param radius Optional. If a cached radius position already exists, overrides default.
  36923. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36924. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36925. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36926. */
  36927. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36928. /**
  36929. * Targets the given meshes with their children and updates zoom level accordingly.
  36930. * @param meshes The mesh to target.
  36931. * @param radius Optional. If a cached radius position already exists, overrides default.
  36932. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36933. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36934. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36935. */
  36936. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36937. /**
  36938. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36939. * @param minimumWorld Determines the smaller position of the bounding box extend
  36940. * @param maximumWorld Determines the bigger position of the bounding box extend
  36941. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36942. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36943. */
  36944. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36945. /**
  36946. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36947. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36948. * frustum width.
  36949. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36950. * to fully enclose the mesh in the viewing frustum.
  36951. */
  36952. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36953. /**
  36954. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36955. * is automatically returned to its default position (expected to be above ground plane).
  36956. */
  36957. private _maintainCameraAboveGround;
  36958. /**
  36959. * Returns the frustum slope based on the canvas ratio and camera FOV
  36960. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36961. */
  36962. private _getFrustumSlope;
  36963. /**
  36964. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36965. */
  36966. private _clearAnimationLocks;
  36967. /**
  36968. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36969. */
  36970. private _applyUserInteraction;
  36971. /**
  36972. * Stops and removes all animations that have been applied to the camera
  36973. */
  36974. stopAllAnimations(): void;
  36975. /**
  36976. * Gets a value indicating if the user is moving the camera
  36977. */
  36978. readonly isUserIsMoving: boolean;
  36979. /**
  36980. * The camera can move all the way towards the mesh.
  36981. */
  36982. static IgnoreBoundsSizeMode: number;
  36983. /**
  36984. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36985. */
  36986. static FitFrustumSidesMode: number;
  36987. }
  36988. }
  36989. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36990. import { Nullable } from "babylonjs/types";
  36991. import { Camera } from "babylonjs/Cameras/camera";
  36992. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36993. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36994. /**
  36995. * Base class for Camera Pointer Inputs.
  36996. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36997. * for example usage.
  36998. */
  36999. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37000. /**
  37001. * Defines the camera the input is attached to.
  37002. */
  37003. abstract camera: Camera;
  37004. /**
  37005. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37006. */
  37007. protected _altKey: boolean;
  37008. protected _ctrlKey: boolean;
  37009. protected _metaKey: boolean;
  37010. protected _shiftKey: boolean;
  37011. /**
  37012. * Which mouse buttons were pressed at time of last mouse event.
  37013. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37014. */
  37015. protected _buttonsPressed: number;
  37016. /**
  37017. * Defines the buttons associated with the input to handle camera move.
  37018. */
  37019. buttons: number[];
  37020. /**
  37021. * Attach the input controls to a specific dom element to get the input from.
  37022. * @param element Defines the element the controls should be listened from
  37023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37024. */
  37025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37026. /**
  37027. * Detach the current controls from the specified dom element.
  37028. * @param element Defines the element to stop listening the inputs from
  37029. */
  37030. detachControl(element: Nullable<HTMLElement>): void;
  37031. /**
  37032. * Gets the class name of the current input.
  37033. * @returns the class name
  37034. */
  37035. getClassName(): string;
  37036. /**
  37037. * Get the friendly name associated with the input class.
  37038. * @returns the input friendly name
  37039. */
  37040. getSimpleName(): string;
  37041. /**
  37042. * Called on pointer POINTERDOUBLETAP event.
  37043. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37044. */
  37045. protected onDoubleTap(type: string): void;
  37046. /**
  37047. * Called on pointer POINTERMOVE event if only a single touch is active.
  37048. * Override this method to provide functionality.
  37049. */
  37050. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37051. /**
  37052. * Called on pointer POINTERMOVE event if multiple touches are active.
  37053. * Override this method to provide functionality.
  37054. */
  37055. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37056. /**
  37057. * Called on JS contextmenu event.
  37058. * Override this method to provide functionality.
  37059. */
  37060. protected onContextMenu(evt: PointerEvent): void;
  37061. /**
  37062. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37063. * press.
  37064. * Override this method to provide functionality.
  37065. */
  37066. protected onButtonDown(evt: PointerEvent): void;
  37067. /**
  37068. * Called each time a new POINTERUP event occurs. Ie, for each button
  37069. * release.
  37070. * Override this method to provide functionality.
  37071. */
  37072. protected onButtonUp(evt: PointerEvent): void;
  37073. /**
  37074. * Called when window becomes inactive.
  37075. * Override this method to provide functionality.
  37076. */
  37077. protected onLostFocus(): void;
  37078. private _pointerInput;
  37079. private _observer;
  37080. private _onLostFocus;
  37081. private pointA;
  37082. private pointB;
  37083. }
  37084. }
  37085. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37086. import { Nullable } from "babylonjs/types";
  37087. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37088. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37089. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37090. /**
  37091. * Manage the pointers inputs to control an arc rotate camera.
  37092. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37093. */
  37094. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37095. /**
  37096. * Defines the camera the input is attached to.
  37097. */
  37098. camera: ArcRotateCamera;
  37099. /**
  37100. * Gets the class name of the current input.
  37101. * @returns the class name
  37102. */
  37103. getClassName(): string;
  37104. /**
  37105. * Defines the buttons associated with the input to handle camera move.
  37106. */
  37107. buttons: number[];
  37108. /**
  37109. * Defines the pointer angular sensibility along the X axis or how fast is
  37110. * the camera rotating.
  37111. */
  37112. angularSensibilityX: number;
  37113. /**
  37114. * Defines the pointer angular sensibility along the Y axis or how fast is
  37115. * the camera rotating.
  37116. */
  37117. angularSensibilityY: number;
  37118. /**
  37119. * Defines the pointer pinch precision or how fast is the camera zooming.
  37120. */
  37121. pinchPrecision: number;
  37122. /**
  37123. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37124. * from 0.
  37125. * It defines the percentage of current camera.radius to use as delta when
  37126. * pinch zoom is used.
  37127. */
  37128. pinchDeltaPercentage: number;
  37129. /**
  37130. * Defines the pointer panning sensibility or how fast is the camera moving.
  37131. */
  37132. panningSensibility: number;
  37133. /**
  37134. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37135. */
  37136. multiTouchPanning: boolean;
  37137. /**
  37138. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37139. * zoom (pinch) through multitouch.
  37140. */
  37141. multiTouchPanAndZoom: boolean;
  37142. /**
  37143. * Revers pinch action direction.
  37144. */
  37145. pinchInwards: boolean;
  37146. private _isPanClick;
  37147. private _twoFingerActivityCount;
  37148. private _isPinching;
  37149. /**
  37150. * Called on pointer POINTERMOVE event if only a single touch is active.
  37151. */
  37152. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37153. /**
  37154. * Called on pointer POINTERDOUBLETAP event.
  37155. */
  37156. protected onDoubleTap(type: string): void;
  37157. /**
  37158. * Called on pointer POINTERMOVE event if multiple touches are active.
  37159. */
  37160. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37161. /**
  37162. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37163. * press.
  37164. */
  37165. protected onButtonDown(evt: PointerEvent): void;
  37166. /**
  37167. * Called each time a new POINTERUP event occurs. Ie, for each button
  37168. * release.
  37169. */
  37170. protected onButtonUp(evt: PointerEvent): void;
  37171. /**
  37172. * Called when window becomes inactive.
  37173. */
  37174. protected onLostFocus(): void;
  37175. }
  37176. }
  37177. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37178. import { Nullable } from "babylonjs/types";
  37179. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37180. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37181. /**
  37182. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37183. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37184. */
  37185. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37186. /**
  37187. * Defines the camera the input is attached to.
  37188. */
  37189. camera: ArcRotateCamera;
  37190. /**
  37191. * Defines the list of key codes associated with the up action (increase alpha)
  37192. */
  37193. keysUp: number[];
  37194. /**
  37195. * Defines the list of key codes associated with the down action (decrease alpha)
  37196. */
  37197. keysDown: number[];
  37198. /**
  37199. * Defines the list of key codes associated with the left action (increase beta)
  37200. */
  37201. keysLeft: number[];
  37202. /**
  37203. * Defines the list of key codes associated with the right action (decrease beta)
  37204. */
  37205. keysRight: number[];
  37206. /**
  37207. * Defines the list of key codes associated with the reset action.
  37208. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37209. */
  37210. keysReset: number[];
  37211. /**
  37212. * Defines the panning sensibility of the inputs.
  37213. * (How fast is the camera paning)
  37214. */
  37215. panningSensibility: number;
  37216. /**
  37217. * Defines the zooming sensibility of the inputs.
  37218. * (How fast is the camera zooming)
  37219. */
  37220. zoomingSensibility: number;
  37221. /**
  37222. * Defines wether maintaining the alt key down switch the movement mode from
  37223. * orientation to zoom.
  37224. */
  37225. useAltToZoom: boolean;
  37226. /**
  37227. * Rotation speed of the camera
  37228. */
  37229. angularSpeed: number;
  37230. private _keys;
  37231. private _ctrlPressed;
  37232. private _altPressed;
  37233. private _onCanvasBlurObserver;
  37234. private _onKeyboardObserver;
  37235. private _engine;
  37236. private _scene;
  37237. /**
  37238. * Attach the input controls to a specific dom element to get the input from.
  37239. * @param element Defines the element the controls should be listened from
  37240. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37241. */
  37242. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37243. /**
  37244. * Detach the current controls from the specified dom element.
  37245. * @param element Defines the element to stop listening the inputs from
  37246. */
  37247. detachControl(element: Nullable<HTMLElement>): void;
  37248. /**
  37249. * Update the current camera state depending on the inputs that have been used this frame.
  37250. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37251. */
  37252. checkInputs(): void;
  37253. /**
  37254. * Gets the class name of the current intput.
  37255. * @returns the class name
  37256. */
  37257. getClassName(): string;
  37258. /**
  37259. * Get the friendly name associated with the input class.
  37260. * @returns the input friendly name
  37261. */
  37262. getSimpleName(): string;
  37263. }
  37264. }
  37265. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37266. import { Nullable } from "babylonjs/types";
  37267. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37268. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37269. /**
  37270. * Manage the mouse wheel inputs to control an arc rotate camera.
  37271. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37272. */
  37273. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37274. /**
  37275. * Defines the camera the input is attached to.
  37276. */
  37277. camera: ArcRotateCamera;
  37278. /**
  37279. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37280. */
  37281. wheelPrecision: number;
  37282. /**
  37283. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37284. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37285. */
  37286. wheelDeltaPercentage: number;
  37287. private _wheel;
  37288. private _observer;
  37289. private computeDeltaFromMouseWheelLegacyEvent;
  37290. /**
  37291. * Attach the input controls to a specific dom element to get the input from.
  37292. * @param element Defines the element the controls should be listened from
  37293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37294. */
  37295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37296. /**
  37297. * Detach the current controls from the specified dom element.
  37298. * @param element Defines the element to stop listening the inputs from
  37299. */
  37300. detachControl(element: Nullable<HTMLElement>): void;
  37301. /**
  37302. * Gets the class name of the current intput.
  37303. * @returns the class name
  37304. */
  37305. getClassName(): string;
  37306. /**
  37307. * Get the friendly name associated with the input class.
  37308. * @returns the input friendly name
  37309. */
  37310. getSimpleName(): string;
  37311. }
  37312. }
  37313. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37314. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37315. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37316. /**
  37317. * Default Inputs manager for the ArcRotateCamera.
  37318. * It groups all the default supported inputs for ease of use.
  37319. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37320. */
  37321. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37322. /**
  37323. * Instantiates a new ArcRotateCameraInputsManager.
  37324. * @param camera Defines the camera the inputs belong to
  37325. */
  37326. constructor(camera: ArcRotateCamera);
  37327. /**
  37328. * Add mouse wheel input support to the input manager.
  37329. * @returns the current input manager
  37330. */
  37331. addMouseWheel(): ArcRotateCameraInputsManager;
  37332. /**
  37333. * Add pointers input support to the input manager.
  37334. * @returns the current input manager
  37335. */
  37336. addPointers(): ArcRotateCameraInputsManager;
  37337. /**
  37338. * Add keyboard input support to the input manager.
  37339. * @returns the current input manager
  37340. */
  37341. addKeyboard(): ArcRotateCameraInputsManager;
  37342. }
  37343. }
  37344. declare module "babylonjs/Cameras/arcRotateCamera" {
  37345. import { Observable } from "babylonjs/Misc/observable";
  37346. import { Nullable } from "babylonjs/types";
  37347. import { Scene } from "babylonjs/scene";
  37348. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37350. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37351. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37352. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37353. import { Camera } from "babylonjs/Cameras/camera";
  37354. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37355. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37356. import { Collider } from "babylonjs/Collisions/collider";
  37357. /**
  37358. * This represents an orbital type of camera.
  37359. *
  37360. * 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.
  37361. * 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.
  37362. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37363. */
  37364. export class ArcRotateCamera extends TargetCamera {
  37365. /**
  37366. * Defines the rotation angle of the camera along the longitudinal axis.
  37367. */
  37368. alpha: number;
  37369. /**
  37370. * Defines the rotation angle of the camera along the latitudinal axis.
  37371. */
  37372. beta: number;
  37373. /**
  37374. * Defines the radius of the camera from it s target point.
  37375. */
  37376. radius: number;
  37377. protected _target: Vector3;
  37378. protected _targetHost: Nullable<AbstractMesh>;
  37379. /**
  37380. * Defines the target point of the camera.
  37381. * The camera looks towards it form the radius distance.
  37382. */
  37383. target: Vector3;
  37384. /**
  37385. * Define the current local position of the camera in the scene
  37386. */
  37387. position: Vector3;
  37388. protected _upVector: Vector3;
  37389. protected _upToYMatrix: Matrix;
  37390. protected _YToUpMatrix: Matrix;
  37391. /**
  37392. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37393. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37394. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37395. */
  37396. upVector: Vector3;
  37397. /**
  37398. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37399. */
  37400. setMatUp(): void;
  37401. /**
  37402. * Current inertia value on the longitudinal axis.
  37403. * The bigger this number the longer it will take for the camera to stop.
  37404. */
  37405. inertialAlphaOffset: number;
  37406. /**
  37407. * Current inertia value on the latitudinal axis.
  37408. * The bigger this number the longer it will take for the camera to stop.
  37409. */
  37410. inertialBetaOffset: number;
  37411. /**
  37412. * Current inertia value on the radius axis.
  37413. * The bigger this number the longer it will take for the camera to stop.
  37414. */
  37415. inertialRadiusOffset: number;
  37416. /**
  37417. * Minimum allowed angle on the longitudinal axis.
  37418. * This can help limiting how the Camera is able to move in the scene.
  37419. */
  37420. lowerAlphaLimit: Nullable<number>;
  37421. /**
  37422. * Maximum allowed angle on the longitudinal axis.
  37423. * This can help limiting how the Camera is able to move in the scene.
  37424. */
  37425. upperAlphaLimit: Nullable<number>;
  37426. /**
  37427. * Minimum allowed angle on the latitudinal axis.
  37428. * This can help limiting how the Camera is able to move in the scene.
  37429. */
  37430. lowerBetaLimit: number;
  37431. /**
  37432. * Maximum allowed angle on the latitudinal axis.
  37433. * This can help limiting how the Camera is able to move in the scene.
  37434. */
  37435. upperBetaLimit: number;
  37436. /**
  37437. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37438. * This can help limiting how the Camera is able to move in the scene.
  37439. */
  37440. lowerRadiusLimit: Nullable<number>;
  37441. /**
  37442. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37443. * This can help limiting how the Camera is able to move in the scene.
  37444. */
  37445. upperRadiusLimit: Nullable<number>;
  37446. /**
  37447. * Defines the current inertia value used during panning of the camera along the X axis.
  37448. */
  37449. inertialPanningX: number;
  37450. /**
  37451. * Defines the current inertia value used during panning of the camera along the Y axis.
  37452. */
  37453. inertialPanningY: number;
  37454. /**
  37455. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37456. * Basically if your fingers moves away from more than this distance you will be considered
  37457. * in pinch mode.
  37458. */
  37459. pinchToPanMaxDistance: number;
  37460. /**
  37461. * Defines the maximum distance the camera can pan.
  37462. * This could help keeping the cammera always in your scene.
  37463. */
  37464. panningDistanceLimit: Nullable<number>;
  37465. /**
  37466. * Defines the target of the camera before paning.
  37467. */
  37468. panningOriginTarget: Vector3;
  37469. /**
  37470. * Defines the value of the inertia used during panning.
  37471. * 0 would mean stop inertia and one would mean no decelleration at all.
  37472. */
  37473. panningInertia: number;
  37474. /**
  37475. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37476. */
  37477. angularSensibilityX: number;
  37478. /**
  37479. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37480. */
  37481. angularSensibilityY: number;
  37482. /**
  37483. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37484. */
  37485. pinchPrecision: number;
  37486. /**
  37487. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37488. * It will be used instead of pinchDeltaPrecision if different from 0.
  37489. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37490. */
  37491. pinchDeltaPercentage: number;
  37492. /**
  37493. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37494. */
  37495. panningSensibility: number;
  37496. /**
  37497. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37498. */
  37499. keysUp: number[];
  37500. /**
  37501. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37502. */
  37503. keysDown: number[];
  37504. /**
  37505. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37506. */
  37507. keysLeft: number[];
  37508. /**
  37509. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37510. */
  37511. keysRight: number[];
  37512. /**
  37513. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37514. */
  37515. wheelPrecision: number;
  37516. /**
  37517. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37518. * It will be used instead of pinchDeltaPrecision if different from 0.
  37519. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37520. */
  37521. wheelDeltaPercentage: number;
  37522. /**
  37523. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37524. */
  37525. zoomOnFactor: number;
  37526. /**
  37527. * Defines a screen offset for the camera position.
  37528. */
  37529. targetScreenOffset: Vector2;
  37530. /**
  37531. * Allows the camera to be completely reversed.
  37532. * If false the camera can not arrive upside down.
  37533. */
  37534. allowUpsideDown: boolean;
  37535. /**
  37536. * Define if double tap/click is used to restore the previously saved state of the camera.
  37537. */
  37538. useInputToRestoreState: boolean;
  37539. /** @hidden */
  37540. _viewMatrix: Matrix;
  37541. /** @hidden */
  37542. _useCtrlForPanning: boolean;
  37543. /** @hidden */
  37544. _panningMouseButton: number;
  37545. /**
  37546. * Defines the input associated to the camera.
  37547. */
  37548. inputs: ArcRotateCameraInputsManager;
  37549. /** @hidden */
  37550. _reset: () => void;
  37551. /**
  37552. * Defines the allowed panning axis.
  37553. */
  37554. panningAxis: Vector3;
  37555. protected _localDirection: Vector3;
  37556. protected _transformedDirection: Vector3;
  37557. private _bouncingBehavior;
  37558. /**
  37559. * Gets the bouncing behavior of the camera if it has been enabled.
  37560. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37561. */
  37562. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37563. /**
  37564. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37565. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37566. */
  37567. useBouncingBehavior: boolean;
  37568. private _framingBehavior;
  37569. /**
  37570. * Gets the framing behavior of the camera if it has been enabled.
  37571. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37572. */
  37573. readonly framingBehavior: Nullable<FramingBehavior>;
  37574. /**
  37575. * Defines if the framing behavior of the camera is enabled on the camera.
  37576. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37577. */
  37578. useFramingBehavior: boolean;
  37579. private _autoRotationBehavior;
  37580. /**
  37581. * Gets the auto rotation behavior of the camera if it has been enabled.
  37582. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37583. */
  37584. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37585. /**
  37586. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37587. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37588. */
  37589. useAutoRotationBehavior: boolean;
  37590. /**
  37591. * Observable triggered when the mesh target has been changed on the camera.
  37592. */
  37593. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37594. /**
  37595. * Event raised when the camera is colliding with a mesh.
  37596. */
  37597. onCollide: (collidedMesh: AbstractMesh) => void;
  37598. /**
  37599. * Defines whether the camera should check collision with the objects oh the scene.
  37600. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37601. */
  37602. checkCollisions: boolean;
  37603. /**
  37604. * Defines the collision radius of the camera.
  37605. * This simulates a sphere around the camera.
  37606. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37607. */
  37608. collisionRadius: Vector3;
  37609. protected _collider: Collider;
  37610. protected _previousPosition: Vector3;
  37611. protected _collisionVelocity: Vector3;
  37612. protected _newPosition: Vector3;
  37613. protected _previousAlpha: number;
  37614. protected _previousBeta: number;
  37615. protected _previousRadius: number;
  37616. protected _collisionTriggered: boolean;
  37617. protected _targetBoundingCenter: Nullable<Vector3>;
  37618. private _computationVector;
  37619. /**
  37620. * Instantiates a new ArcRotateCamera in a given scene
  37621. * @param name Defines the name of the camera
  37622. * @param alpha Defines the camera rotation along the logitudinal axis
  37623. * @param beta Defines the camera rotation along the latitudinal axis
  37624. * @param radius Defines the camera distance from its target
  37625. * @param target Defines the camera target
  37626. * @param scene Defines the scene the camera belongs to
  37627. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37628. */
  37629. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37630. /** @hidden */
  37631. _initCache(): void;
  37632. /** @hidden */
  37633. _updateCache(ignoreParentClass?: boolean): void;
  37634. protected _getTargetPosition(): Vector3;
  37635. private _storedAlpha;
  37636. private _storedBeta;
  37637. private _storedRadius;
  37638. private _storedTarget;
  37639. private _storedTargetScreenOffset;
  37640. /**
  37641. * Stores the current state of the camera (alpha, beta, radius and target)
  37642. * @returns the camera itself
  37643. */
  37644. storeState(): Camera;
  37645. /**
  37646. * @hidden
  37647. * Restored camera state. You must call storeState() first
  37648. */
  37649. _restoreStateValues(): boolean;
  37650. /** @hidden */
  37651. _isSynchronizedViewMatrix(): boolean;
  37652. /**
  37653. * Attached controls to the current camera.
  37654. * @param element Defines the element the controls should be listened from
  37655. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37656. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37657. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37658. */
  37659. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37660. /**
  37661. * Detach the current controls from the camera.
  37662. * The camera will stop reacting to inputs.
  37663. * @param element Defines the element to stop listening the inputs from
  37664. */
  37665. detachControl(element: HTMLElement): void;
  37666. /** @hidden */
  37667. _checkInputs(): void;
  37668. protected _checkLimits(): void;
  37669. /**
  37670. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37671. */
  37672. rebuildAnglesAndRadius(): void;
  37673. /**
  37674. * Use a position to define the current camera related information like alpha, beta and radius
  37675. * @param position Defines the position to set the camera at
  37676. */
  37677. setPosition(position: Vector3): void;
  37678. /**
  37679. * Defines the target the camera should look at.
  37680. * This will automatically adapt alpha beta and radius to fit within the new target.
  37681. * @param target Defines the new target as a Vector or a mesh
  37682. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37683. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37684. */
  37685. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37686. /** @hidden */
  37687. _getViewMatrix(): Matrix;
  37688. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37689. /**
  37690. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37691. * @param meshes Defines the mesh to zoom on
  37692. * @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)
  37693. */
  37694. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37695. /**
  37696. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37697. * The target will be changed but the radius
  37698. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37699. * @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)
  37700. */
  37701. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37702. min: Vector3;
  37703. max: Vector3;
  37704. distance: number;
  37705. }, doNotUpdateMaxZ?: boolean): void;
  37706. /**
  37707. * @override
  37708. * Override Camera.createRigCamera
  37709. */
  37710. createRigCamera(name: string, cameraIndex: number): Camera;
  37711. /**
  37712. * @hidden
  37713. * @override
  37714. * Override Camera._updateRigCameras
  37715. */
  37716. _updateRigCameras(): void;
  37717. /**
  37718. * Destroy the camera and release the current resources hold by it.
  37719. */
  37720. dispose(): void;
  37721. /**
  37722. * Gets the current object class name.
  37723. * @return the class name
  37724. */
  37725. getClassName(): string;
  37726. }
  37727. }
  37728. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37729. import { Behavior } from "babylonjs/Behaviors/behavior";
  37730. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37731. /**
  37732. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37733. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37734. */
  37735. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37736. /**
  37737. * Gets the name of the behavior.
  37738. */
  37739. readonly name: string;
  37740. private _zoomStopsAnimation;
  37741. private _idleRotationSpeed;
  37742. private _idleRotationWaitTime;
  37743. private _idleRotationSpinupTime;
  37744. /**
  37745. * Sets the flag that indicates if user zooming should stop animation.
  37746. */
  37747. /**
  37748. * Gets the flag that indicates if user zooming should stop animation.
  37749. */
  37750. zoomStopsAnimation: boolean;
  37751. /**
  37752. * Sets the default speed at which the camera rotates around the model.
  37753. */
  37754. /**
  37755. * Gets the default speed at which the camera rotates around the model.
  37756. */
  37757. idleRotationSpeed: number;
  37758. /**
  37759. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37760. */
  37761. /**
  37762. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37763. */
  37764. idleRotationWaitTime: number;
  37765. /**
  37766. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37767. */
  37768. /**
  37769. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37770. */
  37771. idleRotationSpinupTime: number;
  37772. /**
  37773. * Gets a value indicating if the camera is currently rotating because of this behavior
  37774. */
  37775. readonly rotationInProgress: boolean;
  37776. private _onPrePointerObservableObserver;
  37777. private _onAfterCheckInputsObserver;
  37778. private _attachedCamera;
  37779. private _isPointerDown;
  37780. private _lastFrameTime;
  37781. private _lastInteractionTime;
  37782. private _cameraRotationSpeed;
  37783. /**
  37784. * Initializes the behavior.
  37785. */
  37786. init(): void;
  37787. /**
  37788. * Attaches the behavior to its arc rotate camera.
  37789. * @param camera Defines the camera to attach the behavior to
  37790. */
  37791. attach(camera: ArcRotateCamera): void;
  37792. /**
  37793. * Detaches the behavior from its current arc rotate camera.
  37794. */
  37795. detach(): void;
  37796. /**
  37797. * Returns true if user is scrolling.
  37798. * @return true if user is scrolling.
  37799. */
  37800. private _userIsZooming;
  37801. private _lastFrameRadius;
  37802. private _shouldAnimationStopForInteraction;
  37803. /**
  37804. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37805. */
  37806. private _applyUserInteraction;
  37807. private _userIsMoving;
  37808. }
  37809. }
  37810. declare module "babylonjs/Behaviors/Cameras/index" {
  37811. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37812. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37813. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37814. }
  37815. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37816. import { Mesh } from "babylonjs/Meshes/mesh";
  37817. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37818. import { Behavior } from "babylonjs/Behaviors/behavior";
  37819. /**
  37820. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37821. */
  37822. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37823. private ui;
  37824. /**
  37825. * The name of the behavior
  37826. */
  37827. name: string;
  37828. /**
  37829. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37830. */
  37831. distanceAwayFromFace: number;
  37832. /**
  37833. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37834. */
  37835. distanceAwayFromBottomOfFace: number;
  37836. private _faceVectors;
  37837. private _target;
  37838. private _scene;
  37839. private _onRenderObserver;
  37840. private _tmpMatrix;
  37841. private _tmpVector;
  37842. /**
  37843. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37844. * @param ui The transform node that should be attched to the mesh
  37845. */
  37846. constructor(ui: TransformNode);
  37847. /**
  37848. * Initializes the behavior
  37849. */
  37850. init(): void;
  37851. private _closestFace;
  37852. private _zeroVector;
  37853. private _lookAtTmpMatrix;
  37854. private _lookAtToRef;
  37855. /**
  37856. * Attaches the AttachToBoxBehavior to the passed in mesh
  37857. * @param target The mesh that the specified node will be attached to
  37858. */
  37859. attach(target: Mesh): void;
  37860. /**
  37861. * Detaches the behavior from the mesh
  37862. */
  37863. detach(): void;
  37864. }
  37865. }
  37866. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37867. import { Behavior } from "babylonjs/Behaviors/behavior";
  37868. import { Mesh } from "babylonjs/Meshes/mesh";
  37869. /**
  37870. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37871. */
  37872. export class FadeInOutBehavior implements Behavior<Mesh> {
  37873. /**
  37874. * Time in milliseconds to delay before fading in (Default: 0)
  37875. */
  37876. delay: number;
  37877. /**
  37878. * Time in milliseconds for the mesh to fade in (Default: 300)
  37879. */
  37880. fadeInTime: number;
  37881. private _millisecondsPerFrame;
  37882. private _hovered;
  37883. private _hoverValue;
  37884. private _ownerNode;
  37885. /**
  37886. * Instatiates the FadeInOutBehavior
  37887. */
  37888. constructor();
  37889. /**
  37890. * The name of the behavior
  37891. */
  37892. readonly name: string;
  37893. /**
  37894. * Initializes the behavior
  37895. */
  37896. init(): void;
  37897. /**
  37898. * Attaches the fade behavior on the passed in mesh
  37899. * @param ownerNode The mesh that will be faded in/out once attached
  37900. */
  37901. attach(ownerNode: Mesh): void;
  37902. /**
  37903. * Detaches the behavior from the mesh
  37904. */
  37905. detach(): void;
  37906. /**
  37907. * Triggers the mesh to begin fading in or out
  37908. * @param value if the object should fade in or out (true to fade in)
  37909. */
  37910. fadeIn(value: boolean): void;
  37911. private _update;
  37912. private _setAllVisibility;
  37913. }
  37914. }
  37915. declare module "babylonjs/Misc/pivotTools" {
  37916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37917. /**
  37918. * Class containing a set of static utilities functions for managing Pivots
  37919. * @hidden
  37920. */
  37921. export class PivotTools {
  37922. private static _PivotCached;
  37923. private static _OldPivotPoint;
  37924. private static _PivotTranslation;
  37925. private static _PivotTmpVector;
  37926. /** @hidden */
  37927. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37928. /** @hidden */
  37929. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37930. }
  37931. }
  37932. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37933. import { Scene } from "babylonjs/scene";
  37934. import { Vector4 } from "babylonjs/Maths/math.vector";
  37935. import { Mesh } from "babylonjs/Meshes/mesh";
  37936. import { Nullable } from "babylonjs/types";
  37937. import { Plane } from "babylonjs/Maths/math.plane";
  37938. /**
  37939. * Class containing static functions to help procedurally build meshes
  37940. */
  37941. export class PlaneBuilder {
  37942. /**
  37943. * Creates a plane mesh
  37944. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37945. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37946. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37948. * * 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
  37949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37950. * @param name defines the name of the mesh
  37951. * @param options defines the options used to create the mesh
  37952. * @param scene defines the hosting scene
  37953. * @returns the plane mesh
  37954. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37955. */
  37956. static CreatePlane(name: string, options: {
  37957. size?: number;
  37958. width?: number;
  37959. height?: number;
  37960. sideOrientation?: number;
  37961. frontUVs?: Vector4;
  37962. backUVs?: Vector4;
  37963. updatable?: boolean;
  37964. sourcePlane?: Plane;
  37965. }, scene?: Nullable<Scene>): Mesh;
  37966. }
  37967. }
  37968. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37969. import { Behavior } from "babylonjs/Behaviors/behavior";
  37970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37971. import { Observable } from "babylonjs/Misc/observable";
  37972. import { Vector3 } from "babylonjs/Maths/math.vector";
  37973. import { Ray } from "babylonjs/Culling/ray";
  37974. import "babylonjs/Meshes/Builders/planeBuilder";
  37975. /**
  37976. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37977. */
  37978. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37979. private static _AnyMouseID;
  37980. /**
  37981. * Abstract mesh the behavior is set on
  37982. */
  37983. attachedNode: AbstractMesh;
  37984. private _dragPlane;
  37985. private _scene;
  37986. private _pointerObserver;
  37987. private _beforeRenderObserver;
  37988. private static _planeScene;
  37989. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37990. /**
  37991. * 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)
  37992. */
  37993. maxDragAngle: number;
  37994. /**
  37995. * @hidden
  37996. */
  37997. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37998. /**
  37999. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38000. */
  38001. currentDraggingPointerID: number;
  38002. /**
  38003. * The last position where the pointer hit the drag plane in world space
  38004. */
  38005. lastDragPosition: Vector3;
  38006. /**
  38007. * If the behavior is currently in a dragging state
  38008. */
  38009. dragging: boolean;
  38010. /**
  38011. * 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)
  38012. */
  38013. dragDeltaRatio: number;
  38014. /**
  38015. * If the drag plane orientation should be updated during the dragging (Default: true)
  38016. */
  38017. updateDragPlane: boolean;
  38018. private _debugMode;
  38019. private _moving;
  38020. /**
  38021. * Fires each time the attached mesh is dragged with the pointer
  38022. * * delta between last drag position and current drag position in world space
  38023. * * dragDistance along the drag axis
  38024. * * dragPlaneNormal normal of the current drag plane used during the drag
  38025. * * dragPlanePoint in world space where the drag intersects the drag plane
  38026. */
  38027. onDragObservable: Observable<{
  38028. delta: Vector3;
  38029. dragPlanePoint: Vector3;
  38030. dragPlaneNormal: Vector3;
  38031. dragDistance: number;
  38032. pointerId: number;
  38033. }>;
  38034. /**
  38035. * Fires each time a drag begins (eg. mouse down on mesh)
  38036. */
  38037. onDragStartObservable: Observable<{
  38038. dragPlanePoint: Vector3;
  38039. pointerId: number;
  38040. }>;
  38041. /**
  38042. * Fires each time a drag ends (eg. mouse release after drag)
  38043. */
  38044. onDragEndObservable: Observable<{
  38045. dragPlanePoint: Vector3;
  38046. pointerId: number;
  38047. }>;
  38048. /**
  38049. * If the attached mesh should be moved when dragged
  38050. */
  38051. moveAttached: boolean;
  38052. /**
  38053. * If the drag behavior will react to drag events (Default: true)
  38054. */
  38055. enabled: boolean;
  38056. /**
  38057. * If pointer events should start and release the drag (Default: true)
  38058. */
  38059. startAndReleaseDragOnPointerEvents: boolean;
  38060. /**
  38061. * If camera controls should be detached during the drag
  38062. */
  38063. detachCameraControls: boolean;
  38064. /**
  38065. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38066. */
  38067. useObjectOrienationForDragging: boolean;
  38068. private _options;
  38069. /**
  38070. * Creates a pointer drag behavior that can be attached to a mesh
  38071. * @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)
  38072. */
  38073. constructor(options?: {
  38074. dragAxis?: Vector3;
  38075. dragPlaneNormal?: Vector3;
  38076. });
  38077. /**
  38078. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38079. */
  38080. validateDrag: (targetPosition: Vector3) => boolean;
  38081. /**
  38082. * The name of the behavior
  38083. */
  38084. readonly name: string;
  38085. /**
  38086. * Initializes the behavior
  38087. */
  38088. init(): void;
  38089. private _tmpVector;
  38090. private _alternatePickedPoint;
  38091. private _worldDragAxis;
  38092. private _targetPosition;
  38093. private _attachedElement;
  38094. /**
  38095. * Attaches the drag behavior the passed in mesh
  38096. * @param ownerNode The mesh that will be dragged around once attached
  38097. * @param predicate Predicate to use for pick filtering
  38098. */
  38099. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38100. /**
  38101. * Force relase the drag action by code.
  38102. */
  38103. releaseDrag(): void;
  38104. private _startDragRay;
  38105. private _lastPointerRay;
  38106. /**
  38107. * Simulates the start of a pointer drag event on the behavior
  38108. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38109. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38110. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38111. */
  38112. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38113. private _startDrag;
  38114. private _dragDelta;
  38115. private _moveDrag;
  38116. private _pickWithRayOnDragPlane;
  38117. private _pointA;
  38118. private _pointB;
  38119. private _pointC;
  38120. private _lineA;
  38121. private _lineB;
  38122. private _localAxis;
  38123. private _lookAt;
  38124. private _updateDragPlanePosition;
  38125. /**
  38126. * Detaches the behavior from the mesh
  38127. */
  38128. detach(): void;
  38129. }
  38130. }
  38131. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38132. import { Mesh } from "babylonjs/Meshes/mesh";
  38133. import { Behavior } from "babylonjs/Behaviors/behavior";
  38134. /**
  38135. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38136. */
  38137. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38138. private _dragBehaviorA;
  38139. private _dragBehaviorB;
  38140. private _startDistance;
  38141. private _initialScale;
  38142. private _targetScale;
  38143. private _ownerNode;
  38144. private _sceneRenderObserver;
  38145. /**
  38146. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38147. */
  38148. constructor();
  38149. /**
  38150. * The name of the behavior
  38151. */
  38152. readonly name: string;
  38153. /**
  38154. * Initializes the behavior
  38155. */
  38156. init(): void;
  38157. private _getCurrentDistance;
  38158. /**
  38159. * Attaches the scale behavior the passed in mesh
  38160. * @param ownerNode The mesh that will be scaled around once attached
  38161. */
  38162. attach(ownerNode: Mesh): void;
  38163. /**
  38164. * Detaches the behavior from the mesh
  38165. */
  38166. detach(): void;
  38167. }
  38168. }
  38169. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38170. import { Behavior } from "babylonjs/Behaviors/behavior";
  38171. import { Mesh } from "babylonjs/Meshes/mesh";
  38172. import { Observable } from "babylonjs/Misc/observable";
  38173. /**
  38174. * 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
  38175. */
  38176. export class SixDofDragBehavior implements Behavior<Mesh> {
  38177. private static _virtualScene;
  38178. private _ownerNode;
  38179. private _sceneRenderObserver;
  38180. private _scene;
  38181. private _targetPosition;
  38182. private _virtualOriginMesh;
  38183. private _virtualDragMesh;
  38184. private _pointerObserver;
  38185. private _moving;
  38186. private _startingOrientation;
  38187. /**
  38188. * 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)
  38189. */
  38190. private zDragFactor;
  38191. /**
  38192. * If the object should rotate to face the drag origin
  38193. */
  38194. rotateDraggedObject: boolean;
  38195. /**
  38196. * If the behavior is currently in a dragging state
  38197. */
  38198. dragging: boolean;
  38199. /**
  38200. * 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)
  38201. */
  38202. dragDeltaRatio: number;
  38203. /**
  38204. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38205. */
  38206. currentDraggingPointerID: number;
  38207. /**
  38208. * If camera controls should be detached during the drag
  38209. */
  38210. detachCameraControls: boolean;
  38211. /**
  38212. * Fires each time a drag starts
  38213. */
  38214. onDragStartObservable: Observable<{}>;
  38215. /**
  38216. * Fires each time a drag ends (eg. mouse release after drag)
  38217. */
  38218. onDragEndObservable: Observable<{}>;
  38219. /**
  38220. * 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
  38221. */
  38222. constructor();
  38223. /**
  38224. * The name of the behavior
  38225. */
  38226. readonly name: string;
  38227. /**
  38228. * Initializes the behavior
  38229. */
  38230. init(): void;
  38231. /**
  38232. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38233. */
  38234. private readonly _pointerCamera;
  38235. /**
  38236. * Attaches the scale behavior the passed in mesh
  38237. * @param ownerNode The mesh that will be scaled around once attached
  38238. */
  38239. attach(ownerNode: Mesh): void;
  38240. /**
  38241. * Detaches the behavior from the mesh
  38242. */
  38243. detach(): void;
  38244. }
  38245. }
  38246. declare module "babylonjs/Behaviors/Meshes/index" {
  38247. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38248. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38249. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38250. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38251. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38252. }
  38253. declare module "babylonjs/Behaviors/index" {
  38254. export * from "babylonjs/Behaviors/behavior";
  38255. export * from "babylonjs/Behaviors/Cameras/index";
  38256. export * from "babylonjs/Behaviors/Meshes/index";
  38257. }
  38258. declare module "babylonjs/Bones/boneIKController" {
  38259. import { Bone } from "babylonjs/Bones/bone";
  38260. import { Vector3 } from "babylonjs/Maths/math.vector";
  38261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38262. import { Nullable } from "babylonjs/types";
  38263. /**
  38264. * Class used to apply inverse kinematics to bones
  38265. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38266. */
  38267. export class BoneIKController {
  38268. private static _tmpVecs;
  38269. private static _tmpQuat;
  38270. private static _tmpMats;
  38271. /**
  38272. * Gets or sets the target mesh
  38273. */
  38274. targetMesh: AbstractMesh;
  38275. /** Gets or sets the mesh used as pole */
  38276. poleTargetMesh: AbstractMesh;
  38277. /**
  38278. * Gets or sets the bone used as pole
  38279. */
  38280. poleTargetBone: Nullable<Bone>;
  38281. /**
  38282. * Gets or sets the target position
  38283. */
  38284. targetPosition: Vector3;
  38285. /**
  38286. * Gets or sets the pole target position
  38287. */
  38288. poleTargetPosition: Vector3;
  38289. /**
  38290. * Gets or sets the pole target local offset
  38291. */
  38292. poleTargetLocalOffset: Vector3;
  38293. /**
  38294. * Gets or sets the pole angle
  38295. */
  38296. poleAngle: number;
  38297. /**
  38298. * Gets or sets the mesh associated with the controller
  38299. */
  38300. mesh: AbstractMesh;
  38301. /**
  38302. * 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)
  38303. */
  38304. slerpAmount: number;
  38305. private _bone1Quat;
  38306. private _bone1Mat;
  38307. private _bone2Ang;
  38308. private _bone1;
  38309. private _bone2;
  38310. private _bone1Length;
  38311. private _bone2Length;
  38312. private _maxAngle;
  38313. private _maxReach;
  38314. private _rightHandedSystem;
  38315. private _bendAxis;
  38316. private _slerping;
  38317. private _adjustRoll;
  38318. /**
  38319. * Gets or sets maximum allowed angle
  38320. */
  38321. maxAngle: number;
  38322. /**
  38323. * Creates a new BoneIKController
  38324. * @param mesh defines the mesh to control
  38325. * @param bone defines the bone to control
  38326. * @param options defines options to set up the controller
  38327. */
  38328. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38329. targetMesh?: AbstractMesh;
  38330. poleTargetMesh?: AbstractMesh;
  38331. poleTargetBone?: Bone;
  38332. poleTargetLocalOffset?: Vector3;
  38333. poleAngle?: number;
  38334. bendAxis?: Vector3;
  38335. maxAngle?: number;
  38336. slerpAmount?: number;
  38337. });
  38338. private _setMaxAngle;
  38339. /**
  38340. * Force the controller to update the bones
  38341. */
  38342. update(): void;
  38343. }
  38344. }
  38345. declare module "babylonjs/Bones/boneLookController" {
  38346. import { Vector3 } from "babylonjs/Maths/math.vector";
  38347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38348. import { Bone } from "babylonjs/Bones/bone";
  38349. import { Space } from "babylonjs/Maths/math.axis";
  38350. /**
  38351. * Class used to make a bone look toward a point in space
  38352. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38353. */
  38354. export class BoneLookController {
  38355. private static _tmpVecs;
  38356. private static _tmpQuat;
  38357. private static _tmpMats;
  38358. /**
  38359. * The target Vector3 that the bone will look at
  38360. */
  38361. target: Vector3;
  38362. /**
  38363. * The mesh that the bone is attached to
  38364. */
  38365. mesh: AbstractMesh;
  38366. /**
  38367. * The bone that will be looking to the target
  38368. */
  38369. bone: Bone;
  38370. /**
  38371. * The up axis of the coordinate system that is used when the bone is rotated
  38372. */
  38373. upAxis: Vector3;
  38374. /**
  38375. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38376. */
  38377. upAxisSpace: Space;
  38378. /**
  38379. * Used to make an adjustment to the yaw of the bone
  38380. */
  38381. adjustYaw: number;
  38382. /**
  38383. * Used to make an adjustment to the pitch of the bone
  38384. */
  38385. adjustPitch: number;
  38386. /**
  38387. * Used to make an adjustment to the roll of the bone
  38388. */
  38389. adjustRoll: number;
  38390. /**
  38391. * 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)
  38392. */
  38393. slerpAmount: number;
  38394. private _minYaw;
  38395. private _maxYaw;
  38396. private _minPitch;
  38397. private _maxPitch;
  38398. private _minYawSin;
  38399. private _minYawCos;
  38400. private _maxYawSin;
  38401. private _maxYawCos;
  38402. private _midYawConstraint;
  38403. private _minPitchTan;
  38404. private _maxPitchTan;
  38405. private _boneQuat;
  38406. private _slerping;
  38407. private _transformYawPitch;
  38408. private _transformYawPitchInv;
  38409. private _firstFrameSkipped;
  38410. private _yawRange;
  38411. private _fowardAxis;
  38412. /**
  38413. * Gets or sets the minimum yaw angle that the bone can look to
  38414. */
  38415. minYaw: number;
  38416. /**
  38417. * Gets or sets the maximum yaw angle that the bone can look to
  38418. */
  38419. maxYaw: number;
  38420. /**
  38421. * Gets or sets the minimum pitch angle that the bone can look to
  38422. */
  38423. minPitch: number;
  38424. /**
  38425. * Gets or sets the maximum pitch angle that the bone can look to
  38426. */
  38427. maxPitch: number;
  38428. /**
  38429. * Create a BoneLookController
  38430. * @param mesh the mesh that the bone belongs to
  38431. * @param bone the bone that will be looking to the target
  38432. * @param target the target Vector3 to look at
  38433. * @param options optional settings:
  38434. * * maxYaw: the maximum angle the bone will yaw to
  38435. * * minYaw: the minimum angle the bone will yaw to
  38436. * * maxPitch: the maximum angle the bone will pitch to
  38437. * * minPitch: the minimum angle the bone will yaw to
  38438. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38439. * * upAxis: the up axis of the coordinate system
  38440. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38441. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38442. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38443. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38444. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38445. * * adjustRoll: used to make an adjustment to the roll of the bone
  38446. **/
  38447. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38448. maxYaw?: number;
  38449. minYaw?: number;
  38450. maxPitch?: number;
  38451. minPitch?: number;
  38452. slerpAmount?: number;
  38453. upAxis?: Vector3;
  38454. upAxisSpace?: Space;
  38455. yawAxis?: Vector3;
  38456. pitchAxis?: Vector3;
  38457. adjustYaw?: number;
  38458. adjustPitch?: number;
  38459. adjustRoll?: number;
  38460. });
  38461. /**
  38462. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38463. */
  38464. update(): void;
  38465. private _getAngleDiff;
  38466. private _getAngleBetween;
  38467. private _isAngleBetween;
  38468. }
  38469. }
  38470. declare module "babylonjs/Bones/index" {
  38471. export * from "babylonjs/Bones/bone";
  38472. export * from "babylonjs/Bones/boneIKController";
  38473. export * from "babylonjs/Bones/boneLookController";
  38474. export * from "babylonjs/Bones/skeleton";
  38475. }
  38476. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38477. import { Nullable } from "babylonjs/types";
  38478. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38479. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38480. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38481. /**
  38482. * Manage the gamepad inputs to control an arc rotate camera.
  38483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38484. */
  38485. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38486. /**
  38487. * Defines the camera the input is attached to.
  38488. */
  38489. camera: ArcRotateCamera;
  38490. /**
  38491. * Defines the gamepad the input is gathering event from.
  38492. */
  38493. gamepad: Nullable<Gamepad>;
  38494. /**
  38495. * Defines the gamepad rotation sensiblity.
  38496. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38497. */
  38498. gamepadRotationSensibility: number;
  38499. /**
  38500. * Defines the gamepad move sensiblity.
  38501. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38502. */
  38503. gamepadMoveSensibility: number;
  38504. private _yAxisScale;
  38505. /**
  38506. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38507. */
  38508. invertYAxis: boolean;
  38509. private _onGamepadConnectedObserver;
  38510. private _onGamepadDisconnectedObserver;
  38511. /**
  38512. * Attach the input controls to a specific dom element to get the input from.
  38513. * @param element Defines the element the controls should be listened from
  38514. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38515. */
  38516. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38517. /**
  38518. * Detach the current controls from the specified dom element.
  38519. * @param element Defines the element to stop listening the inputs from
  38520. */
  38521. detachControl(element: Nullable<HTMLElement>): void;
  38522. /**
  38523. * Update the current camera state depending on the inputs that have been used this frame.
  38524. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38525. */
  38526. checkInputs(): void;
  38527. /**
  38528. * Gets the class name of the current intput.
  38529. * @returns the class name
  38530. */
  38531. getClassName(): string;
  38532. /**
  38533. * Get the friendly name associated with the input class.
  38534. * @returns the input friendly name
  38535. */
  38536. getSimpleName(): string;
  38537. }
  38538. }
  38539. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38540. import { Nullable } from "babylonjs/types";
  38541. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38542. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38543. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38544. interface ArcRotateCameraInputsManager {
  38545. /**
  38546. * Add orientation input support to the input manager.
  38547. * @returns the current input manager
  38548. */
  38549. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38550. }
  38551. }
  38552. /**
  38553. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38555. */
  38556. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38557. /**
  38558. * Defines the camera the input is attached to.
  38559. */
  38560. camera: ArcRotateCamera;
  38561. /**
  38562. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38563. */
  38564. alphaCorrection: number;
  38565. /**
  38566. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38567. */
  38568. gammaCorrection: number;
  38569. private _alpha;
  38570. private _gamma;
  38571. private _dirty;
  38572. private _deviceOrientationHandler;
  38573. /**
  38574. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38575. */
  38576. constructor();
  38577. /**
  38578. * Attach the input controls to a specific dom element to get the input from.
  38579. * @param element Defines the element the controls should be listened from
  38580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38581. */
  38582. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38583. /** @hidden */
  38584. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38585. /**
  38586. * Update the current camera state depending on the inputs that have been used this frame.
  38587. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38588. */
  38589. checkInputs(): void;
  38590. /**
  38591. * Detach the current controls from the specified dom element.
  38592. * @param element Defines the element to stop listening the inputs from
  38593. */
  38594. detachControl(element: Nullable<HTMLElement>): void;
  38595. /**
  38596. * Gets the class name of the current intput.
  38597. * @returns the class name
  38598. */
  38599. getClassName(): string;
  38600. /**
  38601. * Get the friendly name associated with the input class.
  38602. * @returns the input friendly name
  38603. */
  38604. getSimpleName(): string;
  38605. }
  38606. }
  38607. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38608. import { Nullable } from "babylonjs/types";
  38609. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38610. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38611. /**
  38612. * Listen to mouse events to control the camera.
  38613. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38614. */
  38615. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38616. /**
  38617. * Defines the camera the input is attached to.
  38618. */
  38619. camera: FlyCamera;
  38620. /**
  38621. * Defines if touch is enabled. (Default is true.)
  38622. */
  38623. touchEnabled: boolean;
  38624. /**
  38625. * Defines the buttons associated with the input to handle camera rotation.
  38626. */
  38627. buttons: number[];
  38628. /**
  38629. * Assign buttons for Yaw control.
  38630. */
  38631. buttonsYaw: number[];
  38632. /**
  38633. * Assign buttons for Pitch control.
  38634. */
  38635. buttonsPitch: number[];
  38636. /**
  38637. * Assign buttons for Roll control.
  38638. */
  38639. buttonsRoll: number[];
  38640. /**
  38641. * Detect if any button is being pressed while mouse is moved.
  38642. * -1 = Mouse locked.
  38643. * 0 = Left button.
  38644. * 1 = Middle Button.
  38645. * 2 = Right Button.
  38646. */
  38647. activeButton: number;
  38648. /**
  38649. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38650. * Higher values reduce its sensitivity.
  38651. */
  38652. angularSensibility: number;
  38653. private _mousemoveCallback;
  38654. private _observer;
  38655. private _rollObserver;
  38656. private previousPosition;
  38657. private noPreventDefault;
  38658. private element;
  38659. /**
  38660. * Listen to mouse events to control the camera.
  38661. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38663. */
  38664. constructor(touchEnabled?: boolean);
  38665. /**
  38666. * Attach the mouse control to the HTML DOM element.
  38667. * @param element Defines the element that listens to the input events.
  38668. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38669. */
  38670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38671. /**
  38672. * Detach the current controls from the specified dom element.
  38673. * @param element Defines the element to stop listening the inputs from
  38674. */
  38675. detachControl(element: Nullable<HTMLElement>): void;
  38676. /**
  38677. * Gets the class name of the current input.
  38678. * @returns the class name.
  38679. */
  38680. getClassName(): string;
  38681. /**
  38682. * Get the friendly name associated with the input class.
  38683. * @returns the input's friendly name.
  38684. */
  38685. getSimpleName(): string;
  38686. private _pointerInput;
  38687. private _onMouseMove;
  38688. /**
  38689. * Rotate camera by mouse offset.
  38690. */
  38691. private rotateCamera;
  38692. }
  38693. }
  38694. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38695. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38696. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38697. /**
  38698. * Default Inputs manager for the FlyCamera.
  38699. * It groups all the default supported inputs for ease of use.
  38700. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38701. */
  38702. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38703. /**
  38704. * Instantiates a new FlyCameraInputsManager.
  38705. * @param camera Defines the camera the inputs belong to.
  38706. */
  38707. constructor(camera: FlyCamera);
  38708. /**
  38709. * Add keyboard input support to the input manager.
  38710. * @returns the new FlyCameraKeyboardMoveInput().
  38711. */
  38712. addKeyboard(): FlyCameraInputsManager;
  38713. /**
  38714. * Add mouse input support to the input manager.
  38715. * @param touchEnabled Enable touch screen support.
  38716. * @returns the new FlyCameraMouseInput().
  38717. */
  38718. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38719. }
  38720. }
  38721. declare module "babylonjs/Cameras/flyCamera" {
  38722. import { Scene } from "babylonjs/scene";
  38723. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38725. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38726. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38727. /**
  38728. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38729. * such as in a 3D Space Shooter or a Flight Simulator.
  38730. */
  38731. export class FlyCamera extends TargetCamera {
  38732. /**
  38733. * Define the collision ellipsoid of the camera.
  38734. * This is helpful for simulating a camera body, like a player's body.
  38735. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38736. */
  38737. ellipsoid: Vector3;
  38738. /**
  38739. * Define an offset for the position of the ellipsoid around the camera.
  38740. * This can be helpful if the camera is attached away from the player's body center,
  38741. * such as at its head.
  38742. */
  38743. ellipsoidOffset: Vector3;
  38744. /**
  38745. * Enable or disable collisions of the camera with the rest of the scene objects.
  38746. */
  38747. checkCollisions: boolean;
  38748. /**
  38749. * Enable or disable gravity on the camera.
  38750. */
  38751. applyGravity: boolean;
  38752. /**
  38753. * Define the current direction the camera is moving to.
  38754. */
  38755. cameraDirection: Vector3;
  38756. /**
  38757. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38758. * This overrides and empties cameraRotation.
  38759. */
  38760. rotationQuaternion: Quaternion;
  38761. /**
  38762. * Track Roll to maintain the wanted Rolling when looking around.
  38763. */
  38764. _trackRoll: number;
  38765. /**
  38766. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38767. */
  38768. rollCorrect: number;
  38769. /**
  38770. * Mimic a banked turn, Rolling the camera when Yawing.
  38771. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38772. */
  38773. bankedTurn: boolean;
  38774. /**
  38775. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38776. */
  38777. bankedTurnLimit: number;
  38778. /**
  38779. * Value of 0 disables the banked Roll.
  38780. * Value of 1 is equal to the Yaw angle in radians.
  38781. */
  38782. bankedTurnMultiplier: number;
  38783. /**
  38784. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38785. */
  38786. inputs: FlyCameraInputsManager;
  38787. /**
  38788. * Gets the input sensibility for mouse input.
  38789. * Higher values reduce sensitivity.
  38790. */
  38791. /**
  38792. * Sets the input sensibility for a mouse input.
  38793. * Higher values reduce sensitivity.
  38794. */
  38795. angularSensibility: number;
  38796. /**
  38797. * Get the keys for camera movement forward.
  38798. */
  38799. /**
  38800. * Set the keys for camera movement forward.
  38801. */
  38802. keysForward: number[];
  38803. /**
  38804. * Get the keys for camera movement backward.
  38805. */
  38806. keysBackward: number[];
  38807. /**
  38808. * Get the keys for camera movement up.
  38809. */
  38810. /**
  38811. * Set the keys for camera movement up.
  38812. */
  38813. keysUp: number[];
  38814. /**
  38815. * Get the keys for camera movement down.
  38816. */
  38817. /**
  38818. * Set the keys for camera movement down.
  38819. */
  38820. keysDown: number[];
  38821. /**
  38822. * Get the keys for camera movement left.
  38823. */
  38824. /**
  38825. * Set the keys for camera movement left.
  38826. */
  38827. keysLeft: number[];
  38828. /**
  38829. * Set the keys for camera movement right.
  38830. */
  38831. /**
  38832. * Set the keys for camera movement right.
  38833. */
  38834. keysRight: number[];
  38835. /**
  38836. * Event raised when the camera collides with a mesh in the scene.
  38837. */
  38838. onCollide: (collidedMesh: AbstractMesh) => void;
  38839. private _collider;
  38840. private _needMoveForGravity;
  38841. private _oldPosition;
  38842. private _diffPosition;
  38843. private _newPosition;
  38844. /** @hidden */
  38845. _localDirection: Vector3;
  38846. /** @hidden */
  38847. _transformedDirection: Vector3;
  38848. /**
  38849. * Instantiates a FlyCamera.
  38850. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38851. * such as in a 3D Space Shooter or a Flight Simulator.
  38852. * @param name Define the name of the camera in the scene.
  38853. * @param position Define the starting position of the camera in the scene.
  38854. * @param scene Define the scene the camera belongs to.
  38855. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38856. */
  38857. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38858. /**
  38859. * Attach a control to the HTML DOM element.
  38860. * @param element Defines the element that listens to the input events.
  38861. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38862. */
  38863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38864. /**
  38865. * Detach a control from the HTML DOM element.
  38866. * The camera will stop reacting to that input.
  38867. * @param element Defines the element that listens to the input events.
  38868. */
  38869. detachControl(element: HTMLElement): void;
  38870. private _collisionMask;
  38871. /**
  38872. * Get the mask that the camera ignores in collision events.
  38873. */
  38874. /**
  38875. * Set the mask that the camera ignores in collision events.
  38876. */
  38877. collisionMask: number;
  38878. /** @hidden */
  38879. _collideWithWorld(displacement: Vector3): void;
  38880. /** @hidden */
  38881. private _onCollisionPositionChange;
  38882. /** @hidden */
  38883. _checkInputs(): void;
  38884. /** @hidden */
  38885. _decideIfNeedsToMove(): boolean;
  38886. /** @hidden */
  38887. _updatePosition(): void;
  38888. /**
  38889. * Restore the Roll to its target value at the rate specified.
  38890. * @param rate - Higher means slower restoring.
  38891. * @hidden
  38892. */
  38893. restoreRoll(rate: number): void;
  38894. /**
  38895. * Destroy the camera and release the current resources held by it.
  38896. */
  38897. dispose(): void;
  38898. /**
  38899. * Get the current object class name.
  38900. * @returns the class name.
  38901. */
  38902. getClassName(): string;
  38903. }
  38904. }
  38905. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38906. import { Nullable } from "babylonjs/types";
  38907. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38908. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38909. /**
  38910. * Listen to keyboard events to control the camera.
  38911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38912. */
  38913. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38914. /**
  38915. * Defines the camera the input is attached to.
  38916. */
  38917. camera: FlyCamera;
  38918. /**
  38919. * The list of keyboard keys used to control the forward move of the camera.
  38920. */
  38921. keysForward: number[];
  38922. /**
  38923. * The list of keyboard keys used to control the backward move of the camera.
  38924. */
  38925. keysBackward: number[];
  38926. /**
  38927. * The list of keyboard keys used to control the forward move of the camera.
  38928. */
  38929. keysUp: number[];
  38930. /**
  38931. * The list of keyboard keys used to control the backward move of the camera.
  38932. */
  38933. keysDown: number[];
  38934. /**
  38935. * The list of keyboard keys used to control the right strafe move of the camera.
  38936. */
  38937. keysRight: number[];
  38938. /**
  38939. * The list of keyboard keys used to control the left strafe move of the camera.
  38940. */
  38941. keysLeft: number[];
  38942. private _keys;
  38943. private _onCanvasBlurObserver;
  38944. private _onKeyboardObserver;
  38945. private _engine;
  38946. private _scene;
  38947. /**
  38948. * Attach the input controls to a specific dom element to get the input from.
  38949. * @param element Defines the element the controls should be listened from
  38950. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38951. */
  38952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38953. /**
  38954. * Detach the current controls from the specified dom element.
  38955. * @param element Defines the element to stop listening the inputs from
  38956. */
  38957. detachControl(element: Nullable<HTMLElement>): void;
  38958. /**
  38959. * Gets the class name of the current intput.
  38960. * @returns the class name
  38961. */
  38962. getClassName(): string;
  38963. /** @hidden */
  38964. _onLostFocus(e: FocusEvent): void;
  38965. /**
  38966. * Get the friendly name associated with the input class.
  38967. * @returns the input friendly name
  38968. */
  38969. getSimpleName(): string;
  38970. /**
  38971. * Update the current camera state depending on the inputs that have been used this frame.
  38972. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38973. */
  38974. checkInputs(): void;
  38975. }
  38976. }
  38977. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38978. import { Nullable } from "babylonjs/types";
  38979. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38980. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38981. /**
  38982. * Manage the mouse wheel inputs to control a follow camera.
  38983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38984. */
  38985. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38986. /**
  38987. * Defines the camera the input is attached to.
  38988. */
  38989. camera: FollowCamera;
  38990. /**
  38991. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38992. */
  38993. axisControlRadius: boolean;
  38994. /**
  38995. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38996. */
  38997. axisControlHeight: boolean;
  38998. /**
  38999. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39000. */
  39001. axisControlRotation: boolean;
  39002. /**
  39003. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39004. * relation to mouseWheel events.
  39005. */
  39006. wheelPrecision: number;
  39007. /**
  39008. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39009. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39010. */
  39011. wheelDeltaPercentage: number;
  39012. private _wheel;
  39013. private _observer;
  39014. /**
  39015. * Attach the input controls to a specific dom element to get the input from.
  39016. * @param element Defines the element the controls should be listened from
  39017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39018. */
  39019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39020. /**
  39021. * Detach the current controls from the specified dom element.
  39022. * @param element Defines the element to stop listening the inputs from
  39023. */
  39024. detachControl(element: Nullable<HTMLElement>): void;
  39025. /**
  39026. * Gets the class name of the current intput.
  39027. * @returns the class name
  39028. */
  39029. getClassName(): string;
  39030. /**
  39031. * Get the friendly name associated with the input class.
  39032. * @returns the input friendly name
  39033. */
  39034. getSimpleName(): string;
  39035. }
  39036. }
  39037. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39038. import { Nullable } from "babylonjs/types";
  39039. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39040. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39041. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39042. /**
  39043. * Manage the pointers inputs to control an follow camera.
  39044. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39045. */
  39046. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39047. /**
  39048. * Defines the camera the input is attached to.
  39049. */
  39050. camera: FollowCamera;
  39051. /**
  39052. * Gets the class name of the current input.
  39053. * @returns the class name
  39054. */
  39055. getClassName(): string;
  39056. /**
  39057. * Defines the pointer angular sensibility along the X axis or how fast is
  39058. * the camera rotating.
  39059. * A negative number will reverse the axis direction.
  39060. */
  39061. angularSensibilityX: number;
  39062. /**
  39063. * Defines the pointer angular sensibility along the Y axis or how fast is
  39064. * the camera rotating.
  39065. * A negative number will reverse the axis direction.
  39066. */
  39067. angularSensibilityY: number;
  39068. /**
  39069. * Defines the pointer pinch precision or how fast is the camera zooming.
  39070. * A negative number will reverse the axis direction.
  39071. */
  39072. pinchPrecision: number;
  39073. /**
  39074. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39075. * from 0.
  39076. * It defines the percentage of current camera.radius to use as delta when
  39077. * pinch zoom is used.
  39078. */
  39079. pinchDeltaPercentage: number;
  39080. /**
  39081. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39082. */
  39083. axisXControlRadius: boolean;
  39084. /**
  39085. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39086. */
  39087. axisXControlHeight: boolean;
  39088. /**
  39089. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39090. */
  39091. axisXControlRotation: boolean;
  39092. /**
  39093. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39094. */
  39095. axisYControlRadius: boolean;
  39096. /**
  39097. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39098. */
  39099. axisYControlHeight: boolean;
  39100. /**
  39101. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39102. */
  39103. axisYControlRotation: boolean;
  39104. /**
  39105. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39106. */
  39107. axisPinchControlRadius: boolean;
  39108. /**
  39109. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39110. */
  39111. axisPinchControlHeight: boolean;
  39112. /**
  39113. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39114. */
  39115. axisPinchControlRotation: boolean;
  39116. /**
  39117. * Log error messages if basic misconfiguration has occurred.
  39118. */
  39119. warningEnable: boolean;
  39120. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39121. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39122. private _warningCounter;
  39123. private _warning;
  39124. }
  39125. }
  39126. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39127. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39128. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39129. /**
  39130. * Default Inputs manager for the FollowCamera.
  39131. * It groups all the default supported inputs for ease of use.
  39132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39133. */
  39134. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39135. /**
  39136. * Instantiates a new FollowCameraInputsManager.
  39137. * @param camera Defines the camera the inputs belong to
  39138. */
  39139. constructor(camera: FollowCamera);
  39140. /**
  39141. * Add keyboard input support to the input manager.
  39142. * @returns the current input manager
  39143. */
  39144. addKeyboard(): FollowCameraInputsManager;
  39145. /**
  39146. * Add mouse wheel input support to the input manager.
  39147. * @returns the current input manager
  39148. */
  39149. addMouseWheel(): FollowCameraInputsManager;
  39150. /**
  39151. * Add pointers input support to the input manager.
  39152. * @returns the current input manager
  39153. */
  39154. addPointers(): FollowCameraInputsManager;
  39155. /**
  39156. * Add orientation input support to the input manager.
  39157. * @returns the current input manager
  39158. */
  39159. addVRDeviceOrientation(): FollowCameraInputsManager;
  39160. }
  39161. }
  39162. declare module "babylonjs/Cameras/followCamera" {
  39163. import { Nullable } from "babylonjs/types";
  39164. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39165. import { Scene } from "babylonjs/scene";
  39166. import { Vector3 } from "babylonjs/Maths/math.vector";
  39167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39168. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39169. /**
  39170. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39171. * an arc rotate version arcFollowCamera are available.
  39172. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39173. */
  39174. export class FollowCamera extends TargetCamera {
  39175. /**
  39176. * Distance the follow camera should follow an object at
  39177. */
  39178. radius: number;
  39179. /**
  39180. * Minimum allowed distance of the camera to the axis of rotation
  39181. * (The camera can not get closer).
  39182. * This can help limiting how the Camera is able to move in the scene.
  39183. */
  39184. lowerRadiusLimit: Nullable<number>;
  39185. /**
  39186. * Maximum allowed distance of the camera to the axis of rotation
  39187. * (The camera can not get further).
  39188. * This can help limiting how the Camera is able to move in the scene.
  39189. */
  39190. upperRadiusLimit: Nullable<number>;
  39191. /**
  39192. * Define a rotation offset between the camera and the object it follows
  39193. */
  39194. rotationOffset: number;
  39195. /**
  39196. * Minimum allowed angle to camera position relative to target object.
  39197. * This can help limiting how the Camera is able to move in the scene.
  39198. */
  39199. lowerRotationOffsetLimit: Nullable<number>;
  39200. /**
  39201. * Maximum allowed angle to camera position relative to target object.
  39202. * This can help limiting how the Camera is able to move in the scene.
  39203. */
  39204. upperRotationOffsetLimit: Nullable<number>;
  39205. /**
  39206. * Define a height offset between the camera and the object it follows.
  39207. * It can help following an object from the top (like a car chaing a plane)
  39208. */
  39209. heightOffset: number;
  39210. /**
  39211. * Minimum allowed height of camera position relative to target object.
  39212. * This can help limiting how the Camera is able to move in the scene.
  39213. */
  39214. lowerHeightOffsetLimit: Nullable<number>;
  39215. /**
  39216. * Maximum allowed height of camera position relative to target object.
  39217. * This can help limiting how the Camera is able to move in the scene.
  39218. */
  39219. upperHeightOffsetLimit: Nullable<number>;
  39220. /**
  39221. * Define how fast the camera can accelerate to follow it s target.
  39222. */
  39223. cameraAcceleration: number;
  39224. /**
  39225. * Define the speed limit of the camera following an object.
  39226. */
  39227. maxCameraSpeed: number;
  39228. /**
  39229. * Define the target of the camera.
  39230. */
  39231. lockedTarget: Nullable<AbstractMesh>;
  39232. /**
  39233. * Defines the input associated with the camera.
  39234. */
  39235. inputs: FollowCameraInputsManager;
  39236. /**
  39237. * Instantiates the follow camera.
  39238. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39239. * @param name Define the name of the camera in the scene
  39240. * @param position Define the position of the camera
  39241. * @param scene Define the scene the camera belong to
  39242. * @param lockedTarget Define the target of the camera
  39243. */
  39244. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39245. private _follow;
  39246. /**
  39247. * Attached controls to the current camera.
  39248. * @param element Defines the element the controls should be listened from
  39249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39250. */
  39251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39252. /**
  39253. * Detach the current controls from the camera.
  39254. * The camera will stop reacting to inputs.
  39255. * @param element Defines the element to stop listening the inputs from
  39256. */
  39257. detachControl(element: HTMLElement): void;
  39258. /** @hidden */
  39259. _checkInputs(): void;
  39260. private _checkLimits;
  39261. /**
  39262. * Gets the camera class name.
  39263. * @returns the class name
  39264. */
  39265. getClassName(): string;
  39266. }
  39267. /**
  39268. * Arc Rotate version of the follow camera.
  39269. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39270. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39271. */
  39272. export class ArcFollowCamera extends TargetCamera {
  39273. /** The longitudinal angle of the camera */
  39274. alpha: number;
  39275. /** The latitudinal angle of the camera */
  39276. beta: number;
  39277. /** The radius of the camera from its target */
  39278. radius: number;
  39279. /** Define the camera target (the messh it should follow) */
  39280. target: Nullable<AbstractMesh>;
  39281. private _cartesianCoordinates;
  39282. /**
  39283. * Instantiates a new ArcFollowCamera
  39284. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39285. * @param name Define the name of the camera
  39286. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39287. * @param beta Define the rotation angle of the camera around the elevation axis
  39288. * @param radius Define the radius of the camera from its target point
  39289. * @param target Define the target of the camera
  39290. * @param scene Define the scene the camera belongs to
  39291. */
  39292. constructor(name: string,
  39293. /** The longitudinal angle of the camera */
  39294. alpha: number,
  39295. /** The latitudinal angle of the camera */
  39296. beta: number,
  39297. /** The radius of the camera from its target */
  39298. radius: number,
  39299. /** Define the camera target (the messh it should follow) */
  39300. target: Nullable<AbstractMesh>, scene: Scene);
  39301. private _follow;
  39302. /** @hidden */
  39303. _checkInputs(): void;
  39304. /**
  39305. * Returns the class name of the object.
  39306. * It is mostly used internally for serialization purposes.
  39307. */
  39308. getClassName(): string;
  39309. }
  39310. }
  39311. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39312. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39313. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39314. import { Nullable } from "babylonjs/types";
  39315. /**
  39316. * Manage the keyboard inputs to control the movement of a follow camera.
  39317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39318. */
  39319. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39320. /**
  39321. * Defines the camera the input is attached to.
  39322. */
  39323. camera: FollowCamera;
  39324. /**
  39325. * Defines the list of key codes associated with the up action (increase heightOffset)
  39326. */
  39327. keysHeightOffsetIncr: number[];
  39328. /**
  39329. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39330. */
  39331. keysHeightOffsetDecr: number[];
  39332. /**
  39333. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39334. */
  39335. keysHeightOffsetModifierAlt: boolean;
  39336. /**
  39337. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39338. */
  39339. keysHeightOffsetModifierCtrl: boolean;
  39340. /**
  39341. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39342. */
  39343. keysHeightOffsetModifierShift: boolean;
  39344. /**
  39345. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39346. */
  39347. keysRotationOffsetIncr: number[];
  39348. /**
  39349. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39350. */
  39351. keysRotationOffsetDecr: number[];
  39352. /**
  39353. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39354. */
  39355. keysRotationOffsetModifierAlt: boolean;
  39356. /**
  39357. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39358. */
  39359. keysRotationOffsetModifierCtrl: boolean;
  39360. /**
  39361. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39362. */
  39363. keysRotationOffsetModifierShift: boolean;
  39364. /**
  39365. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39366. */
  39367. keysRadiusIncr: number[];
  39368. /**
  39369. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39370. */
  39371. keysRadiusDecr: number[];
  39372. /**
  39373. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39374. */
  39375. keysRadiusModifierAlt: boolean;
  39376. /**
  39377. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39378. */
  39379. keysRadiusModifierCtrl: boolean;
  39380. /**
  39381. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39382. */
  39383. keysRadiusModifierShift: boolean;
  39384. /**
  39385. * Defines the rate of change of heightOffset.
  39386. */
  39387. heightSensibility: number;
  39388. /**
  39389. * Defines the rate of change of rotationOffset.
  39390. */
  39391. rotationSensibility: number;
  39392. /**
  39393. * Defines the rate of change of radius.
  39394. */
  39395. radiusSensibility: number;
  39396. private _keys;
  39397. private _ctrlPressed;
  39398. private _altPressed;
  39399. private _shiftPressed;
  39400. private _onCanvasBlurObserver;
  39401. private _onKeyboardObserver;
  39402. private _engine;
  39403. private _scene;
  39404. /**
  39405. * Attach the input controls to a specific dom element to get the input from.
  39406. * @param element Defines the element the controls should be listened from
  39407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39408. */
  39409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39410. /**
  39411. * Detach the current controls from the specified dom element.
  39412. * @param element Defines the element to stop listening the inputs from
  39413. */
  39414. detachControl(element: Nullable<HTMLElement>): void;
  39415. /**
  39416. * Update the current camera state depending on the inputs that have been used this frame.
  39417. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39418. */
  39419. checkInputs(): void;
  39420. /**
  39421. * Gets the class name of the current input.
  39422. * @returns the class name
  39423. */
  39424. getClassName(): string;
  39425. /**
  39426. * Get the friendly name associated with the input class.
  39427. * @returns the input friendly name
  39428. */
  39429. getSimpleName(): string;
  39430. /**
  39431. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39432. * allow modification of the heightOffset value.
  39433. */
  39434. private _modifierHeightOffset;
  39435. /**
  39436. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39437. * allow modification of the rotationOffset value.
  39438. */
  39439. private _modifierRotationOffset;
  39440. /**
  39441. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39442. * allow modification of the radius value.
  39443. */
  39444. private _modifierRadius;
  39445. }
  39446. }
  39447. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39448. import { Nullable } from "babylonjs/types";
  39449. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39450. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39451. import { Observable } from "babylonjs/Misc/observable";
  39452. module "babylonjs/Cameras/freeCameraInputsManager" {
  39453. interface FreeCameraInputsManager {
  39454. /**
  39455. * @hidden
  39456. */
  39457. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39458. /**
  39459. * Add orientation input support to the input manager.
  39460. * @returns the current input manager
  39461. */
  39462. addDeviceOrientation(): FreeCameraInputsManager;
  39463. }
  39464. }
  39465. /**
  39466. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39467. * Screen rotation is taken into account.
  39468. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39469. */
  39470. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39471. private _camera;
  39472. private _screenOrientationAngle;
  39473. private _constantTranform;
  39474. private _screenQuaternion;
  39475. private _alpha;
  39476. private _beta;
  39477. private _gamma;
  39478. /**
  39479. * Can be used to detect if a device orientation sensor is availible on a device
  39480. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39481. * @returns a promise that will resolve on orientation change
  39482. */
  39483. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39484. /**
  39485. * @hidden
  39486. */
  39487. _onDeviceOrientationChangedObservable: Observable<void>;
  39488. /**
  39489. * Instantiates a new input
  39490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39491. */
  39492. constructor();
  39493. /**
  39494. * Define the camera controlled by the input.
  39495. */
  39496. camera: FreeCamera;
  39497. /**
  39498. * Attach the input controls to a specific dom element to get the input from.
  39499. * @param element Defines the element the controls should be listened from
  39500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39501. */
  39502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39503. private _orientationChanged;
  39504. private _deviceOrientation;
  39505. /**
  39506. * Detach the current controls from the specified dom element.
  39507. * @param element Defines the element to stop listening the inputs from
  39508. */
  39509. detachControl(element: Nullable<HTMLElement>): void;
  39510. /**
  39511. * Update the current camera state depending on the inputs that have been used this frame.
  39512. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39513. */
  39514. checkInputs(): void;
  39515. /**
  39516. * Gets the class name of the current intput.
  39517. * @returns the class name
  39518. */
  39519. getClassName(): string;
  39520. /**
  39521. * Get the friendly name associated with the input class.
  39522. * @returns the input friendly name
  39523. */
  39524. getSimpleName(): string;
  39525. }
  39526. }
  39527. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39528. import { Nullable } from "babylonjs/types";
  39529. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39530. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39531. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39532. /**
  39533. * Manage the gamepad inputs to control a free camera.
  39534. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39535. */
  39536. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39537. /**
  39538. * Define the camera the input is attached to.
  39539. */
  39540. camera: FreeCamera;
  39541. /**
  39542. * Define the Gamepad controlling the input
  39543. */
  39544. gamepad: Nullable<Gamepad>;
  39545. /**
  39546. * Defines the gamepad rotation sensiblity.
  39547. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39548. */
  39549. gamepadAngularSensibility: number;
  39550. /**
  39551. * Defines the gamepad move sensiblity.
  39552. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39553. */
  39554. gamepadMoveSensibility: number;
  39555. private _yAxisScale;
  39556. /**
  39557. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39558. */
  39559. invertYAxis: boolean;
  39560. private _onGamepadConnectedObserver;
  39561. private _onGamepadDisconnectedObserver;
  39562. private _cameraTransform;
  39563. private _deltaTransform;
  39564. private _vector3;
  39565. private _vector2;
  39566. /**
  39567. * Attach the input controls to a specific dom element to get the input from.
  39568. * @param element Defines the element the controls should be listened from
  39569. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39570. */
  39571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39572. /**
  39573. * Detach the current controls from the specified dom element.
  39574. * @param element Defines the element to stop listening the inputs from
  39575. */
  39576. detachControl(element: Nullable<HTMLElement>): void;
  39577. /**
  39578. * Update the current camera state depending on the inputs that have been used this frame.
  39579. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39580. */
  39581. checkInputs(): void;
  39582. /**
  39583. * Gets the class name of the current intput.
  39584. * @returns the class name
  39585. */
  39586. getClassName(): string;
  39587. /**
  39588. * Get the friendly name associated with the input class.
  39589. * @returns the input friendly name
  39590. */
  39591. getSimpleName(): string;
  39592. }
  39593. }
  39594. declare module "babylonjs/Misc/virtualJoystick" {
  39595. import { Nullable } from "babylonjs/types";
  39596. import { Vector3 } from "babylonjs/Maths/math.vector";
  39597. /**
  39598. * Defines the potential axis of a Joystick
  39599. */
  39600. export enum JoystickAxis {
  39601. /** X axis */
  39602. X = 0,
  39603. /** Y axis */
  39604. Y = 1,
  39605. /** Z axis */
  39606. Z = 2
  39607. }
  39608. /**
  39609. * Class used to define virtual joystick (used in touch mode)
  39610. */
  39611. export class VirtualJoystick {
  39612. /**
  39613. * Gets or sets a boolean indicating that left and right values must be inverted
  39614. */
  39615. reverseLeftRight: boolean;
  39616. /**
  39617. * Gets or sets a boolean indicating that up and down values must be inverted
  39618. */
  39619. reverseUpDown: boolean;
  39620. /**
  39621. * Gets the offset value for the position (ie. the change of the position value)
  39622. */
  39623. deltaPosition: Vector3;
  39624. /**
  39625. * Gets a boolean indicating if the virtual joystick was pressed
  39626. */
  39627. pressed: boolean;
  39628. /**
  39629. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39630. */
  39631. static Canvas: Nullable<HTMLCanvasElement>;
  39632. private static _globalJoystickIndex;
  39633. private static vjCanvasContext;
  39634. private static vjCanvasWidth;
  39635. private static vjCanvasHeight;
  39636. private static halfWidth;
  39637. private _action;
  39638. private _axisTargetedByLeftAndRight;
  39639. private _axisTargetedByUpAndDown;
  39640. private _joystickSensibility;
  39641. private _inversedSensibility;
  39642. private _joystickPointerID;
  39643. private _joystickColor;
  39644. private _joystickPointerPos;
  39645. private _joystickPreviousPointerPos;
  39646. private _joystickPointerStartPos;
  39647. private _deltaJoystickVector;
  39648. private _leftJoystick;
  39649. private _touches;
  39650. private _onPointerDownHandlerRef;
  39651. private _onPointerMoveHandlerRef;
  39652. private _onPointerUpHandlerRef;
  39653. private _onResize;
  39654. /**
  39655. * Creates a new virtual joystick
  39656. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39657. */
  39658. constructor(leftJoystick?: boolean);
  39659. /**
  39660. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39661. * @param newJoystickSensibility defines the new sensibility
  39662. */
  39663. setJoystickSensibility(newJoystickSensibility: number): void;
  39664. private _onPointerDown;
  39665. private _onPointerMove;
  39666. private _onPointerUp;
  39667. /**
  39668. * Change the color of the virtual joystick
  39669. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39670. */
  39671. setJoystickColor(newColor: string): void;
  39672. /**
  39673. * Defines a callback to call when the joystick is touched
  39674. * @param action defines the callback
  39675. */
  39676. setActionOnTouch(action: () => any): void;
  39677. /**
  39678. * Defines which axis you'd like to control for left & right
  39679. * @param axis defines the axis to use
  39680. */
  39681. setAxisForLeftRight(axis: JoystickAxis): void;
  39682. /**
  39683. * Defines which axis you'd like to control for up & down
  39684. * @param axis defines the axis to use
  39685. */
  39686. setAxisForUpDown(axis: JoystickAxis): void;
  39687. private _drawVirtualJoystick;
  39688. /**
  39689. * Release internal HTML canvas
  39690. */
  39691. releaseCanvas(): void;
  39692. }
  39693. }
  39694. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39695. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39696. import { Nullable } from "babylonjs/types";
  39697. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39698. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39699. module "babylonjs/Cameras/freeCameraInputsManager" {
  39700. interface FreeCameraInputsManager {
  39701. /**
  39702. * Add virtual joystick input support to the input manager.
  39703. * @returns the current input manager
  39704. */
  39705. addVirtualJoystick(): FreeCameraInputsManager;
  39706. }
  39707. }
  39708. /**
  39709. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39710. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39711. */
  39712. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39713. /**
  39714. * Defines the camera the input is attached to.
  39715. */
  39716. camera: FreeCamera;
  39717. private _leftjoystick;
  39718. private _rightjoystick;
  39719. /**
  39720. * Gets the left stick of the virtual joystick.
  39721. * @returns The virtual Joystick
  39722. */
  39723. getLeftJoystick(): VirtualJoystick;
  39724. /**
  39725. * Gets the right stick of the virtual joystick.
  39726. * @returns The virtual Joystick
  39727. */
  39728. getRightJoystick(): VirtualJoystick;
  39729. /**
  39730. * Update the current camera state depending on the inputs that have been used this frame.
  39731. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39732. */
  39733. checkInputs(): void;
  39734. /**
  39735. * Attach the input controls to a specific dom element to get the input from.
  39736. * @param element Defines the element the controls should be listened from
  39737. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39738. */
  39739. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39740. /**
  39741. * Detach the current controls from the specified dom element.
  39742. * @param element Defines the element to stop listening the inputs from
  39743. */
  39744. detachControl(element: Nullable<HTMLElement>): void;
  39745. /**
  39746. * Gets the class name of the current intput.
  39747. * @returns the class name
  39748. */
  39749. getClassName(): string;
  39750. /**
  39751. * Get the friendly name associated with the input class.
  39752. * @returns the input friendly name
  39753. */
  39754. getSimpleName(): string;
  39755. }
  39756. }
  39757. declare module "babylonjs/Cameras/Inputs/index" {
  39758. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39759. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39760. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39761. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39762. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39763. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39764. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39765. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39766. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39767. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39768. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39769. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39770. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39771. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39772. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39773. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39774. }
  39775. declare module "babylonjs/Cameras/touchCamera" {
  39776. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39777. import { Scene } from "babylonjs/scene";
  39778. import { Vector3 } from "babylonjs/Maths/math.vector";
  39779. /**
  39780. * This represents a FPS type of camera controlled by touch.
  39781. * This is like a universal camera minus the Gamepad controls.
  39782. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39783. */
  39784. export class TouchCamera extends FreeCamera {
  39785. /**
  39786. * Defines the touch sensibility for rotation.
  39787. * The higher the faster.
  39788. */
  39789. touchAngularSensibility: number;
  39790. /**
  39791. * Defines the touch sensibility for move.
  39792. * The higher the faster.
  39793. */
  39794. touchMoveSensibility: number;
  39795. /**
  39796. * Instantiates a new touch camera.
  39797. * This represents a FPS type of camera controlled by touch.
  39798. * This is like a universal camera minus the Gamepad controls.
  39799. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39800. * @param name Define the name of the camera in the scene
  39801. * @param position Define the start position of the camera in the scene
  39802. * @param scene Define the scene the camera belongs to
  39803. */
  39804. constructor(name: string, position: Vector3, scene: Scene);
  39805. /**
  39806. * Gets the current object class name.
  39807. * @return the class name
  39808. */
  39809. getClassName(): string;
  39810. /** @hidden */
  39811. _setupInputs(): void;
  39812. }
  39813. }
  39814. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39815. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39816. import { Scene } from "babylonjs/scene";
  39817. import { Vector3 } from "babylonjs/Maths/math.vector";
  39818. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39819. import { Axis } from "babylonjs/Maths/math.axis";
  39820. /**
  39821. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39822. * being tilted forward or back and left or right.
  39823. */
  39824. export class DeviceOrientationCamera extends FreeCamera {
  39825. private _initialQuaternion;
  39826. private _quaternionCache;
  39827. private _tmpDragQuaternion;
  39828. private _disablePointerInputWhenUsingDeviceOrientation;
  39829. /**
  39830. * Creates a new device orientation camera
  39831. * @param name The name of the camera
  39832. * @param position The start position camera
  39833. * @param scene The scene the camera belongs to
  39834. */
  39835. constructor(name: string, position: Vector3, scene: Scene);
  39836. /**
  39837. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39838. */
  39839. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39840. private _dragFactor;
  39841. /**
  39842. * Enabled turning on the y axis when the orientation sensor is active
  39843. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39844. */
  39845. enableHorizontalDragging(dragFactor?: number): void;
  39846. /**
  39847. * Gets the current instance class name ("DeviceOrientationCamera").
  39848. * This helps avoiding instanceof at run time.
  39849. * @returns the class name
  39850. */
  39851. getClassName(): string;
  39852. /**
  39853. * @hidden
  39854. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39855. */
  39856. _checkInputs(): void;
  39857. /**
  39858. * Reset the camera to its default orientation on the specified axis only.
  39859. * @param axis The axis to reset
  39860. */
  39861. resetToCurrentRotation(axis?: Axis): void;
  39862. }
  39863. }
  39864. declare module "babylonjs/Gamepads/xboxGamepad" {
  39865. import { Observable } from "babylonjs/Misc/observable";
  39866. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39867. /**
  39868. * Defines supported buttons for XBox360 compatible gamepads
  39869. */
  39870. export enum Xbox360Button {
  39871. /** A */
  39872. A = 0,
  39873. /** B */
  39874. B = 1,
  39875. /** X */
  39876. X = 2,
  39877. /** Y */
  39878. Y = 3,
  39879. /** Start */
  39880. Start = 4,
  39881. /** Back */
  39882. Back = 5,
  39883. /** Left button */
  39884. LB = 6,
  39885. /** Right button */
  39886. RB = 7,
  39887. /** Left stick */
  39888. LeftStick = 8,
  39889. /** Right stick */
  39890. RightStick = 9
  39891. }
  39892. /** Defines values for XBox360 DPad */
  39893. export enum Xbox360Dpad {
  39894. /** Up */
  39895. Up = 0,
  39896. /** Down */
  39897. Down = 1,
  39898. /** Left */
  39899. Left = 2,
  39900. /** Right */
  39901. Right = 3
  39902. }
  39903. /**
  39904. * Defines a XBox360 gamepad
  39905. */
  39906. export class Xbox360Pad extends Gamepad {
  39907. private _leftTrigger;
  39908. private _rightTrigger;
  39909. private _onlefttriggerchanged;
  39910. private _onrighttriggerchanged;
  39911. private _onbuttondown;
  39912. private _onbuttonup;
  39913. private _ondpaddown;
  39914. private _ondpadup;
  39915. /** Observable raised when a button is pressed */
  39916. onButtonDownObservable: Observable<Xbox360Button>;
  39917. /** Observable raised when a button is released */
  39918. onButtonUpObservable: Observable<Xbox360Button>;
  39919. /** Observable raised when a pad is pressed */
  39920. onPadDownObservable: Observable<Xbox360Dpad>;
  39921. /** Observable raised when a pad is released */
  39922. onPadUpObservable: Observable<Xbox360Dpad>;
  39923. private _buttonA;
  39924. private _buttonB;
  39925. private _buttonX;
  39926. private _buttonY;
  39927. private _buttonBack;
  39928. private _buttonStart;
  39929. private _buttonLB;
  39930. private _buttonRB;
  39931. private _buttonLeftStick;
  39932. private _buttonRightStick;
  39933. private _dPadUp;
  39934. private _dPadDown;
  39935. private _dPadLeft;
  39936. private _dPadRight;
  39937. private _isXboxOnePad;
  39938. /**
  39939. * Creates a new XBox360 gamepad object
  39940. * @param id defines the id of this gamepad
  39941. * @param index defines its index
  39942. * @param gamepad defines the internal HTML gamepad object
  39943. * @param xboxOne defines if it is a XBox One gamepad
  39944. */
  39945. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39946. /**
  39947. * Defines the callback to call when left trigger is pressed
  39948. * @param callback defines the callback to use
  39949. */
  39950. onlefttriggerchanged(callback: (value: number) => void): void;
  39951. /**
  39952. * Defines the callback to call when right trigger is pressed
  39953. * @param callback defines the callback to use
  39954. */
  39955. onrighttriggerchanged(callback: (value: number) => void): void;
  39956. /**
  39957. * Gets the left trigger value
  39958. */
  39959. /**
  39960. * Sets the left trigger value
  39961. */
  39962. leftTrigger: number;
  39963. /**
  39964. * Gets the right trigger value
  39965. */
  39966. /**
  39967. * Sets the right trigger value
  39968. */
  39969. rightTrigger: number;
  39970. /**
  39971. * Defines the callback to call when a button is pressed
  39972. * @param callback defines the callback to use
  39973. */
  39974. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39975. /**
  39976. * Defines the callback to call when a button is released
  39977. * @param callback defines the callback to use
  39978. */
  39979. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39980. /**
  39981. * Defines the callback to call when a pad is pressed
  39982. * @param callback defines the callback to use
  39983. */
  39984. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39985. /**
  39986. * Defines the callback to call when a pad is released
  39987. * @param callback defines the callback to use
  39988. */
  39989. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39990. private _setButtonValue;
  39991. private _setDPadValue;
  39992. /**
  39993. * Gets the value of the `A` button
  39994. */
  39995. /**
  39996. * Sets the value of the `A` button
  39997. */
  39998. buttonA: number;
  39999. /**
  40000. * Gets the value of the `B` button
  40001. */
  40002. /**
  40003. * Sets the value of the `B` button
  40004. */
  40005. buttonB: number;
  40006. /**
  40007. * Gets the value of the `X` button
  40008. */
  40009. /**
  40010. * Sets the value of the `X` button
  40011. */
  40012. buttonX: number;
  40013. /**
  40014. * Gets the value of the `Y` button
  40015. */
  40016. /**
  40017. * Sets the value of the `Y` button
  40018. */
  40019. buttonY: number;
  40020. /**
  40021. * Gets the value of the `Start` button
  40022. */
  40023. /**
  40024. * Sets the value of the `Start` button
  40025. */
  40026. buttonStart: number;
  40027. /**
  40028. * Gets the value of the `Back` button
  40029. */
  40030. /**
  40031. * Sets the value of the `Back` button
  40032. */
  40033. buttonBack: number;
  40034. /**
  40035. * Gets the value of the `Left` button
  40036. */
  40037. /**
  40038. * Sets the value of the `Left` button
  40039. */
  40040. buttonLB: number;
  40041. /**
  40042. * Gets the value of the `Right` button
  40043. */
  40044. /**
  40045. * Sets the value of the `Right` button
  40046. */
  40047. buttonRB: number;
  40048. /**
  40049. * Gets the value of the Left joystick
  40050. */
  40051. /**
  40052. * Sets the value of the Left joystick
  40053. */
  40054. buttonLeftStick: number;
  40055. /**
  40056. * Gets the value of the Right joystick
  40057. */
  40058. /**
  40059. * Sets the value of the Right joystick
  40060. */
  40061. buttonRightStick: number;
  40062. /**
  40063. * Gets the value of D-pad up
  40064. */
  40065. /**
  40066. * Sets the value of D-pad up
  40067. */
  40068. dPadUp: number;
  40069. /**
  40070. * Gets the value of D-pad down
  40071. */
  40072. /**
  40073. * Sets the value of D-pad down
  40074. */
  40075. dPadDown: number;
  40076. /**
  40077. * Gets the value of D-pad left
  40078. */
  40079. /**
  40080. * Sets the value of D-pad left
  40081. */
  40082. dPadLeft: number;
  40083. /**
  40084. * Gets the value of D-pad right
  40085. */
  40086. /**
  40087. * Sets the value of D-pad right
  40088. */
  40089. dPadRight: number;
  40090. /**
  40091. * Force the gamepad to synchronize with device values
  40092. */
  40093. update(): void;
  40094. /**
  40095. * Disposes the gamepad
  40096. */
  40097. dispose(): void;
  40098. }
  40099. }
  40100. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40101. import { Observable } from "babylonjs/Misc/observable";
  40102. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40103. /**
  40104. * Defines supported buttons for DualShock compatible gamepads
  40105. */
  40106. export enum DualShockButton {
  40107. /** Cross */
  40108. Cross = 0,
  40109. /** Circle */
  40110. Circle = 1,
  40111. /** Square */
  40112. Square = 2,
  40113. /** Triangle */
  40114. Triangle = 3,
  40115. /** Options */
  40116. Options = 4,
  40117. /** Share */
  40118. Share = 5,
  40119. /** L1 */
  40120. L1 = 6,
  40121. /** R1 */
  40122. R1 = 7,
  40123. /** Left stick */
  40124. LeftStick = 8,
  40125. /** Right stick */
  40126. RightStick = 9
  40127. }
  40128. /** Defines values for DualShock DPad */
  40129. export enum DualShockDpad {
  40130. /** Up */
  40131. Up = 0,
  40132. /** Down */
  40133. Down = 1,
  40134. /** Left */
  40135. Left = 2,
  40136. /** Right */
  40137. Right = 3
  40138. }
  40139. /**
  40140. * Defines a DualShock gamepad
  40141. */
  40142. export class DualShockPad extends Gamepad {
  40143. private _leftTrigger;
  40144. private _rightTrigger;
  40145. private _onlefttriggerchanged;
  40146. private _onrighttriggerchanged;
  40147. private _onbuttondown;
  40148. private _onbuttonup;
  40149. private _ondpaddown;
  40150. private _ondpadup;
  40151. /** Observable raised when a button is pressed */
  40152. onButtonDownObservable: Observable<DualShockButton>;
  40153. /** Observable raised when a button is released */
  40154. onButtonUpObservable: Observable<DualShockButton>;
  40155. /** Observable raised when a pad is pressed */
  40156. onPadDownObservable: Observable<DualShockDpad>;
  40157. /** Observable raised when a pad is released */
  40158. onPadUpObservable: Observable<DualShockDpad>;
  40159. private _buttonCross;
  40160. private _buttonCircle;
  40161. private _buttonSquare;
  40162. private _buttonTriangle;
  40163. private _buttonShare;
  40164. private _buttonOptions;
  40165. private _buttonL1;
  40166. private _buttonR1;
  40167. private _buttonLeftStick;
  40168. private _buttonRightStick;
  40169. private _dPadUp;
  40170. private _dPadDown;
  40171. private _dPadLeft;
  40172. private _dPadRight;
  40173. /**
  40174. * Creates a new DualShock gamepad object
  40175. * @param id defines the id of this gamepad
  40176. * @param index defines its index
  40177. * @param gamepad defines the internal HTML gamepad object
  40178. */
  40179. constructor(id: string, index: number, gamepad: any);
  40180. /**
  40181. * Defines the callback to call when left trigger is pressed
  40182. * @param callback defines the callback to use
  40183. */
  40184. onlefttriggerchanged(callback: (value: number) => void): void;
  40185. /**
  40186. * Defines the callback to call when right trigger is pressed
  40187. * @param callback defines the callback to use
  40188. */
  40189. onrighttriggerchanged(callback: (value: number) => void): void;
  40190. /**
  40191. * Gets the left trigger value
  40192. */
  40193. /**
  40194. * Sets the left trigger value
  40195. */
  40196. leftTrigger: number;
  40197. /**
  40198. * Gets the right trigger value
  40199. */
  40200. /**
  40201. * Sets the right trigger value
  40202. */
  40203. rightTrigger: number;
  40204. /**
  40205. * Defines the callback to call when a button is pressed
  40206. * @param callback defines the callback to use
  40207. */
  40208. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40209. /**
  40210. * Defines the callback to call when a button is released
  40211. * @param callback defines the callback to use
  40212. */
  40213. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40214. /**
  40215. * Defines the callback to call when a pad is pressed
  40216. * @param callback defines the callback to use
  40217. */
  40218. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40219. /**
  40220. * Defines the callback to call when a pad is released
  40221. * @param callback defines the callback to use
  40222. */
  40223. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40224. private _setButtonValue;
  40225. private _setDPadValue;
  40226. /**
  40227. * Gets the value of the `Cross` button
  40228. */
  40229. /**
  40230. * Sets the value of the `Cross` button
  40231. */
  40232. buttonCross: number;
  40233. /**
  40234. * Gets the value of the `Circle` button
  40235. */
  40236. /**
  40237. * Sets the value of the `Circle` button
  40238. */
  40239. buttonCircle: number;
  40240. /**
  40241. * Gets the value of the `Square` button
  40242. */
  40243. /**
  40244. * Sets the value of the `Square` button
  40245. */
  40246. buttonSquare: number;
  40247. /**
  40248. * Gets the value of the `Triangle` button
  40249. */
  40250. /**
  40251. * Sets the value of the `Triangle` button
  40252. */
  40253. buttonTriangle: number;
  40254. /**
  40255. * Gets the value of the `Options` button
  40256. */
  40257. /**
  40258. * Sets the value of the `Options` button
  40259. */
  40260. buttonOptions: number;
  40261. /**
  40262. * Gets the value of the `Share` button
  40263. */
  40264. /**
  40265. * Sets the value of the `Share` button
  40266. */
  40267. buttonShare: number;
  40268. /**
  40269. * Gets the value of the `L1` button
  40270. */
  40271. /**
  40272. * Sets the value of the `L1` button
  40273. */
  40274. buttonL1: number;
  40275. /**
  40276. * Gets the value of the `R1` button
  40277. */
  40278. /**
  40279. * Sets the value of the `R1` button
  40280. */
  40281. buttonR1: number;
  40282. /**
  40283. * Gets the value of the Left joystick
  40284. */
  40285. /**
  40286. * Sets the value of the Left joystick
  40287. */
  40288. buttonLeftStick: number;
  40289. /**
  40290. * Gets the value of the Right joystick
  40291. */
  40292. /**
  40293. * Sets the value of the Right joystick
  40294. */
  40295. buttonRightStick: number;
  40296. /**
  40297. * Gets the value of D-pad up
  40298. */
  40299. /**
  40300. * Sets the value of D-pad up
  40301. */
  40302. dPadUp: number;
  40303. /**
  40304. * Gets the value of D-pad down
  40305. */
  40306. /**
  40307. * Sets the value of D-pad down
  40308. */
  40309. dPadDown: number;
  40310. /**
  40311. * Gets the value of D-pad left
  40312. */
  40313. /**
  40314. * Sets the value of D-pad left
  40315. */
  40316. dPadLeft: number;
  40317. /**
  40318. * Gets the value of D-pad right
  40319. */
  40320. /**
  40321. * Sets the value of D-pad right
  40322. */
  40323. dPadRight: number;
  40324. /**
  40325. * Force the gamepad to synchronize with device values
  40326. */
  40327. update(): void;
  40328. /**
  40329. * Disposes the gamepad
  40330. */
  40331. dispose(): void;
  40332. }
  40333. }
  40334. declare module "babylonjs/Gamepads/gamepadManager" {
  40335. import { Observable } from "babylonjs/Misc/observable";
  40336. import { Nullable } from "babylonjs/types";
  40337. import { Scene } from "babylonjs/scene";
  40338. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40339. /**
  40340. * Manager for handling gamepads
  40341. */
  40342. export class GamepadManager {
  40343. private _scene?;
  40344. private _babylonGamepads;
  40345. private _oneGamepadConnected;
  40346. /** @hidden */
  40347. _isMonitoring: boolean;
  40348. private _gamepadEventSupported;
  40349. private _gamepadSupport;
  40350. /**
  40351. * observable to be triggered when the gamepad controller has been connected
  40352. */
  40353. onGamepadConnectedObservable: Observable<Gamepad>;
  40354. /**
  40355. * observable to be triggered when the gamepad controller has been disconnected
  40356. */
  40357. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40358. private _onGamepadConnectedEvent;
  40359. private _onGamepadDisconnectedEvent;
  40360. /**
  40361. * Initializes the gamepad manager
  40362. * @param _scene BabylonJS scene
  40363. */
  40364. constructor(_scene?: Scene | undefined);
  40365. /**
  40366. * The gamepads in the game pad manager
  40367. */
  40368. readonly gamepads: Gamepad[];
  40369. /**
  40370. * Get the gamepad controllers based on type
  40371. * @param type The type of gamepad controller
  40372. * @returns Nullable gamepad
  40373. */
  40374. getGamepadByType(type?: number): Nullable<Gamepad>;
  40375. /**
  40376. * Disposes the gamepad manager
  40377. */
  40378. dispose(): void;
  40379. private _addNewGamepad;
  40380. private _startMonitoringGamepads;
  40381. private _stopMonitoringGamepads;
  40382. /** @hidden */
  40383. _checkGamepadsStatus(): void;
  40384. private _updateGamepadObjects;
  40385. }
  40386. }
  40387. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40388. import { Nullable } from "babylonjs/types";
  40389. import { Scene } from "babylonjs/scene";
  40390. import { ISceneComponent } from "babylonjs/sceneComponent";
  40391. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40392. module "babylonjs/scene" {
  40393. interface Scene {
  40394. /** @hidden */
  40395. _gamepadManager: Nullable<GamepadManager>;
  40396. /**
  40397. * Gets the gamepad manager associated with the scene
  40398. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40399. */
  40400. gamepadManager: GamepadManager;
  40401. }
  40402. }
  40403. module "babylonjs/Cameras/freeCameraInputsManager" {
  40404. /**
  40405. * Interface representing a free camera inputs manager
  40406. */
  40407. interface FreeCameraInputsManager {
  40408. /**
  40409. * Adds gamepad input support to the FreeCameraInputsManager.
  40410. * @returns the FreeCameraInputsManager
  40411. */
  40412. addGamepad(): FreeCameraInputsManager;
  40413. }
  40414. }
  40415. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40416. /**
  40417. * Interface representing an arc rotate camera inputs manager
  40418. */
  40419. interface ArcRotateCameraInputsManager {
  40420. /**
  40421. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40422. * @returns the camera inputs manager
  40423. */
  40424. addGamepad(): ArcRotateCameraInputsManager;
  40425. }
  40426. }
  40427. /**
  40428. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40429. */
  40430. export class GamepadSystemSceneComponent implements ISceneComponent {
  40431. /**
  40432. * The component name helpfull to identify the component in the list of scene components.
  40433. */
  40434. readonly name: string;
  40435. /**
  40436. * The scene the component belongs to.
  40437. */
  40438. scene: Scene;
  40439. /**
  40440. * Creates a new instance of the component for the given scene
  40441. * @param scene Defines the scene to register the component in
  40442. */
  40443. constructor(scene: Scene);
  40444. /**
  40445. * Registers the component in a given scene
  40446. */
  40447. register(): void;
  40448. /**
  40449. * Rebuilds the elements related to this component in case of
  40450. * context lost for instance.
  40451. */
  40452. rebuild(): void;
  40453. /**
  40454. * Disposes the component and the associated ressources
  40455. */
  40456. dispose(): void;
  40457. private _beforeCameraUpdate;
  40458. }
  40459. }
  40460. declare module "babylonjs/Cameras/universalCamera" {
  40461. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40462. import { Scene } from "babylonjs/scene";
  40463. import { Vector3 } from "babylonjs/Maths/math.vector";
  40464. import "babylonjs/Gamepads/gamepadSceneComponent";
  40465. /**
  40466. * 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,
  40467. * which still works and will still be found in many Playgrounds.
  40468. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40469. */
  40470. export class UniversalCamera extends TouchCamera {
  40471. /**
  40472. * Defines the gamepad rotation sensiblity.
  40473. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40474. */
  40475. gamepadAngularSensibility: number;
  40476. /**
  40477. * Defines the gamepad move sensiblity.
  40478. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40479. */
  40480. gamepadMoveSensibility: number;
  40481. /**
  40482. * 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,
  40483. * which still works and will still be found in many Playgrounds.
  40484. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40485. * @param name Define the name of the camera in the scene
  40486. * @param position Define the start position of the camera in the scene
  40487. * @param scene Define the scene the camera belongs to
  40488. */
  40489. constructor(name: string, position: Vector3, scene: Scene);
  40490. /**
  40491. * Gets the current object class name.
  40492. * @return the class name
  40493. */
  40494. getClassName(): string;
  40495. }
  40496. }
  40497. declare module "babylonjs/Cameras/gamepadCamera" {
  40498. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40499. import { Scene } from "babylonjs/scene";
  40500. import { Vector3 } from "babylonjs/Maths/math.vector";
  40501. /**
  40502. * This represents a FPS type of camera. This is only here for back compat purpose.
  40503. * Please use the UniversalCamera instead as both are identical.
  40504. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40505. */
  40506. export class GamepadCamera extends UniversalCamera {
  40507. /**
  40508. * Instantiates a new Gamepad Camera
  40509. * This represents a FPS type of camera. This is only here for back compat purpose.
  40510. * Please use the UniversalCamera instead as both are identical.
  40511. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40512. * @param name Define the name of the camera in the scene
  40513. * @param position Define the start position of the camera in the scene
  40514. * @param scene Define the scene the camera belongs to
  40515. */
  40516. constructor(name: string, position: Vector3, scene: Scene);
  40517. /**
  40518. * Gets the current object class name.
  40519. * @return the class name
  40520. */
  40521. getClassName(): string;
  40522. }
  40523. }
  40524. declare module "babylonjs/Shaders/pass.fragment" {
  40525. /** @hidden */
  40526. export var passPixelShader: {
  40527. name: string;
  40528. shader: string;
  40529. };
  40530. }
  40531. declare module "babylonjs/Shaders/passCube.fragment" {
  40532. /** @hidden */
  40533. export var passCubePixelShader: {
  40534. name: string;
  40535. shader: string;
  40536. };
  40537. }
  40538. declare module "babylonjs/PostProcesses/passPostProcess" {
  40539. import { Nullable } from "babylonjs/types";
  40540. import { Camera } from "babylonjs/Cameras/camera";
  40541. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40542. import { Engine } from "babylonjs/Engines/engine";
  40543. import "babylonjs/Shaders/pass.fragment";
  40544. import "babylonjs/Shaders/passCube.fragment";
  40545. /**
  40546. * PassPostProcess which produces an output the same as it's input
  40547. */
  40548. export class PassPostProcess extends PostProcess {
  40549. /**
  40550. * Creates the PassPostProcess
  40551. * @param name The name of the effect.
  40552. * @param options The required width/height ratio to downsize to before computing the render pass.
  40553. * @param camera The camera to apply the render pass to.
  40554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40555. * @param engine The engine which the post process will be applied. (default: current engine)
  40556. * @param reusable If the post process can be reused on the same frame. (default: false)
  40557. * @param textureType The type of texture to be used when performing the post processing.
  40558. * @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)
  40559. */
  40560. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40561. }
  40562. /**
  40563. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40564. */
  40565. export class PassCubePostProcess extends PostProcess {
  40566. private _face;
  40567. /**
  40568. * Gets or sets the cube face to display.
  40569. * * 0 is +X
  40570. * * 1 is -X
  40571. * * 2 is +Y
  40572. * * 3 is -Y
  40573. * * 4 is +Z
  40574. * * 5 is -Z
  40575. */
  40576. face: number;
  40577. /**
  40578. * Creates the PassCubePostProcess
  40579. * @param name The name of the effect.
  40580. * @param options The required width/height ratio to downsize to before computing the render pass.
  40581. * @param camera The camera to apply the render pass to.
  40582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40583. * @param engine The engine which the post process will be applied. (default: current engine)
  40584. * @param reusable If the post process can be reused on the same frame. (default: false)
  40585. * @param textureType The type of texture to be used when performing the post processing.
  40586. * @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)
  40587. */
  40588. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40589. }
  40590. }
  40591. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40592. /** @hidden */
  40593. export var anaglyphPixelShader: {
  40594. name: string;
  40595. shader: string;
  40596. };
  40597. }
  40598. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40599. import { Engine } from "babylonjs/Engines/engine";
  40600. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40601. import { Camera } from "babylonjs/Cameras/camera";
  40602. import "babylonjs/Shaders/anaglyph.fragment";
  40603. /**
  40604. * Postprocess used to generate anaglyphic rendering
  40605. */
  40606. export class AnaglyphPostProcess extends PostProcess {
  40607. private _passedProcess;
  40608. /**
  40609. * Creates a new AnaglyphPostProcess
  40610. * @param name defines postprocess name
  40611. * @param options defines creation options or target ratio scale
  40612. * @param rigCameras defines cameras using this postprocess
  40613. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40614. * @param engine defines hosting engine
  40615. * @param reusable defines if the postprocess will be reused multiple times per frame
  40616. */
  40617. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40618. }
  40619. }
  40620. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40621. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40622. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40623. import { Scene } from "babylonjs/scene";
  40624. import { Vector3 } from "babylonjs/Maths/math.vector";
  40625. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40626. /**
  40627. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40628. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40629. */
  40630. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40631. /**
  40632. * Creates a new AnaglyphArcRotateCamera
  40633. * @param name defines camera name
  40634. * @param alpha defines alpha angle (in radians)
  40635. * @param beta defines beta angle (in radians)
  40636. * @param radius defines radius
  40637. * @param target defines camera target
  40638. * @param interaxialDistance defines distance between each color axis
  40639. * @param scene defines the hosting scene
  40640. */
  40641. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40642. /**
  40643. * Gets camera class name
  40644. * @returns AnaglyphArcRotateCamera
  40645. */
  40646. getClassName(): string;
  40647. }
  40648. }
  40649. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40650. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40651. import { Scene } from "babylonjs/scene";
  40652. import { Vector3 } from "babylonjs/Maths/math.vector";
  40653. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40654. /**
  40655. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40656. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40657. */
  40658. export class AnaglyphFreeCamera extends FreeCamera {
  40659. /**
  40660. * Creates a new AnaglyphFreeCamera
  40661. * @param name defines camera name
  40662. * @param position defines initial position
  40663. * @param interaxialDistance defines distance between each color axis
  40664. * @param scene defines the hosting scene
  40665. */
  40666. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40667. /**
  40668. * Gets camera class name
  40669. * @returns AnaglyphFreeCamera
  40670. */
  40671. getClassName(): string;
  40672. }
  40673. }
  40674. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40675. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40676. import { Scene } from "babylonjs/scene";
  40677. import { Vector3 } from "babylonjs/Maths/math.vector";
  40678. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40679. /**
  40680. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40681. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40682. */
  40683. export class AnaglyphGamepadCamera extends GamepadCamera {
  40684. /**
  40685. * Creates a new AnaglyphGamepadCamera
  40686. * @param name defines camera name
  40687. * @param position defines initial position
  40688. * @param interaxialDistance defines distance between each color axis
  40689. * @param scene defines the hosting scene
  40690. */
  40691. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40692. /**
  40693. * Gets camera class name
  40694. * @returns AnaglyphGamepadCamera
  40695. */
  40696. getClassName(): string;
  40697. }
  40698. }
  40699. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40700. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40701. import { Scene } from "babylonjs/scene";
  40702. import { Vector3 } from "babylonjs/Maths/math.vector";
  40703. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40704. /**
  40705. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40706. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40707. */
  40708. export class AnaglyphUniversalCamera extends UniversalCamera {
  40709. /**
  40710. * Creates a new AnaglyphUniversalCamera
  40711. * @param name defines camera name
  40712. * @param position defines initial position
  40713. * @param interaxialDistance defines distance between each color axis
  40714. * @param scene defines the hosting scene
  40715. */
  40716. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40717. /**
  40718. * Gets camera class name
  40719. * @returns AnaglyphUniversalCamera
  40720. */
  40721. getClassName(): string;
  40722. }
  40723. }
  40724. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40725. /** @hidden */
  40726. export var stereoscopicInterlacePixelShader: {
  40727. name: string;
  40728. shader: string;
  40729. };
  40730. }
  40731. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40732. import { Camera } from "babylonjs/Cameras/camera";
  40733. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40734. import { Engine } from "babylonjs/Engines/engine";
  40735. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40736. /**
  40737. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40738. */
  40739. export class StereoscopicInterlacePostProcess extends PostProcess {
  40740. private _stepSize;
  40741. private _passedProcess;
  40742. /**
  40743. * Initializes a StereoscopicInterlacePostProcess
  40744. * @param name The name of the effect.
  40745. * @param rigCameras The rig cameras to be appled to the post process
  40746. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40747. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40748. * @param engine The engine which the post process will be applied. (default: current engine)
  40749. * @param reusable If the post process can be reused on the same frame. (default: false)
  40750. */
  40751. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40752. }
  40753. }
  40754. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40755. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40756. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40757. import { Scene } from "babylonjs/scene";
  40758. import { Vector3 } from "babylonjs/Maths/math.vector";
  40759. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40760. /**
  40761. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40762. * @see http://doc.babylonjs.com/features/cameras
  40763. */
  40764. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40765. /**
  40766. * Creates a new StereoscopicArcRotateCamera
  40767. * @param name defines camera name
  40768. * @param alpha defines alpha angle (in radians)
  40769. * @param beta defines beta angle (in radians)
  40770. * @param radius defines radius
  40771. * @param target defines camera target
  40772. * @param interaxialDistance defines distance between each color axis
  40773. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40774. * @param scene defines the hosting scene
  40775. */
  40776. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40777. /**
  40778. * Gets camera class name
  40779. * @returns StereoscopicArcRotateCamera
  40780. */
  40781. getClassName(): string;
  40782. }
  40783. }
  40784. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40785. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40786. import { Scene } from "babylonjs/scene";
  40787. import { Vector3 } from "babylonjs/Maths/math.vector";
  40788. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40789. /**
  40790. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40791. * @see http://doc.babylonjs.com/features/cameras
  40792. */
  40793. export class StereoscopicFreeCamera extends FreeCamera {
  40794. /**
  40795. * Creates a new StereoscopicFreeCamera
  40796. * @param name defines camera name
  40797. * @param position defines initial position
  40798. * @param interaxialDistance defines distance between each color axis
  40799. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40800. * @param scene defines the hosting scene
  40801. */
  40802. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40803. /**
  40804. * Gets camera class name
  40805. * @returns StereoscopicFreeCamera
  40806. */
  40807. getClassName(): string;
  40808. }
  40809. }
  40810. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40811. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40812. import { Scene } from "babylonjs/scene";
  40813. import { Vector3 } from "babylonjs/Maths/math.vector";
  40814. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40815. /**
  40816. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40817. * @see http://doc.babylonjs.com/features/cameras
  40818. */
  40819. export class StereoscopicGamepadCamera extends GamepadCamera {
  40820. /**
  40821. * Creates a new StereoscopicGamepadCamera
  40822. * @param name defines camera name
  40823. * @param position defines initial position
  40824. * @param interaxialDistance defines distance between each color axis
  40825. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40826. * @param scene defines the hosting scene
  40827. */
  40828. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40829. /**
  40830. * Gets camera class name
  40831. * @returns StereoscopicGamepadCamera
  40832. */
  40833. getClassName(): string;
  40834. }
  40835. }
  40836. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40837. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40838. import { Scene } from "babylonjs/scene";
  40839. import { Vector3 } from "babylonjs/Maths/math.vector";
  40840. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40841. /**
  40842. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40843. * @see http://doc.babylonjs.com/features/cameras
  40844. */
  40845. export class StereoscopicUniversalCamera extends UniversalCamera {
  40846. /**
  40847. * Creates a new StereoscopicUniversalCamera
  40848. * @param name defines camera name
  40849. * @param position defines initial position
  40850. * @param interaxialDistance defines distance between each color axis
  40851. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40852. * @param scene defines the hosting scene
  40853. */
  40854. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40855. /**
  40856. * Gets camera class name
  40857. * @returns StereoscopicUniversalCamera
  40858. */
  40859. getClassName(): string;
  40860. }
  40861. }
  40862. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40863. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40864. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40865. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40866. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40867. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40868. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40869. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40870. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40871. }
  40872. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40873. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40874. import { Scene } from "babylonjs/scene";
  40875. import { Vector3 } from "babylonjs/Maths/math.vector";
  40876. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40877. /**
  40878. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40879. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40880. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40881. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40882. */
  40883. export class VirtualJoysticksCamera extends FreeCamera {
  40884. /**
  40885. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40886. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40887. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40888. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40889. * @param name Define the name of the camera in the scene
  40890. * @param position Define the start position of the camera in the scene
  40891. * @param scene Define the scene the camera belongs to
  40892. */
  40893. constructor(name: string, position: Vector3, scene: Scene);
  40894. /**
  40895. * Gets the current object class name.
  40896. * @return the class name
  40897. */
  40898. getClassName(): string;
  40899. }
  40900. }
  40901. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40902. import { Matrix } from "babylonjs/Maths/math.vector";
  40903. /**
  40904. * This represents all the required metrics to create a VR camera.
  40905. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40906. */
  40907. export class VRCameraMetrics {
  40908. /**
  40909. * Define the horizontal resolution off the screen.
  40910. */
  40911. hResolution: number;
  40912. /**
  40913. * Define the vertical resolution off the screen.
  40914. */
  40915. vResolution: number;
  40916. /**
  40917. * Define the horizontal screen size.
  40918. */
  40919. hScreenSize: number;
  40920. /**
  40921. * Define the vertical screen size.
  40922. */
  40923. vScreenSize: number;
  40924. /**
  40925. * Define the vertical screen center position.
  40926. */
  40927. vScreenCenter: number;
  40928. /**
  40929. * Define the distance of the eyes to the screen.
  40930. */
  40931. eyeToScreenDistance: number;
  40932. /**
  40933. * Define the distance between both lenses
  40934. */
  40935. lensSeparationDistance: number;
  40936. /**
  40937. * Define the distance between both viewer's eyes.
  40938. */
  40939. interpupillaryDistance: number;
  40940. /**
  40941. * Define the distortion factor of the VR postprocess.
  40942. * Please, touch with care.
  40943. */
  40944. distortionK: number[];
  40945. /**
  40946. * Define the chromatic aberration correction factors for the VR post process.
  40947. */
  40948. chromaAbCorrection: number[];
  40949. /**
  40950. * Define the scale factor of the post process.
  40951. * The smaller the better but the slower.
  40952. */
  40953. postProcessScaleFactor: number;
  40954. /**
  40955. * Define an offset for the lens center.
  40956. */
  40957. lensCenterOffset: number;
  40958. /**
  40959. * Define if the current vr camera should compensate the distortion of the lense or not.
  40960. */
  40961. compensateDistortion: boolean;
  40962. /**
  40963. * Defines if multiview should be enabled when rendering (Default: false)
  40964. */
  40965. multiviewEnabled: boolean;
  40966. /**
  40967. * Gets the rendering aspect ratio based on the provided resolutions.
  40968. */
  40969. readonly aspectRatio: number;
  40970. /**
  40971. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40972. */
  40973. readonly aspectRatioFov: number;
  40974. /**
  40975. * @hidden
  40976. */
  40977. readonly leftHMatrix: Matrix;
  40978. /**
  40979. * @hidden
  40980. */
  40981. readonly rightHMatrix: Matrix;
  40982. /**
  40983. * @hidden
  40984. */
  40985. readonly leftPreViewMatrix: Matrix;
  40986. /**
  40987. * @hidden
  40988. */
  40989. readonly rightPreViewMatrix: Matrix;
  40990. /**
  40991. * Get the default VRMetrics based on the most generic setup.
  40992. * @returns the default vr metrics
  40993. */
  40994. static GetDefault(): VRCameraMetrics;
  40995. }
  40996. }
  40997. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40998. /** @hidden */
  40999. export var vrDistortionCorrectionPixelShader: {
  41000. name: string;
  41001. shader: string;
  41002. };
  41003. }
  41004. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41005. import { Camera } from "babylonjs/Cameras/camera";
  41006. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41007. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41008. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41009. /**
  41010. * VRDistortionCorrectionPostProcess used for mobile VR
  41011. */
  41012. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41013. private _isRightEye;
  41014. private _distortionFactors;
  41015. private _postProcessScaleFactor;
  41016. private _lensCenterOffset;
  41017. private _scaleIn;
  41018. private _scaleFactor;
  41019. private _lensCenter;
  41020. /**
  41021. * Initializes the VRDistortionCorrectionPostProcess
  41022. * @param name The name of the effect.
  41023. * @param camera The camera to apply the render pass to.
  41024. * @param isRightEye If this is for the right eye distortion
  41025. * @param vrMetrics All the required metrics for the VR camera
  41026. */
  41027. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41028. }
  41029. }
  41030. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41031. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41032. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41033. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41034. import { Scene } from "babylonjs/scene";
  41035. import { Vector3 } from "babylonjs/Maths/math.vector";
  41036. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41037. import "babylonjs/Cameras/RigModes/vrRigMode";
  41038. /**
  41039. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41040. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41041. */
  41042. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41043. /**
  41044. * Creates a new VRDeviceOrientationArcRotateCamera
  41045. * @param name defines camera name
  41046. * @param alpha defines the camera rotation along the logitudinal axis
  41047. * @param beta defines the camera rotation along the latitudinal axis
  41048. * @param radius defines the camera distance from its target
  41049. * @param target defines the camera target
  41050. * @param scene defines the scene the camera belongs to
  41051. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41052. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41053. */
  41054. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41055. /**
  41056. * Gets camera class name
  41057. * @returns VRDeviceOrientationArcRotateCamera
  41058. */
  41059. getClassName(): string;
  41060. }
  41061. }
  41062. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41063. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41064. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41065. import { Scene } from "babylonjs/scene";
  41066. import { Vector3 } from "babylonjs/Maths/math.vector";
  41067. import "babylonjs/Cameras/RigModes/vrRigMode";
  41068. /**
  41069. * Camera used to simulate VR rendering (based on FreeCamera)
  41070. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41071. */
  41072. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41073. /**
  41074. * Creates a new VRDeviceOrientationFreeCamera
  41075. * @param name defines camera name
  41076. * @param position defines the start position of the camera
  41077. * @param scene defines the scene the camera belongs to
  41078. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41079. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41080. */
  41081. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41082. /**
  41083. * Gets camera class name
  41084. * @returns VRDeviceOrientationFreeCamera
  41085. */
  41086. getClassName(): string;
  41087. }
  41088. }
  41089. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41090. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41091. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41092. import { Scene } from "babylonjs/scene";
  41093. import { Vector3 } from "babylonjs/Maths/math.vector";
  41094. import "babylonjs/Gamepads/gamepadSceneComponent";
  41095. /**
  41096. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41097. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41098. */
  41099. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41100. /**
  41101. * Creates a new VRDeviceOrientationGamepadCamera
  41102. * @param name defines camera name
  41103. * @param position defines the start position of the camera
  41104. * @param scene defines the scene the camera belongs to
  41105. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41106. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41107. */
  41108. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41109. /**
  41110. * Gets camera class name
  41111. * @returns VRDeviceOrientationGamepadCamera
  41112. */
  41113. getClassName(): string;
  41114. }
  41115. }
  41116. declare module "babylonjs/Materials/pushMaterial" {
  41117. import { Nullable } from "babylonjs/types";
  41118. import { Scene } from "babylonjs/scene";
  41119. import { Matrix } from "babylonjs/Maths/math.vector";
  41120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41121. import { Mesh } from "babylonjs/Meshes/mesh";
  41122. import { Material } from "babylonjs/Materials/material";
  41123. import { Effect } from "babylonjs/Materials/effect";
  41124. /**
  41125. * Base class of materials working in push mode in babylon JS
  41126. * @hidden
  41127. */
  41128. export class PushMaterial extends Material {
  41129. protected _activeEffect: Effect;
  41130. protected _normalMatrix: Matrix;
  41131. /**
  41132. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41133. * This means that the material can keep using a previous shader while a new one is being compiled.
  41134. * This is mostly used when shader parallel compilation is supported (true by default)
  41135. */
  41136. allowShaderHotSwapping: boolean;
  41137. constructor(name: string, scene: Scene);
  41138. getEffect(): Effect;
  41139. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41140. /**
  41141. * Binds the given world matrix to the active effect
  41142. *
  41143. * @param world the matrix to bind
  41144. */
  41145. bindOnlyWorldMatrix(world: Matrix): void;
  41146. /**
  41147. * Binds the given normal matrix to the active effect
  41148. *
  41149. * @param normalMatrix the matrix to bind
  41150. */
  41151. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41152. bind(world: Matrix, mesh?: Mesh): void;
  41153. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41154. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41155. }
  41156. }
  41157. declare module "babylonjs/Materials/materialFlags" {
  41158. /**
  41159. * This groups all the flags used to control the materials channel.
  41160. */
  41161. export class MaterialFlags {
  41162. private static _DiffuseTextureEnabled;
  41163. /**
  41164. * Are diffuse textures enabled in the application.
  41165. */
  41166. static DiffuseTextureEnabled: boolean;
  41167. private static _AmbientTextureEnabled;
  41168. /**
  41169. * Are ambient textures enabled in the application.
  41170. */
  41171. static AmbientTextureEnabled: boolean;
  41172. private static _OpacityTextureEnabled;
  41173. /**
  41174. * Are opacity textures enabled in the application.
  41175. */
  41176. static OpacityTextureEnabled: boolean;
  41177. private static _ReflectionTextureEnabled;
  41178. /**
  41179. * Are reflection textures enabled in the application.
  41180. */
  41181. static ReflectionTextureEnabled: boolean;
  41182. private static _EmissiveTextureEnabled;
  41183. /**
  41184. * Are emissive textures enabled in the application.
  41185. */
  41186. static EmissiveTextureEnabled: boolean;
  41187. private static _SpecularTextureEnabled;
  41188. /**
  41189. * Are specular textures enabled in the application.
  41190. */
  41191. static SpecularTextureEnabled: boolean;
  41192. private static _BumpTextureEnabled;
  41193. /**
  41194. * Are bump textures enabled in the application.
  41195. */
  41196. static BumpTextureEnabled: boolean;
  41197. private static _LightmapTextureEnabled;
  41198. /**
  41199. * Are lightmap textures enabled in the application.
  41200. */
  41201. static LightmapTextureEnabled: boolean;
  41202. private static _RefractionTextureEnabled;
  41203. /**
  41204. * Are refraction textures enabled in the application.
  41205. */
  41206. static RefractionTextureEnabled: boolean;
  41207. private static _ColorGradingTextureEnabled;
  41208. /**
  41209. * Are color grading textures enabled in the application.
  41210. */
  41211. static ColorGradingTextureEnabled: boolean;
  41212. private static _FresnelEnabled;
  41213. /**
  41214. * Are fresnels enabled in the application.
  41215. */
  41216. static FresnelEnabled: boolean;
  41217. private static _ClearCoatTextureEnabled;
  41218. /**
  41219. * Are clear coat textures enabled in the application.
  41220. */
  41221. static ClearCoatTextureEnabled: boolean;
  41222. private static _ClearCoatBumpTextureEnabled;
  41223. /**
  41224. * Are clear coat bump textures enabled in the application.
  41225. */
  41226. static ClearCoatBumpTextureEnabled: boolean;
  41227. private static _ClearCoatTintTextureEnabled;
  41228. /**
  41229. * Are clear coat tint textures enabled in the application.
  41230. */
  41231. static ClearCoatTintTextureEnabled: boolean;
  41232. private static _SheenTextureEnabled;
  41233. /**
  41234. * Are sheen textures enabled in the application.
  41235. */
  41236. static SheenTextureEnabled: boolean;
  41237. private static _AnisotropicTextureEnabled;
  41238. /**
  41239. * Are anisotropic textures enabled in the application.
  41240. */
  41241. static AnisotropicTextureEnabled: boolean;
  41242. private static _ThicknessTextureEnabled;
  41243. /**
  41244. * Are thickness textures enabled in the application.
  41245. */
  41246. static ThicknessTextureEnabled: boolean;
  41247. }
  41248. }
  41249. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41250. /** @hidden */
  41251. export var defaultFragmentDeclaration: {
  41252. name: string;
  41253. shader: string;
  41254. };
  41255. }
  41256. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41257. /** @hidden */
  41258. export var defaultUboDeclaration: {
  41259. name: string;
  41260. shader: string;
  41261. };
  41262. }
  41263. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41264. /** @hidden */
  41265. export var lightFragmentDeclaration: {
  41266. name: string;
  41267. shader: string;
  41268. };
  41269. }
  41270. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41271. /** @hidden */
  41272. export var lightUboDeclaration: {
  41273. name: string;
  41274. shader: string;
  41275. };
  41276. }
  41277. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41278. /** @hidden */
  41279. export var lightsFragmentFunctions: {
  41280. name: string;
  41281. shader: string;
  41282. };
  41283. }
  41284. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41285. /** @hidden */
  41286. export var shadowsFragmentFunctions: {
  41287. name: string;
  41288. shader: string;
  41289. };
  41290. }
  41291. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41292. /** @hidden */
  41293. export var fresnelFunction: {
  41294. name: string;
  41295. shader: string;
  41296. };
  41297. }
  41298. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41299. /** @hidden */
  41300. export var reflectionFunction: {
  41301. name: string;
  41302. shader: string;
  41303. };
  41304. }
  41305. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41306. /** @hidden */
  41307. export var bumpFragmentFunctions: {
  41308. name: string;
  41309. shader: string;
  41310. };
  41311. }
  41312. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41313. /** @hidden */
  41314. export var logDepthDeclaration: {
  41315. name: string;
  41316. shader: string;
  41317. };
  41318. }
  41319. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41320. /** @hidden */
  41321. export var bumpFragment: {
  41322. name: string;
  41323. shader: string;
  41324. };
  41325. }
  41326. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41327. /** @hidden */
  41328. export var depthPrePass: {
  41329. name: string;
  41330. shader: string;
  41331. };
  41332. }
  41333. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41334. /** @hidden */
  41335. export var lightFragment: {
  41336. name: string;
  41337. shader: string;
  41338. };
  41339. }
  41340. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41341. /** @hidden */
  41342. export var logDepthFragment: {
  41343. name: string;
  41344. shader: string;
  41345. };
  41346. }
  41347. declare module "babylonjs/Shaders/default.fragment" {
  41348. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41349. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41350. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41351. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41352. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41353. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41354. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41355. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41356. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41357. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41358. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41359. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41360. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41361. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41362. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41363. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41364. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41365. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41366. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41367. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41368. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41369. /** @hidden */
  41370. export var defaultPixelShader: {
  41371. name: string;
  41372. shader: string;
  41373. };
  41374. }
  41375. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41376. /** @hidden */
  41377. export var defaultVertexDeclaration: {
  41378. name: string;
  41379. shader: string;
  41380. };
  41381. }
  41382. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41383. /** @hidden */
  41384. export var bumpVertexDeclaration: {
  41385. name: string;
  41386. shader: string;
  41387. };
  41388. }
  41389. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41390. /** @hidden */
  41391. export var bumpVertex: {
  41392. name: string;
  41393. shader: string;
  41394. };
  41395. }
  41396. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41397. /** @hidden */
  41398. export var fogVertex: {
  41399. name: string;
  41400. shader: string;
  41401. };
  41402. }
  41403. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41404. /** @hidden */
  41405. export var shadowsVertex: {
  41406. name: string;
  41407. shader: string;
  41408. };
  41409. }
  41410. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41411. /** @hidden */
  41412. export var pointCloudVertex: {
  41413. name: string;
  41414. shader: string;
  41415. };
  41416. }
  41417. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41418. /** @hidden */
  41419. export var logDepthVertex: {
  41420. name: string;
  41421. shader: string;
  41422. };
  41423. }
  41424. declare module "babylonjs/Shaders/default.vertex" {
  41425. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41426. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41427. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41428. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41429. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41430. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41431. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41432. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41433. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41434. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41435. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41436. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41437. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41438. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41439. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41440. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41441. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41442. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41443. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41444. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41445. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41446. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41447. /** @hidden */
  41448. export var defaultVertexShader: {
  41449. name: string;
  41450. shader: string;
  41451. };
  41452. }
  41453. declare module "babylonjs/Materials/standardMaterial" {
  41454. import { SmartArray } from "babylonjs/Misc/smartArray";
  41455. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41456. import { Nullable } from "babylonjs/types";
  41457. import { Scene } from "babylonjs/scene";
  41458. import { Matrix } from "babylonjs/Maths/math.vector";
  41459. import { Color3 } from "babylonjs/Maths/math.color";
  41460. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41462. import { Mesh } from "babylonjs/Meshes/mesh";
  41463. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41464. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41465. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41466. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41467. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41468. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41469. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41470. import "babylonjs/Shaders/default.fragment";
  41471. import "babylonjs/Shaders/default.vertex";
  41472. /** @hidden */
  41473. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41474. MAINUV1: boolean;
  41475. MAINUV2: boolean;
  41476. DIFFUSE: boolean;
  41477. DIFFUSEDIRECTUV: number;
  41478. AMBIENT: boolean;
  41479. AMBIENTDIRECTUV: number;
  41480. OPACITY: boolean;
  41481. OPACITYDIRECTUV: number;
  41482. OPACITYRGB: boolean;
  41483. REFLECTION: boolean;
  41484. EMISSIVE: boolean;
  41485. EMISSIVEDIRECTUV: number;
  41486. SPECULAR: boolean;
  41487. SPECULARDIRECTUV: number;
  41488. BUMP: boolean;
  41489. BUMPDIRECTUV: number;
  41490. PARALLAX: boolean;
  41491. PARALLAXOCCLUSION: boolean;
  41492. SPECULAROVERALPHA: boolean;
  41493. CLIPPLANE: boolean;
  41494. CLIPPLANE2: boolean;
  41495. CLIPPLANE3: boolean;
  41496. CLIPPLANE4: boolean;
  41497. ALPHATEST: boolean;
  41498. DEPTHPREPASS: boolean;
  41499. ALPHAFROMDIFFUSE: boolean;
  41500. POINTSIZE: boolean;
  41501. FOG: boolean;
  41502. SPECULARTERM: boolean;
  41503. DIFFUSEFRESNEL: boolean;
  41504. OPACITYFRESNEL: boolean;
  41505. REFLECTIONFRESNEL: boolean;
  41506. REFRACTIONFRESNEL: boolean;
  41507. EMISSIVEFRESNEL: boolean;
  41508. FRESNEL: boolean;
  41509. NORMAL: boolean;
  41510. UV1: boolean;
  41511. UV2: boolean;
  41512. VERTEXCOLOR: boolean;
  41513. VERTEXALPHA: boolean;
  41514. NUM_BONE_INFLUENCERS: number;
  41515. BonesPerMesh: number;
  41516. BONETEXTURE: boolean;
  41517. INSTANCES: boolean;
  41518. GLOSSINESS: boolean;
  41519. ROUGHNESS: boolean;
  41520. EMISSIVEASILLUMINATION: boolean;
  41521. LINKEMISSIVEWITHDIFFUSE: boolean;
  41522. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41523. LIGHTMAP: boolean;
  41524. LIGHTMAPDIRECTUV: number;
  41525. OBJECTSPACE_NORMALMAP: boolean;
  41526. USELIGHTMAPASSHADOWMAP: boolean;
  41527. REFLECTIONMAP_3D: boolean;
  41528. REFLECTIONMAP_SPHERICAL: boolean;
  41529. REFLECTIONMAP_PLANAR: boolean;
  41530. REFLECTIONMAP_CUBIC: boolean;
  41531. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41532. REFLECTIONMAP_PROJECTION: boolean;
  41533. REFLECTIONMAP_SKYBOX: boolean;
  41534. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41535. REFLECTIONMAP_EXPLICIT: boolean;
  41536. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41537. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41538. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41539. INVERTCUBICMAP: boolean;
  41540. LOGARITHMICDEPTH: boolean;
  41541. REFRACTION: boolean;
  41542. REFRACTIONMAP_3D: boolean;
  41543. REFLECTIONOVERALPHA: boolean;
  41544. TWOSIDEDLIGHTING: boolean;
  41545. SHADOWFLOAT: boolean;
  41546. MORPHTARGETS: boolean;
  41547. MORPHTARGETS_NORMAL: boolean;
  41548. MORPHTARGETS_TANGENT: boolean;
  41549. MORPHTARGETS_UV: boolean;
  41550. NUM_MORPH_INFLUENCERS: number;
  41551. NONUNIFORMSCALING: boolean;
  41552. PREMULTIPLYALPHA: boolean;
  41553. IMAGEPROCESSING: boolean;
  41554. VIGNETTE: boolean;
  41555. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41556. VIGNETTEBLENDMODEOPAQUE: boolean;
  41557. TONEMAPPING: boolean;
  41558. TONEMAPPING_ACES: boolean;
  41559. CONTRAST: boolean;
  41560. COLORCURVES: boolean;
  41561. COLORGRADING: boolean;
  41562. COLORGRADING3D: boolean;
  41563. SAMPLER3DGREENDEPTH: boolean;
  41564. SAMPLER3DBGRMAP: boolean;
  41565. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41566. MULTIVIEW: boolean;
  41567. /**
  41568. * If the reflection texture on this material is in linear color space
  41569. * @hidden
  41570. */
  41571. IS_REFLECTION_LINEAR: boolean;
  41572. /**
  41573. * If the refraction texture on this material is in linear color space
  41574. * @hidden
  41575. */
  41576. IS_REFRACTION_LINEAR: boolean;
  41577. EXPOSURE: boolean;
  41578. constructor();
  41579. setReflectionMode(modeToEnable: string): void;
  41580. }
  41581. /**
  41582. * This is the default material used in Babylon. It is the best trade off between quality
  41583. * and performances.
  41584. * @see http://doc.babylonjs.com/babylon101/materials
  41585. */
  41586. export class StandardMaterial extends PushMaterial {
  41587. private _diffuseTexture;
  41588. /**
  41589. * The basic texture of the material as viewed under a light.
  41590. */
  41591. diffuseTexture: Nullable<BaseTexture>;
  41592. private _ambientTexture;
  41593. /**
  41594. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41595. */
  41596. ambientTexture: Nullable<BaseTexture>;
  41597. private _opacityTexture;
  41598. /**
  41599. * Define the transparency of the material from a texture.
  41600. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41601. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41602. */
  41603. opacityTexture: Nullable<BaseTexture>;
  41604. private _reflectionTexture;
  41605. /**
  41606. * Define the texture used to display the reflection.
  41607. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41608. */
  41609. reflectionTexture: Nullable<BaseTexture>;
  41610. private _emissiveTexture;
  41611. /**
  41612. * Define texture of the material as if self lit.
  41613. * This will be mixed in the final result even in the absence of light.
  41614. */
  41615. emissiveTexture: Nullable<BaseTexture>;
  41616. private _specularTexture;
  41617. /**
  41618. * Define how the color and intensity of the highlight given by the light in the material.
  41619. */
  41620. specularTexture: Nullable<BaseTexture>;
  41621. private _bumpTexture;
  41622. /**
  41623. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41624. * 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.
  41625. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41626. */
  41627. bumpTexture: Nullable<BaseTexture>;
  41628. private _lightmapTexture;
  41629. /**
  41630. * Complex lighting can be computationally expensive to compute at runtime.
  41631. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41632. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41633. */
  41634. lightmapTexture: Nullable<BaseTexture>;
  41635. private _refractionTexture;
  41636. /**
  41637. * Define the texture used to display the refraction.
  41638. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41639. */
  41640. refractionTexture: Nullable<BaseTexture>;
  41641. /**
  41642. * The color of the material lit by the environmental background lighting.
  41643. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41644. */
  41645. ambientColor: Color3;
  41646. /**
  41647. * The basic color of the material as viewed under a light.
  41648. */
  41649. diffuseColor: Color3;
  41650. /**
  41651. * Define how the color and intensity of the highlight given by the light in the material.
  41652. */
  41653. specularColor: Color3;
  41654. /**
  41655. * Define the color of the material as if self lit.
  41656. * This will be mixed in the final result even in the absence of light.
  41657. */
  41658. emissiveColor: Color3;
  41659. /**
  41660. * Defines how sharp are the highlights in the material.
  41661. * The bigger the value the sharper giving a more glossy feeling to the result.
  41662. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41663. */
  41664. specularPower: number;
  41665. private _useAlphaFromDiffuseTexture;
  41666. /**
  41667. * Does the transparency come from the diffuse texture alpha channel.
  41668. */
  41669. useAlphaFromDiffuseTexture: boolean;
  41670. private _useEmissiveAsIllumination;
  41671. /**
  41672. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41673. */
  41674. useEmissiveAsIllumination: boolean;
  41675. private _linkEmissiveWithDiffuse;
  41676. /**
  41677. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41678. * the emissive level when the final color is close to one.
  41679. */
  41680. linkEmissiveWithDiffuse: boolean;
  41681. private _useSpecularOverAlpha;
  41682. /**
  41683. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41684. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41685. */
  41686. useSpecularOverAlpha: boolean;
  41687. private _useReflectionOverAlpha;
  41688. /**
  41689. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41690. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41691. */
  41692. useReflectionOverAlpha: boolean;
  41693. private _disableLighting;
  41694. /**
  41695. * Does lights from the scene impacts this material.
  41696. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41697. */
  41698. disableLighting: boolean;
  41699. private _useObjectSpaceNormalMap;
  41700. /**
  41701. * Allows using an object space normal map (instead of tangent space).
  41702. */
  41703. useObjectSpaceNormalMap: boolean;
  41704. private _useParallax;
  41705. /**
  41706. * Is parallax enabled or not.
  41707. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41708. */
  41709. useParallax: boolean;
  41710. private _useParallaxOcclusion;
  41711. /**
  41712. * Is parallax occlusion enabled or not.
  41713. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41714. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41715. */
  41716. useParallaxOcclusion: boolean;
  41717. /**
  41718. * 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.
  41719. */
  41720. parallaxScaleBias: number;
  41721. private _roughness;
  41722. /**
  41723. * Helps to define how blurry the reflections should appears in the material.
  41724. */
  41725. roughness: number;
  41726. /**
  41727. * In case of refraction, define the value of the index of refraction.
  41728. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41729. */
  41730. indexOfRefraction: number;
  41731. /**
  41732. * Invert the refraction texture alongside the y axis.
  41733. * It can be useful with procedural textures or probe for instance.
  41734. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41735. */
  41736. invertRefractionY: boolean;
  41737. /**
  41738. * Defines the alpha limits in alpha test mode.
  41739. */
  41740. alphaCutOff: number;
  41741. private _useLightmapAsShadowmap;
  41742. /**
  41743. * In case of light mapping, define whether the map contains light or shadow informations.
  41744. */
  41745. useLightmapAsShadowmap: boolean;
  41746. private _diffuseFresnelParameters;
  41747. /**
  41748. * Define the diffuse fresnel parameters of the material.
  41749. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41750. */
  41751. diffuseFresnelParameters: FresnelParameters;
  41752. private _opacityFresnelParameters;
  41753. /**
  41754. * Define the opacity fresnel parameters of the material.
  41755. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41756. */
  41757. opacityFresnelParameters: FresnelParameters;
  41758. private _reflectionFresnelParameters;
  41759. /**
  41760. * Define the reflection fresnel parameters of the material.
  41761. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41762. */
  41763. reflectionFresnelParameters: FresnelParameters;
  41764. private _refractionFresnelParameters;
  41765. /**
  41766. * Define the refraction fresnel parameters of the material.
  41767. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41768. */
  41769. refractionFresnelParameters: FresnelParameters;
  41770. private _emissiveFresnelParameters;
  41771. /**
  41772. * Define the emissive fresnel parameters of the material.
  41773. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41774. */
  41775. emissiveFresnelParameters: FresnelParameters;
  41776. private _useReflectionFresnelFromSpecular;
  41777. /**
  41778. * If true automatically deducts the fresnels values from the material specularity.
  41779. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41780. */
  41781. useReflectionFresnelFromSpecular: boolean;
  41782. private _useGlossinessFromSpecularMapAlpha;
  41783. /**
  41784. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41785. */
  41786. useGlossinessFromSpecularMapAlpha: boolean;
  41787. private _maxSimultaneousLights;
  41788. /**
  41789. * Defines the maximum number of lights that can be used in the material
  41790. */
  41791. maxSimultaneousLights: number;
  41792. private _invertNormalMapX;
  41793. /**
  41794. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41795. */
  41796. invertNormalMapX: boolean;
  41797. private _invertNormalMapY;
  41798. /**
  41799. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41800. */
  41801. invertNormalMapY: boolean;
  41802. private _twoSidedLighting;
  41803. /**
  41804. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41805. */
  41806. twoSidedLighting: boolean;
  41807. /**
  41808. * Default configuration related to image processing available in the standard Material.
  41809. */
  41810. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41811. /**
  41812. * Gets the image processing configuration used either in this material.
  41813. */
  41814. /**
  41815. * Sets the Default image processing configuration used either in the this material.
  41816. *
  41817. * If sets to null, the scene one is in use.
  41818. */
  41819. imageProcessingConfiguration: ImageProcessingConfiguration;
  41820. /**
  41821. * Keep track of the image processing observer to allow dispose and replace.
  41822. */
  41823. private _imageProcessingObserver;
  41824. /**
  41825. * Attaches a new image processing configuration to the Standard Material.
  41826. * @param configuration
  41827. */
  41828. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41829. /**
  41830. * Gets wether the color curves effect is enabled.
  41831. */
  41832. /**
  41833. * Sets wether the color curves effect is enabled.
  41834. */
  41835. cameraColorCurvesEnabled: boolean;
  41836. /**
  41837. * Gets wether the color grading effect is enabled.
  41838. */
  41839. /**
  41840. * Gets wether the color grading effect is enabled.
  41841. */
  41842. cameraColorGradingEnabled: boolean;
  41843. /**
  41844. * Gets wether tonemapping is enabled or not.
  41845. */
  41846. /**
  41847. * Sets wether tonemapping is enabled or not
  41848. */
  41849. cameraToneMappingEnabled: boolean;
  41850. /**
  41851. * The camera exposure used on this material.
  41852. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41853. * This corresponds to a photographic exposure.
  41854. */
  41855. /**
  41856. * The camera exposure used on this material.
  41857. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41858. * This corresponds to a photographic exposure.
  41859. */
  41860. cameraExposure: number;
  41861. /**
  41862. * Gets The camera contrast used on this material.
  41863. */
  41864. /**
  41865. * Sets The camera contrast used on this material.
  41866. */
  41867. cameraContrast: number;
  41868. /**
  41869. * Gets the Color Grading 2D Lookup Texture.
  41870. */
  41871. /**
  41872. * Sets the Color Grading 2D Lookup Texture.
  41873. */
  41874. cameraColorGradingTexture: Nullable<BaseTexture>;
  41875. /**
  41876. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41877. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41878. * 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;
  41879. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41880. */
  41881. /**
  41882. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41883. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41884. * 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;
  41885. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41886. */
  41887. cameraColorCurves: Nullable<ColorCurves>;
  41888. /**
  41889. * Custom callback helping to override the default shader used in the material.
  41890. */
  41891. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41892. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41893. protected _worldViewProjectionMatrix: Matrix;
  41894. protected _globalAmbientColor: Color3;
  41895. protected _useLogarithmicDepth: boolean;
  41896. protected _rebuildInParallel: boolean;
  41897. /**
  41898. * Instantiates a new standard material.
  41899. * This is the default material used in Babylon. It is the best trade off between quality
  41900. * and performances.
  41901. * @see http://doc.babylonjs.com/babylon101/materials
  41902. * @param name Define the name of the material in the scene
  41903. * @param scene Define the scene the material belong to
  41904. */
  41905. constructor(name: string, scene: Scene);
  41906. /**
  41907. * Gets a boolean indicating that current material needs to register RTT
  41908. */
  41909. readonly hasRenderTargetTextures: boolean;
  41910. /**
  41911. * Gets the current class name of the material e.g. "StandardMaterial"
  41912. * Mainly use in serialization.
  41913. * @returns the class name
  41914. */
  41915. getClassName(): string;
  41916. /**
  41917. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41918. * You can try switching to logarithmic depth.
  41919. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41920. */
  41921. useLogarithmicDepth: boolean;
  41922. /**
  41923. * Specifies if the material will require alpha blending
  41924. * @returns a boolean specifying if alpha blending is needed
  41925. */
  41926. needAlphaBlending(): boolean;
  41927. /**
  41928. * Specifies if this material should be rendered in alpha test mode
  41929. * @returns a boolean specifying if an alpha test is needed.
  41930. */
  41931. needAlphaTesting(): boolean;
  41932. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41933. /**
  41934. * Get the texture used for alpha test purpose.
  41935. * @returns the diffuse texture in case of the standard material.
  41936. */
  41937. getAlphaTestTexture(): Nullable<BaseTexture>;
  41938. /**
  41939. * Get if the submesh is ready to be used and all its information available.
  41940. * Child classes can use it to update shaders
  41941. * @param mesh defines the mesh to check
  41942. * @param subMesh defines which submesh to check
  41943. * @param useInstances specifies that instances should be used
  41944. * @returns a boolean indicating that the submesh is ready or not
  41945. */
  41946. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41947. /**
  41948. * Builds the material UBO layouts.
  41949. * Used internally during the effect preparation.
  41950. */
  41951. buildUniformLayout(): void;
  41952. /**
  41953. * Unbinds the material from the mesh
  41954. */
  41955. unbind(): void;
  41956. /**
  41957. * Binds the submesh to this material by preparing the effect and shader to draw
  41958. * @param world defines the world transformation matrix
  41959. * @param mesh defines the mesh containing the submesh
  41960. * @param subMesh defines the submesh to bind the material to
  41961. */
  41962. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41963. /**
  41964. * Get the list of animatables in the material.
  41965. * @returns the list of animatables object used in the material
  41966. */
  41967. getAnimatables(): IAnimatable[];
  41968. /**
  41969. * Gets the active textures from the material
  41970. * @returns an array of textures
  41971. */
  41972. getActiveTextures(): BaseTexture[];
  41973. /**
  41974. * Specifies if the material uses a texture
  41975. * @param texture defines the texture to check against the material
  41976. * @returns a boolean specifying if the material uses the texture
  41977. */
  41978. hasTexture(texture: BaseTexture): boolean;
  41979. /**
  41980. * Disposes the material
  41981. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41982. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41983. */
  41984. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41985. /**
  41986. * Makes a duplicate of the material, and gives it a new name
  41987. * @param name defines the new name for the duplicated material
  41988. * @returns the cloned material
  41989. */
  41990. clone(name: string): StandardMaterial;
  41991. /**
  41992. * Serializes this material in a JSON representation
  41993. * @returns the serialized material object
  41994. */
  41995. serialize(): any;
  41996. /**
  41997. * Creates a standard material from parsed material data
  41998. * @param source defines the JSON representation of the material
  41999. * @param scene defines the hosting scene
  42000. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42001. * @returns a new standard material
  42002. */
  42003. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42004. /**
  42005. * Are diffuse textures enabled in the application.
  42006. */
  42007. static DiffuseTextureEnabled: boolean;
  42008. /**
  42009. * Are ambient textures enabled in the application.
  42010. */
  42011. static AmbientTextureEnabled: boolean;
  42012. /**
  42013. * Are opacity textures enabled in the application.
  42014. */
  42015. static OpacityTextureEnabled: boolean;
  42016. /**
  42017. * Are reflection textures enabled in the application.
  42018. */
  42019. static ReflectionTextureEnabled: boolean;
  42020. /**
  42021. * Are emissive textures enabled in the application.
  42022. */
  42023. static EmissiveTextureEnabled: boolean;
  42024. /**
  42025. * Are specular textures enabled in the application.
  42026. */
  42027. static SpecularTextureEnabled: boolean;
  42028. /**
  42029. * Are bump textures enabled in the application.
  42030. */
  42031. static BumpTextureEnabled: boolean;
  42032. /**
  42033. * Are lightmap textures enabled in the application.
  42034. */
  42035. static LightmapTextureEnabled: boolean;
  42036. /**
  42037. * Are refraction textures enabled in the application.
  42038. */
  42039. static RefractionTextureEnabled: boolean;
  42040. /**
  42041. * Are color grading textures enabled in the application.
  42042. */
  42043. static ColorGradingTextureEnabled: boolean;
  42044. /**
  42045. * Are fresnels enabled in the application.
  42046. */
  42047. static FresnelEnabled: boolean;
  42048. }
  42049. }
  42050. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42051. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42052. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42053. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42054. /** @hidden */
  42055. export var imageProcessingPixelShader: {
  42056. name: string;
  42057. shader: string;
  42058. };
  42059. }
  42060. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42061. import { Nullable } from "babylonjs/types";
  42062. import { Color4 } from "babylonjs/Maths/math.color";
  42063. import { Camera } from "babylonjs/Cameras/camera";
  42064. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42065. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42066. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42067. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42068. import { Engine } from "babylonjs/Engines/engine";
  42069. import "babylonjs/Shaders/imageProcessing.fragment";
  42070. import "babylonjs/Shaders/postprocess.vertex";
  42071. /**
  42072. * ImageProcessingPostProcess
  42073. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42074. */
  42075. export class ImageProcessingPostProcess extends PostProcess {
  42076. /**
  42077. * Default configuration related to image processing available in the PBR Material.
  42078. */
  42079. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42080. /**
  42081. * Gets the image processing configuration used either in this material.
  42082. */
  42083. /**
  42084. * Sets the Default image processing configuration used either in the this material.
  42085. *
  42086. * If sets to null, the scene one is in use.
  42087. */
  42088. imageProcessingConfiguration: ImageProcessingConfiguration;
  42089. /**
  42090. * Keep track of the image processing observer to allow dispose and replace.
  42091. */
  42092. private _imageProcessingObserver;
  42093. /**
  42094. * Attaches a new image processing configuration to the PBR Material.
  42095. * @param configuration
  42096. */
  42097. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42098. /**
  42099. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42100. */
  42101. /**
  42102. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42103. */
  42104. colorCurves: Nullable<ColorCurves>;
  42105. /**
  42106. * Gets wether the color curves effect is enabled.
  42107. */
  42108. /**
  42109. * Sets wether the color curves effect is enabled.
  42110. */
  42111. colorCurvesEnabled: boolean;
  42112. /**
  42113. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42114. */
  42115. /**
  42116. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42117. */
  42118. colorGradingTexture: Nullable<BaseTexture>;
  42119. /**
  42120. * Gets wether the color grading effect is enabled.
  42121. */
  42122. /**
  42123. * Gets wether the color grading effect is enabled.
  42124. */
  42125. colorGradingEnabled: boolean;
  42126. /**
  42127. * Gets exposure used in the effect.
  42128. */
  42129. /**
  42130. * Sets exposure used in the effect.
  42131. */
  42132. exposure: number;
  42133. /**
  42134. * Gets wether tonemapping is enabled or not.
  42135. */
  42136. /**
  42137. * Sets wether tonemapping is enabled or not
  42138. */
  42139. toneMappingEnabled: boolean;
  42140. /**
  42141. * Gets the type of tone mapping effect.
  42142. */
  42143. /**
  42144. * Sets the type of tone mapping effect.
  42145. */
  42146. toneMappingType: number;
  42147. /**
  42148. * Gets contrast used in the effect.
  42149. */
  42150. /**
  42151. * Sets contrast used in the effect.
  42152. */
  42153. contrast: number;
  42154. /**
  42155. * Gets Vignette stretch size.
  42156. */
  42157. /**
  42158. * Sets Vignette stretch size.
  42159. */
  42160. vignetteStretch: number;
  42161. /**
  42162. * Gets Vignette centre X Offset.
  42163. */
  42164. /**
  42165. * Sets Vignette centre X Offset.
  42166. */
  42167. vignetteCentreX: number;
  42168. /**
  42169. * Gets Vignette centre Y Offset.
  42170. */
  42171. /**
  42172. * Sets Vignette centre Y Offset.
  42173. */
  42174. vignetteCentreY: number;
  42175. /**
  42176. * Gets Vignette weight or intensity of the vignette effect.
  42177. */
  42178. /**
  42179. * Sets Vignette weight or intensity of the vignette effect.
  42180. */
  42181. vignetteWeight: number;
  42182. /**
  42183. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42184. * if vignetteEnabled is set to true.
  42185. */
  42186. /**
  42187. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42188. * if vignetteEnabled is set to true.
  42189. */
  42190. vignetteColor: Color4;
  42191. /**
  42192. * Gets Camera field of view used by the Vignette effect.
  42193. */
  42194. /**
  42195. * Sets Camera field of view used by the Vignette effect.
  42196. */
  42197. vignetteCameraFov: number;
  42198. /**
  42199. * Gets the vignette blend mode allowing different kind of effect.
  42200. */
  42201. /**
  42202. * Sets the vignette blend mode allowing different kind of effect.
  42203. */
  42204. vignetteBlendMode: number;
  42205. /**
  42206. * Gets wether the vignette effect is enabled.
  42207. */
  42208. /**
  42209. * Sets wether the vignette effect is enabled.
  42210. */
  42211. vignetteEnabled: boolean;
  42212. private _fromLinearSpace;
  42213. /**
  42214. * Gets wether the input of the processing is in Gamma or Linear Space.
  42215. */
  42216. /**
  42217. * Sets wether the input of the processing is in Gamma or Linear Space.
  42218. */
  42219. fromLinearSpace: boolean;
  42220. /**
  42221. * Defines cache preventing GC.
  42222. */
  42223. private _defines;
  42224. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42225. /**
  42226. * "ImageProcessingPostProcess"
  42227. * @returns "ImageProcessingPostProcess"
  42228. */
  42229. getClassName(): string;
  42230. protected _updateParameters(): void;
  42231. dispose(camera?: Camera): void;
  42232. }
  42233. }
  42234. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42235. import { Scene } from "babylonjs/scene";
  42236. import { Color3 } from "babylonjs/Maths/math.color";
  42237. import { Mesh } from "babylonjs/Meshes/mesh";
  42238. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42239. import { Nullable } from "babylonjs/types";
  42240. /**
  42241. * Class containing static functions to help procedurally build meshes
  42242. */
  42243. export class GroundBuilder {
  42244. /**
  42245. * Creates a ground mesh
  42246. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42247. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42249. * @param name defines the name of the mesh
  42250. * @param options defines the options used to create the mesh
  42251. * @param scene defines the hosting scene
  42252. * @returns the ground mesh
  42253. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42254. */
  42255. static CreateGround(name: string, options: {
  42256. width?: number;
  42257. height?: number;
  42258. subdivisions?: number;
  42259. subdivisionsX?: number;
  42260. subdivisionsY?: number;
  42261. updatable?: boolean;
  42262. }, scene: any): Mesh;
  42263. /**
  42264. * Creates a tiled ground mesh
  42265. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42266. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42267. * * 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
  42268. * * 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
  42269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42270. * @param name defines the name of the mesh
  42271. * @param options defines the options used to create the mesh
  42272. * @param scene defines the hosting scene
  42273. * @returns the tiled ground mesh
  42274. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42275. */
  42276. static CreateTiledGround(name: string, options: {
  42277. xmin: number;
  42278. zmin: number;
  42279. xmax: number;
  42280. zmax: number;
  42281. subdivisions?: {
  42282. w: number;
  42283. h: number;
  42284. };
  42285. precision?: {
  42286. w: number;
  42287. h: number;
  42288. };
  42289. updatable?: boolean;
  42290. }, scene?: Nullable<Scene>): Mesh;
  42291. /**
  42292. * Creates a ground mesh from a height map
  42293. * * The parameter `url` sets the URL of the height map image resource.
  42294. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42295. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42296. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42297. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42298. * * 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.
  42299. * * 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).
  42300. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42302. * @param name defines the name of the mesh
  42303. * @param url defines the url to the height map
  42304. * @param options defines the options used to create the mesh
  42305. * @param scene defines the hosting scene
  42306. * @returns the ground mesh
  42307. * @see https://doc.babylonjs.com/babylon101/height_map
  42308. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42309. */
  42310. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42311. width?: number;
  42312. height?: number;
  42313. subdivisions?: number;
  42314. minHeight?: number;
  42315. maxHeight?: number;
  42316. colorFilter?: Color3;
  42317. alphaFilter?: number;
  42318. updatable?: boolean;
  42319. onReady?: (mesh: GroundMesh) => void;
  42320. }, scene?: Nullable<Scene>): GroundMesh;
  42321. }
  42322. }
  42323. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42324. import { Vector4 } from "babylonjs/Maths/math.vector";
  42325. import { Mesh } from "babylonjs/Meshes/mesh";
  42326. /**
  42327. * Class containing static functions to help procedurally build meshes
  42328. */
  42329. export class TorusBuilder {
  42330. /**
  42331. * Creates a torus mesh
  42332. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42333. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42334. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42336. * * 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
  42337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42338. * @param name defines the name of the mesh
  42339. * @param options defines the options used to create the mesh
  42340. * @param scene defines the hosting scene
  42341. * @returns the torus mesh
  42342. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42343. */
  42344. static CreateTorus(name: string, options: {
  42345. diameter?: number;
  42346. thickness?: number;
  42347. tessellation?: number;
  42348. updatable?: boolean;
  42349. sideOrientation?: number;
  42350. frontUVs?: Vector4;
  42351. backUVs?: Vector4;
  42352. }, scene: any): Mesh;
  42353. }
  42354. }
  42355. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42356. import { Vector4 } from "babylonjs/Maths/math.vector";
  42357. import { Color4 } from "babylonjs/Maths/math.color";
  42358. import { Mesh } from "babylonjs/Meshes/mesh";
  42359. /**
  42360. * Class containing static functions to help procedurally build meshes
  42361. */
  42362. export class CylinderBuilder {
  42363. /**
  42364. * Creates a cylinder or a cone mesh
  42365. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42366. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42367. * * 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.
  42368. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42369. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42370. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42371. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42372. * * 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).
  42373. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42374. * * 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).
  42375. * * 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
  42376. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42377. * * 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
  42378. * * 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.
  42379. * * If `enclose` is false, a ring surface is one element.
  42380. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42381. * * 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
  42382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42383. * * 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
  42384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42385. * @param name defines the name of the mesh
  42386. * @param options defines the options used to create the mesh
  42387. * @param scene defines the hosting scene
  42388. * @returns the cylinder mesh
  42389. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42390. */
  42391. static CreateCylinder(name: string, options: {
  42392. height?: number;
  42393. diameterTop?: number;
  42394. diameterBottom?: number;
  42395. diameter?: number;
  42396. tessellation?: number;
  42397. subdivisions?: number;
  42398. arc?: number;
  42399. faceColors?: Color4[];
  42400. faceUV?: Vector4[];
  42401. updatable?: boolean;
  42402. hasRings?: boolean;
  42403. enclose?: boolean;
  42404. cap?: number;
  42405. sideOrientation?: number;
  42406. frontUVs?: Vector4;
  42407. backUVs?: Vector4;
  42408. }, scene: any): Mesh;
  42409. }
  42410. }
  42411. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42412. import { Observable } from "babylonjs/Misc/observable";
  42413. import { Nullable } from "babylonjs/types";
  42414. import { Camera } from "babylonjs/Cameras/camera";
  42415. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42416. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42417. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42418. import { Scene } from "babylonjs/scene";
  42419. import { Vector3 } from "babylonjs/Maths/math.vector";
  42420. import { Color3 } from "babylonjs/Maths/math.color";
  42421. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42423. import { Mesh } from "babylonjs/Meshes/mesh";
  42424. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42425. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42426. import "babylonjs/Meshes/Builders/groundBuilder";
  42427. import "babylonjs/Meshes/Builders/torusBuilder";
  42428. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42429. import "babylonjs/Gamepads/gamepadSceneComponent";
  42430. import "babylonjs/Animations/animatable";
  42431. /**
  42432. * Options to modify the vr teleportation behavior.
  42433. */
  42434. export interface VRTeleportationOptions {
  42435. /**
  42436. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42437. */
  42438. floorMeshName?: string;
  42439. /**
  42440. * A list of meshes to be used as the teleportation floor. (default: empty)
  42441. */
  42442. floorMeshes?: Mesh[];
  42443. }
  42444. /**
  42445. * Options to modify the vr experience helper's behavior.
  42446. */
  42447. export interface VRExperienceHelperOptions extends WebVROptions {
  42448. /**
  42449. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42450. */
  42451. createDeviceOrientationCamera?: boolean;
  42452. /**
  42453. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42454. */
  42455. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42456. /**
  42457. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42458. */
  42459. laserToggle?: boolean;
  42460. /**
  42461. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42462. */
  42463. floorMeshes?: Mesh[];
  42464. /**
  42465. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42466. */
  42467. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42468. }
  42469. /**
  42470. * Event containing information after VR has been entered
  42471. */
  42472. export class OnAfterEnteringVRObservableEvent {
  42473. /**
  42474. * If entering vr was successful
  42475. */
  42476. success: boolean;
  42477. }
  42478. /**
  42479. * Helps to quickly add VR support to an existing scene.
  42480. * See http://doc.babylonjs.com/how_to/webvr_helper
  42481. */
  42482. export class VRExperienceHelper {
  42483. /** Options to modify the vr experience helper's behavior. */
  42484. webVROptions: VRExperienceHelperOptions;
  42485. private _scene;
  42486. private _position;
  42487. private _btnVR;
  42488. private _btnVRDisplayed;
  42489. private _webVRsupported;
  42490. private _webVRready;
  42491. private _webVRrequesting;
  42492. private _webVRpresenting;
  42493. private _hasEnteredVR;
  42494. private _fullscreenVRpresenting;
  42495. private _canvas;
  42496. private _webVRCamera;
  42497. private _vrDeviceOrientationCamera;
  42498. private _deviceOrientationCamera;
  42499. private _existingCamera;
  42500. private _onKeyDown;
  42501. private _onVrDisplayPresentChange;
  42502. private _onVRDisplayChanged;
  42503. private _onVRRequestPresentStart;
  42504. private _onVRRequestPresentComplete;
  42505. /**
  42506. * 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)
  42507. */
  42508. enableGazeEvenWhenNoPointerLock: boolean;
  42509. /**
  42510. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42511. */
  42512. exitVROnDoubleTap: boolean;
  42513. /**
  42514. * Observable raised right before entering VR.
  42515. */
  42516. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42517. /**
  42518. * Observable raised when entering VR has completed.
  42519. */
  42520. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42521. /**
  42522. * Observable raised when exiting VR.
  42523. */
  42524. onExitingVRObservable: Observable<VRExperienceHelper>;
  42525. /**
  42526. * Observable raised when controller mesh is loaded.
  42527. */
  42528. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42529. /** Return this.onEnteringVRObservable
  42530. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42531. */
  42532. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42533. /** Return this.onExitingVRObservable
  42534. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42535. */
  42536. readonly onExitingVR: Observable<VRExperienceHelper>;
  42537. /** Return this.onControllerMeshLoadedObservable
  42538. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42539. */
  42540. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42541. private _rayLength;
  42542. private _useCustomVRButton;
  42543. private _teleportationRequested;
  42544. private _teleportActive;
  42545. private _floorMeshName;
  42546. private _floorMeshesCollection;
  42547. private _rotationAllowed;
  42548. private _teleportBackwardsVector;
  42549. private _teleportationTarget;
  42550. private _isDefaultTeleportationTarget;
  42551. private _postProcessMove;
  42552. private _teleportationFillColor;
  42553. private _teleportationBorderColor;
  42554. private _rotationAngle;
  42555. private _haloCenter;
  42556. private _cameraGazer;
  42557. private _padSensibilityUp;
  42558. private _padSensibilityDown;
  42559. private _leftController;
  42560. private _rightController;
  42561. /**
  42562. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42563. */
  42564. onNewMeshSelected: Observable<AbstractMesh>;
  42565. /**
  42566. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42567. * This observable will provide the mesh and the controller used to select the mesh
  42568. */
  42569. onMeshSelectedWithController: Observable<{
  42570. mesh: AbstractMesh;
  42571. controller: WebVRController;
  42572. }>;
  42573. /**
  42574. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42575. */
  42576. onNewMeshPicked: Observable<PickingInfo>;
  42577. private _circleEase;
  42578. /**
  42579. * Observable raised before camera teleportation
  42580. */
  42581. onBeforeCameraTeleport: Observable<Vector3>;
  42582. /**
  42583. * Observable raised after camera teleportation
  42584. */
  42585. onAfterCameraTeleport: Observable<Vector3>;
  42586. /**
  42587. * Observable raised when current selected mesh gets unselected
  42588. */
  42589. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42590. private _raySelectionPredicate;
  42591. /**
  42592. * To be optionaly changed by user to define custom ray selection
  42593. */
  42594. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42595. /**
  42596. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42597. */
  42598. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42599. /**
  42600. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42601. */
  42602. teleportationEnabled: boolean;
  42603. private _defaultHeight;
  42604. private _teleportationInitialized;
  42605. private _interactionsEnabled;
  42606. private _interactionsRequested;
  42607. private _displayGaze;
  42608. private _displayLaserPointer;
  42609. /**
  42610. * The mesh used to display where the user is going to teleport.
  42611. */
  42612. /**
  42613. * Sets the mesh to be used to display where the user is going to teleport.
  42614. */
  42615. teleportationTarget: Mesh;
  42616. /**
  42617. * 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
  42618. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42619. * See http://doc.babylonjs.com/resources/baking_transformations
  42620. */
  42621. gazeTrackerMesh: Mesh;
  42622. /**
  42623. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42624. */
  42625. updateGazeTrackerScale: boolean;
  42626. /**
  42627. * If the gaze trackers color should be updated when selecting meshes
  42628. */
  42629. updateGazeTrackerColor: boolean;
  42630. /**
  42631. * If the controller laser color should be updated when selecting meshes
  42632. */
  42633. updateControllerLaserColor: boolean;
  42634. /**
  42635. * The gaze tracking mesh corresponding to the left controller
  42636. */
  42637. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42638. /**
  42639. * The gaze tracking mesh corresponding to the right controller
  42640. */
  42641. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42642. /**
  42643. * If the ray of the gaze should be displayed.
  42644. */
  42645. /**
  42646. * Sets if the ray of the gaze should be displayed.
  42647. */
  42648. displayGaze: boolean;
  42649. /**
  42650. * If the ray of the LaserPointer should be displayed.
  42651. */
  42652. /**
  42653. * Sets if the ray of the LaserPointer should be displayed.
  42654. */
  42655. displayLaserPointer: boolean;
  42656. /**
  42657. * The deviceOrientationCamera used as the camera when not in VR.
  42658. */
  42659. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42660. /**
  42661. * Based on the current WebVR support, returns the current VR camera used.
  42662. */
  42663. readonly currentVRCamera: Nullable<Camera>;
  42664. /**
  42665. * The webVRCamera which is used when in VR.
  42666. */
  42667. readonly webVRCamera: WebVRFreeCamera;
  42668. /**
  42669. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42670. */
  42671. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42672. /**
  42673. * The html button that is used to trigger entering into VR.
  42674. */
  42675. readonly vrButton: Nullable<HTMLButtonElement>;
  42676. private readonly _teleportationRequestInitiated;
  42677. /**
  42678. * Defines wether or not Pointer lock should be requested when switching to
  42679. * full screen.
  42680. */
  42681. requestPointerLockOnFullScreen: boolean;
  42682. /**
  42683. * Instantiates a VRExperienceHelper.
  42684. * Helps to quickly add VR support to an existing scene.
  42685. * @param scene The scene the VRExperienceHelper belongs to.
  42686. * @param webVROptions Options to modify the vr experience helper's behavior.
  42687. */
  42688. constructor(scene: Scene,
  42689. /** Options to modify the vr experience helper's behavior. */
  42690. webVROptions?: VRExperienceHelperOptions);
  42691. private _onDefaultMeshLoaded;
  42692. private _onResize;
  42693. private _onFullscreenChange;
  42694. /**
  42695. * Gets a value indicating if we are currently in VR mode.
  42696. */
  42697. readonly isInVRMode: boolean;
  42698. private onVrDisplayPresentChange;
  42699. private onVRDisplayChanged;
  42700. private moveButtonToBottomRight;
  42701. private displayVRButton;
  42702. private updateButtonVisibility;
  42703. private _cachedAngularSensibility;
  42704. /**
  42705. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42706. * Otherwise, will use the fullscreen API.
  42707. */
  42708. enterVR(): void;
  42709. /**
  42710. * Attempt to exit VR, or fullscreen.
  42711. */
  42712. exitVR(): void;
  42713. /**
  42714. * The position of the vr experience helper.
  42715. */
  42716. /**
  42717. * Sets the position of the vr experience helper.
  42718. */
  42719. position: Vector3;
  42720. /**
  42721. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42722. */
  42723. enableInteractions(): void;
  42724. private readonly _noControllerIsActive;
  42725. private beforeRender;
  42726. private _isTeleportationFloor;
  42727. /**
  42728. * Adds a floor mesh to be used for teleportation.
  42729. * @param floorMesh the mesh to be used for teleportation.
  42730. */
  42731. addFloorMesh(floorMesh: Mesh): void;
  42732. /**
  42733. * Removes a floor mesh from being used for teleportation.
  42734. * @param floorMesh the mesh to be removed.
  42735. */
  42736. removeFloorMesh(floorMesh: Mesh): void;
  42737. /**
  42738. * Enables interactions and teleportation using the VR controllers and gaze.
  42739. * @param vrTeleportationOptions options to modify teleportation behavior.
  42740. */
  42741. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42742. private _onNewGamepadConnected;
  42743. private _tryEnableInteractionOnController;
  42744. private _onNewGamepadDisconnected;
  42745. private _enableInteractionOnController;
  42746. private _checkTeleportWithRay;
  42747. private _checkRotate;
  42748. private _checkTeleportBackwards;
  42749. private _enableTeleportationOnController;
  42750. private _createTeleportationCircles;
  42751. private _displayTeleportationTarget;
  42752. private _hideTeleportationTarget;
  42753. private _rotateCamera;
  42754. private _moveTeleportationSelectorTo;
  42755. private _workingVector;
  42756. private _workingQuaternion;
  42757. private _workingMatrix;
  42758. /**
  42759. * Teleports the users feet to the desired location
  42760. * @param location The location where the user's feet should be placed
  42761. */
  42762. teleportCamera(location: Vector3): void;
  42763. private _convertNormalToDirectionOfRay;
  42764. private _castRayAndSelectObject;
  42765. private _notifySelectedMeshUnselected;
  42766. /**
  42767. * Sets the color of the laser ray from the vr controllers.
  42768. * @param color new color for the ray.
  42769. */
  42770. changeLaserColor(color: Color3): void;
  42771. /**
  42772. * Sets the color of the ray from the vr headsets gaze.
  42773. * @param color new color for the ray.
  42774. */
  42775. changeGazeColor(color: Color3): void;
  42776. /**
  42777. * Exits VR and disposes of the vr experience helper
  42778. */
  42779. dispose(): void;
  42780. /**
  42781. * Gets the name of the VRExperienceHelper class
  42782. * @returns "VRExperienceHelper"
  42783. */
  42784. getClassName(): string;
  42785. }
  42786. }
  42787. declare module "babylonjs/Cameras/VR/index" {
  42788. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42789. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42790. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42791. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42792. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42793. export * from "babylonjs/Cameras/VR/webVRCamera";
  42794. }
  42795. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42796. import { Observable } from "babylonjs/Misc/observable";
  42797. import { Nullable } from "babylonjs/types";
  42798. import { IDisposable, Scene } from "babylonjs/scene";
  42799. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42800. /**
  42801. * Manages an XRSession to work with Babylon's engine
  42802. * @see https://doc.babylonjs.com/how_to/webxr
  42803. */
  42804. export class WebXRSessionManager implements IDisposable {
  42805. private scene;
  42806. /**
  42807. * Fires every time a new xrFrame arrives which can be used to update the camera
  42808. */
  42809. onXRFrameObservable: Observable<any>;
  42810. /**
  42811. * Fires when the xr session is ended either by the device or manually done
  42812. */
  42813. onXRSessionEnded: Observable<any>;
  42814. /**
  42815. * Underlying xr session
  42816. */
  42817. session: XRSession;
  42818. /**
  42819. * Type of reference space used when creating the session
  42820. */
  42821. referenceSpace: XRReferenceSpace;
  42822. /** @hidden */
  42823. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42824. /**
  42825. * Current XR frame
  42826. */
  42827. currentFrame: Nullable<XRFrame>;
  42828. private _xrNavigator;
  42829. private baseLayer;
  42830. /**
  42831. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42832. * @param scene The scene which the session should be created for
  42833. */
  42834. constructor(scene: Scene);
  42835. /**
  42836. * Initializes the manager
  42837. * After initialization enterXR can be called to start an XR session
  42838. * @returns Promise which resolves after it is initialized
  42839. */
  42840. initializeAsync(): Promise<void>;
  42841. /**
  42842. * Initializes an xr session
  42843. * @param xrSessionMode mode to initialize
  42844. * @returns a promise which will resolve once the session has been initialized
  42845. */
  42846. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42847. /**
  42848. * Sets the reference space on the xr session
  42849. * @param referenceSpace space to set
  42850. * @returns a promise that will resolve once the reference space has been set
  42851. */
  42852. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42853. /**
  42854. * Updates the render state of the session
  42855. * @param state state to set
  42856. * @returns a promise that resolves once the render state has been updated
  42857. */
  42858. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42859. /**
  42860. * Starts rendering to the xr layer
  42861. * @returns a promise that will resolve once rendering has started
  42862. */
  42863. startRenderingToXRAsync(): Promise<void>;
  42864. /**
  42865. * Stops the xrSession and restores the renderloop
  42866. * @returns Promise which resolves after it exits XR
  42867. */
  42868. exitXRAsync(): Promise<unknown>;
  42869. /**
  42870. * Checks if a session would be supported for the creation options specified
  42871. * @param sessionMode session mode to check if supported eg. immersive-vr
  42872. * @returns true if supported
  42873. */
  42874. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42875. /**
  42876. * @hidden
  42877. * Converts the render layer of xrSession to a render target
  42878. * @param session session to create render target for
  42879. * @param scene scene the new render target should be created for
  42880. */
  42881. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42882. /**
  42883. * Disposes of the session manager
  42884. */
  42885. dispose(): void;
  42886. }
  42887. }
  42888. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42889. import { Scene } from "babylonjs/scene";
  42890. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42891. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42892. /**
  42893. * WebXR Camera which holds the views for the xrSession
  42894. * @see https://doc.babylonjs.com/how_to/webxr
  42895. */
  42896. export class WebXRCamera extends FreeCamera {
  42897. private static _TmpMatrix;
  42898. /**
  42899. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42900. * @param name the name of the camera
  42901. * @param scene the scene to add the camera to
  42902. */
  42903. constructor(name: string, scene: Scene);
  42904. private _updateNumberOfRigCameras;
  42905. /** @hidden */
  42906. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42907. /**
  42908. * Updates the cameras position from the current pose information of the XR session
  42909. * @param xrSessionManager the session containing pose information
  42910. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42911. */
  42912. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42913. }
  42914. }
  42915. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42916. import { Nullable } from "babylonjs/types";
  42917. import { IDisposable } from "babylonjs/scene";
  42918. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42919. /**
  42920. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42921. */
  42922. export class WebXRManagedOutputCanvas implements IDisposable {
  42923. private helper;
  42924. private _canvas;
  42925. /**
  42926. * xrpresent context of the canvas which can be used to display/mirror xr content
  42927. */
  42928. canvasContext: WebGLRenderingContext;
  42929. /**
  42930. * xr layer for the canvas
  42931. */
  42932. xrLayer: Nullable<XRWebGLLayer>;
  42933. /**
  42934. * Initializes the xr layer for the session
  42935. * @param xrSession xr session
  42936. * @returns a promise that will resolve once the XR Layer has been created
  42937. */
  42938. initializeXRLayerAsync(xrSession: any): any;
  42939. /**
  42940. * Initializes the canvas to be added/removed upon entering/exiting xr
  42941. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42942. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42943. */
  42944. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42945. /**
  42946. * Disposes of the object
  42947. */
  42948. dispose(): void;
  42949. private _setManagedOutputCanvas;
  42950. private _addCanvas;
  42951. private _removeCanvas;
  42952. }
  42953. }
  42954. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42955. import { Observable } from "babylonjs/Misc/observable";
  42956. import { IDisposable, Scene } from "babylonjs/scene";
  42957. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42959. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42960. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42961. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42962. /**
  42963. * States of the webXR experience
  42964. */
  42965. export enum WebXRState {
  42966. /**
  42967. * Transitioning to being in XR mode
  42968. */
  42969. ENTERING_XR = 0,
  42970. /**
  42971. * Transitioning to non XR mode
  42972. */
  42973. EXITING_XR = 1,
  42974. /**
  42975. * In XR mode and presenting
  42976. */
  42977. IN_XR = 2,
  42978. /**
  42979. * Not entered XR mode
  42980. */
  42981. NOT_IN_XR = 3
  42982. }
  42983. /**
  42984. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42985. * @see https://doc.babylonjs.com/how_to/webxr
  42986. */
  42987. export class WebXRExperienceHelper implements IDisposable {
  42988. private scene;
  42989. /**
  42990. * 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
  42991. */
  42992. container: AbstractMesh;
  42993. /**
  42994. * Camera used to render xr content
  42995. */
  42996. camera: WebXRCamera;
  42997. /**
  42998. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42999. */
  43000. state: WebXRState;
  43001. private _setState;
  43002. private static _TmpVector;
  43003. /**
  43004. * Fires when the state of the experience helper has changed
  43005. */
  43006. onStateChangedObservable: Observable<WebXRState>;
  43007. /** Session manager used to keep track of xr session */
  43008. sessionManager: WebXRSessionManager;
  43009. private _nonVRCamera;
  43010. private _originalSceneAutoClear;
  43011. private _supported;
  43012. /**
  43013. * Creates the experience helper
  43014. * @param scene the scene to attach the experience helper to
  43015. * @returns a promise for the experience helper
  43016. */
  43017. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43018. /**
  43019. * Creates a WebXRExperienceHelper
  43020. * @param scene The scene the helper should be created in
  43021. */
  43022. private constructor();
  43023. /**
  43024. * Exits XR mode and returns the scene to its original state
  43025. * @returns promise that resolves after xr mode has exited
  43026. */
  43027. exitXRAsync(): Promise<unknown>;
  43028. /**
  43029. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43030. * @param sessionCreationOptions options for the XR session
  43031. * @param referenceSpaceType frame of reference of the XR session
  43032. * @param outputCanvas the output canvas that will be used to enter XR mode
  43033. * @returns promise that resolves after xr mode has entered
  43034. */
  43035. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43036. /**
  43037. * Updates the global position of the camera by moving the camera's container
  43038. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43039. * @param position The desired global position of the camera
  43040. */
  43041. setPositionOfCameraUsingContainer(position: Vector3): void;
  43042. /**
  43043. * Rotates the xr camera by rotating the camera's container around the camera's position
  43044. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43045. * @param rotation the desired quaternion rotation to apply to the camera
  43046. */
  43047. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43048. /**
  43049. * Disposes of the experience helper
  43050. */
  43051. dispose(): void;
  43052. }
  43053. }
  43054. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43055. import { Nullable } from "babylonjs/types";
  43056. import { Observable } from "babylonjs/Misc/observable";
  43057. import { IDisposable, Scene } from "babylonjs/scene";
  43058. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43059. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43060. /**
  43061. * Button which can be used to enter a different mode of XR
  43062. */
  43063. export class WebXREnterExitUIButton {
  43064. /** button element */
  43065. element: HTMLElement;
  43066. /** XR initialization options for the button */
  43067. sessionMode: XRSessionMode;
  43068. /** Reference space type */
  43069. referenceSpaceType: XRReferenceSpaceType;
  43070. /**
  43071. * Creates a WebXREnterExitUIButton
  43072. * @param element button element
  43073. * @param sessionMode XR initialization session mode
  43074. * @param referenceSpaceType the type of reference space to be used
  43075. */
  43076. constructor(
  43077. /** button element */
  43078. element: HTMLElement,
  43079. /** XR initialization options for the button */
  43080. sessionMode: XRSessionMode,
  43081. /** Reference space type */
  43082. referenceSpaceType: XRReferenceSpaceType);
  43083. /**
  43084. * Overwritable function which can be used to update the button's visuals when the state changes
  43085. * @param activeButton the current active button in the UI
  43086. */
  43087. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43088. }
  43089. /**
  43090. * Options to create the webXR UI
  43091. */
  43092. export class WebXREnterExitUIOptions {
  43093. /**
  43094. * Context to enter xr with
  43095. */
  43096. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43097. /**
  43098. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43099. */
  43100. customButtons?: Array<WebXREnterExitUIButton>;
  43101. }
  43102. /**
  43103. * UI to allow the user to enter/exit XR mode
  43104. */
  43105. export class WebXREnterExitUI implements IDisposable {
  43106. private scene;
  43107. private _overlay;
  43108. private _buttons;
  43109. private _activeButton;
  43110. /**
  43111. * Fired every time the active button is changed.
  43112. *
  43113. * When xr is entered via a button that launches xr that button will be the callback parameter
  43114. *
  43115. * When exiting xr the callback parameter will be null)
  43116. */
  43117. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43118. /**
  43119. * Creates UI to allow the user to enter/exit XR mode
  43120. * @param scene the scene to add the ui to
  43121. * @param helper the xr experience helper to enter/exit xr with
  43122. * @param options options to configure the UI
  43123. * @returns the created ui
  43124. */
  43125. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43126. private constructor();
  43127. private _updateButtons;
  43128. /**
  43129. * Disposes of the object
  43130. */
  43131. dispose(): void;
  43132. }
  43133. }
  43134. declare module "babylonjs/Cameras/XR/webXRController" {
  43135. import { Nullable } from "babylonjs/types";
  43136. import { Observable } from "babylonjs/Misc/observable";
  43137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43138. import { Ray } from "babylonjs/Culling/ray";
  43139. import { Scene } from "babylonjs/scene";
  43140. /**
  43141. * Represents an XR input
  43142. */
  43143. export class WebXRController {
  43144. private scene;
  43145. /** The underlying input source for the controller */
  43146. inputSource: XRInputSource;
  43147. private parentContainer;
  43148. /**
  43149. * 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
  43150. */
  43151. grip?: AbstractMesh;
  43152. /**
  43153. * Pointer which can be used to select objects or attach a visible laser to
  43154. */
  43155. pointer: AbstractMesh;
  43156. /**
  43157. * Event that fires when the controller is removed/disposed
  43158. */
  43159. onDisposeObservable: Observable<{}>;
  43160. private _tmpMatrix;
  43161. private _tmpQuaternion;
  43162. private _tmpVector;
  43163. /**
  43164. * Creates the controller
  43165. * @see https://doc.babylonjs.com/how_to/webxr
  43166. * @param scene the scene which the controller should be associated to
  43167. * @param inputSource the underlying input source for the controller
  43168. * @param parentContainer parent that the controller meshes should be children of
  43169. */
  43170. constructor(scene: Scene,
  43171. /** The underlying input source for the controller */
  43172. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43173. /**
  43174. * Updates the controller pose based on the given XRFrame
  43175. * @param xrFrame xr frame to update the pose with
  43176. * @param referenceSpace reference space to use
  43177. */
  43178. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43179. /**
  43180. * Gets a world space ray coming from the controller
  43181. * @param result the resulting ray
  43182. */
  43183. getWorldPointerRayToRef(result: Ray): void;
  43184. /**
  43185. * Disposes of the object
  43186. */
  43187. dispose(): void;
  43188. }
  43189. }
  43190. declare module "babylonjs/Cameras/XR/webXRInput" {
  43191. import { Observable } from "babylonjs/Misc/observable";
  43192. import { IDisposable } from "babylonjs/scene";
  43193. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43194. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43195. /**
  43196. * XR input used to track XR inputs such as controllers/rays
  43197. */
  43198. export class WebXRInput implements IDisposable {
  43199. /**
  43200. * Base experience the input listens to
  43201. */
  43202. baseExperience: WebXRExperienceHelper;
  43203. /**
  43204. * XR controllers being tracked
  43205. */
  43206. controllers: Array<WebXRController>;
  43207. private _frameObserver;
  43208. private _stateObserver;
  43209. /**
  43210. * Event when a controller has been connected/added
  43211. */
  43212. onControllerAddedObservable: Observable<WebXRController>;
  43213. /**
  43214. * Event when a controller has been removed/disconnected
  43215. */
  43216. onControllerRemovedObservable: Observable<WebXRController>;
  43217. /**
  43218. * Initializes the WebXRInput
  43219. * @param baseExperience experience helper which the input should be created for
  43220. */
  43221. constructor(
  43222. /**
  43223. * Base experience the input listens to
  43224. */
  43225. baseExperience: WebXRExperienceHelper);
  43226. private _onInputSourcesChange;
  43227. private _addAndRemoveControllers;
  43228. /**
  43229. * Disposes of the object
  43230. */
  43231. dispose(): void;
  43232. }
  43233. }
  43234. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43236. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43237. /**
  43238. * Enables teleportation
  43239. */
  43240. export class WebXRControllerTeleportation {
  43241. private _teleportationFillColor;
  43242. private _teleportationBorderColor;
  43243. private _tmpRay;
  43244. private _tmpVector;
  43245. /**
  43246. * Creates a WebXRControllerTeleportation
  43247. * @param input input manager to add teleportation to
  43248. * @param floorMeshes floormeshes which can be teleported to
  43249. */
  43250. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43251. }
  43252. }
  43253. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43254. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43255. /**
  43256. * Handles pointer input automatically for the pointer of XR controllers
  43257. */
  43258. export class WebXRControllerPointerSelection {
  43259. private static _idCounter;
  43260. private _tmpRay;
  43261. /**
  43262. * Creates a WebXRControllerPointerSelection
  43263. * @param input input manager to setup pointer selection
  43264. */
  43265. constructor(input: WebXRInput);
  43266. private _convertNormalToDirectionOfRay;
  43267. private _updatePointerDistance;
  43268. }
  43269. }
  43270. declare module "babylonjs/Loading/sceneLoader" {
  43271. import { Observable } from "babylonjs/Misc/observable";
  43272. import { Nullable } from "babylonjs/types";
  43273. import { Scene } from "babylonjs/scene";
  43274. import { Engine } from "babylonjs/Engines/engine";
  43275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43276. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43277. import { AssetContainer } from "babylonjs/assetContainer";
  43278. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43279. import { Skeleton } from "babylonjs/Bones/skeleton";
  43280. /**
  43281. * Class used to represent data loading progression
  43282. */
  43283. export class SceneLoaderProgressEvent {
  43284. /** defines if data length to load can be evaluated */
  43285. readonly lengthComputable: boolean;
  43286. /** defines the loaded data length */
  43287. readonly loaded: number;
  43288. /** defines the data length to load */
  43289. readonly total: number;
  43290. /**
  43291. * Create a new progress event
  43292. * @param lengthComputable defines if data length to load can be evaluated
  43293. * @param loaded defines the loaded data length
  43294. * @param total defines the data length to load
  43295. */
  43296. constructor(
  43297. /** defines if data length to load can be evaluated */
  43298. lengthComputable: boolean,
  43299. /** defines the loaded data length */
  43300. loaded: number,
  43301. /** defines the data length to load */
  43302. total: number);
  43303. /**
  43304. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43305. * @param event defines the source event
  43306. * @returns a new SceneLoaderProgressEvent
  43307. */
  43308. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43309. }
  43310. /**
  43311. * Interface used by SceneLoader plugins to define supported file extensions
  43312. */
  43313. export interface ISceneLoaderPluginExtensions {
  43314. /**
  43315. * Defines the list of supported extensions
  43316. */
  43317. [extension: string]: {
  43318. isBinary: boolean;
  43319. };
  43320. }
  43321. /**
  43322. * Interface used by SceneLoader plugin factory
  43323. */
  43324. export interface ISceneLoaderPluginFactory {
  43325. /**
  43326. * Defines the name of the factory
  43327. */
  43328. name: string;
  43329. /**
  43330. * Function called to create a new plugin
  43331. * @return the new plugin
  43332. */
  43333. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43334. /**
  43335. * Boolean indicating if the plugin can direct load specific data
  43336. */
  43337. canDirectLoad?: (data: string) => boolean;
  43338. }
  43339. /**
  43340. * Interface used to define a SceneLoader plugin
  43341. */
  43342. export interface ISceneLoaderPlugin {
  43343. /**
  43344. * The friendly name of this plugin.
  43345. */
  43346. name: string;
  43347. /**
  43348. * The file extensions supported by this plugin.
  43349. */
  43350. extensions: string | ISceneLoaderPluginExtensions;
  43351. /**
  43352. * Import meshes into a scene.
  43353. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43354. * @param scene The scene to import into
  43355. * @param data The data to import
  43356. * @param rootUrl The root url for scene and resources
  43357. * @param meshes The meshes array to import into
  43358. * @param particleSystems The particle systems array to import into
  43359. * @param skeletons The skeletons array to import into
  43360. * @param onError The callback when import fails
  43361. * @returns True if successful or false otherwise
  43362. */
  43363. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43364. /**
  43365. * Load into a scene.
  43366. * @param scene The scene to load into
  43367. * @param data The data to import
  43368. * @param rootUrl The root url for scene and resources
  43369. * @param onError The callback when import fails
  43370. * @returns true if successful or false otherwise
  43371. */
  43372. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43373. /**
  43374. * The callback that returns true if the data can be directly loaded.
  43375. */
  43376. canDirectLoad?: (data: string) => boolean;
  43377. /**
  43378. * The callback that allows custom handling of the root url based on the response url.
  43379. */
  43380. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43381. /**
  43382. * Load into an asset container.
  43383. * @param scene The scene to load into
  43384. * @param data The data to import
  43385. * @param rootUrl The root url for scene and resources
  43386. * @param onError The callback when import fails
  43387. * @returns The loaded asset container
  43388. */
  43389. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43390. }
  43391. /**
  43392. * Interface used to define an async SceneLoader plugin
  43393. */
  43394. export interface ISceneLoaderPluginAsync {
  43395. /**
  43396. * The friendly name of this plugin.
  43397. */
  43398. name: string;
  43399. /**
  43400. * The file extensions supported by this plugin.
  43401. */
  43402. extensions: string | ISceneLoaderPluginExtensions;
  43403. /**
  43404. * Import meshes into a scene.
  43405. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43406. * @param scene The scene to import into
  43407. * @param data The data to import
  43408. * @param rootUrl The root url for scene and resources
  43409. * @param onProgress The callback when the load progresses
  43410. * @param fileName Defines the name of the file to load
  43411. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43412. */
  43413. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43414. meshes: AbstractMesh[];
  43415. particleSystems: IParticleSystem[];
  43416. skeletons: Skeleton[];
  43417. animationGroups: AnimationGroup[];
  43418. }>;
  43419. /**
  43420. * Load into a scene.
  43421. * @param scene The scene to load into
  43422. * @param data The data to import
  43423. * @param rootUrl The root url for scene and resources
  43424. * @param onProgress The callback when the load progresses
  43425. * @param fileName Defines the name of the file to load
  43426. * @returns Nothing
  43427. */
  43428. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43429. /**
  43430. * The callback that returns true if the data can be directly loaded.
  43431. */
  43432. canDirectLoad?: (data: string) => boolean;
  43433. /**
  43434. * The callback that allows custom handling of the root url based on the response url.
  43435. */
  43436. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43437. /**
  43438. * Load into an asset container.
  43439. * @param scene The scene to load into
  43440. * @param data The data to import
  43441. * @param rootUrl The root url for scene and resources
  43442. * @param onProgress The callback when the load progresses
  43443. * @param fileName Defines the name of the file to load
  43444. * @returns The loaded asset container
  43445. */
  43446. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43447. }
  43448. /**
  43449. * Class used to load scene from various file formats using registered plugins
  43450. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43451. */
  43452. export class SceneLoader {
  43453. /**
  43454. * No logging while loading
  43455. */
  43456. static readonly NO_LOGGING: number;
  43457. /**
  43458. * Minimal logging while loading
  43459. */
  43460. static readonly MINIMAL_LOGGING: number;
  43461. /**
  43462. * Summary logging while loading
  43463. */
  43464. static readonly SUMMARY_LOGGING: number;
  43465. /**
  43466. * Detailled logging while loading
  43467. */
  43468. static readonly DETAILED_LOGGING: number;
  43469. /**
  43470. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43471. */
  43472. static ForceFullSceneLoadingForIncremental: boolean;
  43473. /**
  43474. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43475. */
  43476. static ShowLoadingScreen: boolean;
  43477. /**
  43478. * Defines the current logging level (while loading the scene)
  43479. * @ignorenaming
  43480. */
  43481. static loggingLevel: number;
  43482. /**
  43483. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43484. */
  43485. static CleanBoneMatrixWeights: boolean;
  43486. /**
  43487. * Event raised when a plugin is used to load a scene
  43488. */
  43489. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43490. private static _registeredPlugins;
  43491. private static _getDefaultPlugin;
  43492. private static _getPluginForExtension;
  43493. private static _getPluginForDirectLoad;
  43494. private static _getPluginForFilename;
  43495. private static _getDirectLoad;
  43496. private static _loadData;
  43497. private static _getFileInfo;
  43498. /**
  43499. * Gets a plugin that can load the given extension
  43500. * @param extension defines the extension to load
  43501. * @returns a plugin or null if none works
  43502. */
  43503. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43504. /**
  43505. * Gets a boolean indicating that the given extension can be loaded
  43506. * @param extension defines the extension to load
  43507. * @returns true if the extension is supported
  43508. */
  43509. static IsPluginForExtensionAvailable(extension: string): boolean;
  43510. /**
  43511. * Adds a new plugin to the list of registered plugins
  43512. * @param plugin defines the plugin to add
  43513. */
  43514. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43515. /**
  43516. * Import meshes into a scene
  43517. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43518. * @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)
  43519. * @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)
  43520. * @param scene the instance of BABYLON.Scene to append to
  43521. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43522. * @param onProgress a callback with a progress event for each file being loaded
  43523. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43524. * @param pluginExtension the extension used to determine the plugin
  43525. * @returns The loaded plugin
  43526. */
  43527. 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>;
  43528. /**
  43529. * Import meshes into a scene
  43530. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43531. * @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)
  43532. * @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)
  43533. * @param scene the instance of BABYLON.Scene to append to
  43534. * @param onProgress a callback with a progress event for each file being loaded
  43535. * @param pluginExtension the extension used to determine the plugin
  43536. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43537. */
  43538. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43539. meshes: AbstractMesh[];
  43540. particleSystems: IParticleSystem[];
  43541. skeletons: Skeleton[];
  43542. animationGroups: AnimationGroup[];
  43543. }>;
  43544. /**
  43545. * Load a scene
  43546. * @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)
  43547. * @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)
  43548. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43549. * @param onSuccess a callback with the scene when import succeeds
  43550. * @param onProgress a callback with a progress event for each file being loaded
  43551. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43552. * @param pluginExtension the extension used to determine the plugin
  43553. * @returns The loaded plugin
  43554. */
  43555. 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>;
  43556. /**
  43557. * Load a scene
  43558. * @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)
  43559. * @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)
  43560. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43561. * @param onProgress a callback with a progress event for each file being loaded
  43562. * @param pluginExtension the extension used to determine the plugin
  43563. * @returns The loaded scene
  43564. */
  43565. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43566. /**
  43567. * Append a scene
  43568. * @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)
  43569. * @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)
  43570. * @param scene is the instance of BABYLON.Scene to append to
  43571. * @param onSuccess a callback with the scene when import succeeds
  43572. * @param onProgress a callback with a progress event for each file being loaded
  43573. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43574. * @param pluginExtension the extension used to determine the plugin
  43575. * @returns The loaded plugin
  43576. */
  43577. 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>;
  43578. /**
  43579. * Append a scene
  43580. * @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)
  43581. * @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)
  43582. * @param scene is the instance of BABYLON.Scene to append to
  43583. * @param onProgress a callback with a progress event for each file being loaded
  43584. * @param pluginExtension the extension used to determine the plugin
  43585. * @returns The given scene
  43586. */
  43587. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43588. /**
  43589. * Load a scene into an asset container
  43590. * @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)
  43591. * @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)
  43592. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43593. * @param onSuccess a callback with the scene when import succeeds
  43594. * @param onProgress a callback with a progress event for each file being loaded
  43595. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43596. * @param pluginExtension the extension used to determine the plugin
  43597. * @returns The loaded plugin
  43598. */
  43599. 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>;
  43600. /**
  43601. * Load a scene into an asset container
  43602. * @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)
  43603. * @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)
  43604. * @param scene is the instance of Scene to append to
  43605. * @param onProgress a callback with a progress event for each file being loaded
  43606. * @param pluginExtension the extension used to determine the plugin
  43607. * @returns The loaded asset container
  43608. */
  43609. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43610. }
  43611. }
  43612. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43613. import { Scene } from "babylonjs/scene";
  43614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43615. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43616. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43617. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43618. /**
  43619. * Generic Controller
  43620. */
  43621. export class GenericController extends WebVRController {
  43622. /**
  43623. * Base Url for the controller model.
  43624. */
  43625. static readonly MODEL_BASE_URL: string;
  43626. /**
  43627. * File name for the controller model.
  43628. */
  43629. static readonly MODEL_FILENAME: string;
  43630. /**
  43631. * Creates a new GenericController from a gamepad
  43632. * @param vrGamepad the gamepad that the controller should be created from
  43633. */
  43634. constructor(vrGamepad: any);
  43635. /**
  43636. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43637. * @param scene scene in which to add meshes
  43638. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43639. */
  43640. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43641. /**
  43642. * Called once for each button that changed state since the last frame
  43643. * @param buttonIdx Which button index changed
  43644. * @param state New state of the button
  43645. * @param changes Which properties on the state changed since last frame
  43646. */
  43647. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43648. }
  43649. }
  43650. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43651. import { Observable } from "babylonjs/Misc/observable";
  43652. import { Scene } from "babylonjs/scene";
  43653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43654. import { Ray } from "babylonjs/Culling/ray";
  43655. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43656. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43657. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43658. /**
  43659. * Defines the WindowsMotionController object that the state of the windows motion controller
  43660. */
  43661. export class WindowsMotionController extends WebVRController {
  43662. /**
  43663. * The base url used to load the left and right controller models
  43664. */
  43665. static MODEL_BASE_URL: string;
  43666. /**
  43667. * The name of the left controller model file
  43668. */
  43669. static MODEL_LEFT_FILENAME: string;
  43670. /**
  43671. * The name of the right controller model file
  43672. */
  43673. static MODEL_RIGHT_FILENAME: string;
  43674. /**
  43675. * The controller name prefix for this controller type
  43676. */
  43677. static readonly GAMEPAD_ID_PREFIX: string;
  43678. /**
  43679. * The controller id pattern for this controller type
  43680. */
  43681. private static readonly GAMEPAD_ID_PATTERN;
  43682. private _loadedMeshInfo;
  43683. private readonly _mapping;
  43684. /**
  43685. * Fired when the trackpad on this controller is clicked
  43686. */
  43687. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43688. /**
  43689. * Fired when the trackpad on this controller is modified
  43690. */
  43691. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43692. /**
  43693. * The current x and y values of this controller's trackpad
  43694. */
  43695. trackpad: StickValues;
  43696. /**
  43697. * Creates a new WindowsMotionController from a gamepad
  43698. * @param vrGamepad the gamepad that the controller should be created from
  43699. */
  43700. constructor(vrGamepad: any);
  43701. /**
  43702. * Fired when the trigger on this controller is modified
  43703. */
  43704. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43705. /**
  43706. * Fired when the menu button on this controller is modified
  43707. */
  43708. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43709. /**
  43710. * Fired when the grip button on this controller is modified
  43711. */
  43712. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43713. /**
  43714. * Fired when the thumbstick button on this controller is modified
  43715. */
  43716. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43717. /**
  43718. * Fired when the touchpad button on this controller is modified
  43719. */
  43720. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43721. /**
  43722. * Fired when the touchpad values on this controller are modified
  43723. */
  43724. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43725. private _updateTrackpad;
  43726. /**
  43727. * Called once per frame by the engine.
  43728. */
  43729. update(): void;
  43730. /**
  43731. * Called once for each button that changed state since the last frame
  43732. * @param buttonIdx Which button index changed
  43733. * @param state New state of the button
  43734. * @param changes Which properties on the state changed since last frame
  43735. */
  43736. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43737. /**
  43738. * Moves the buttons on the controller mesh based on their current state
  43739. * @param buttonName the name of the button to move
  43740. * @param buttonValue the value of the button which determines the buttons new position
  43741. */
  43742. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43743. /**
  43744. * Moves the axis on the controller mesh based on its current state
  43745. * @param axis the index of the axis
  43746. * @param axisValue the value of the axis which determines the meshes new position
  43747. * @hidden
  43748. */
  43749. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43750. /**
  43751. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43752. * @param scene scene in which to add meshes
  43753. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43754. */
  43755. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43756. /**
  43757. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43758. * can be transformed by button presses and axes values, based on this._mapping.
  43759. *
  43760. * @param scene scene in which the meshes exist
  43761. * @param meshes list of meshes that make up the controller model to process
  43762. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43763. */
  43764. private processModel;
  43765. private createMeshInfo;
  43766. /**
  43767. * Gets the ray of the controller in the direction the controller is pointing
  43768. * @param length the length the resulting ray should be
  43769. * @returns a ray in the direction the controller is pointing
  43770. */
  43771. getForwardRay(length?: number): Ray;
  43772. /**
  43773. * Disposes of the controller
  43774. */
  43775. dispose(): void;
  43776. }
  43777. }
  43778. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43779. import { Observable } from "babylonjs/Misc/observable";
  43780. import { Scene } from "babylonjs/scene";
  43781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43782. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43783. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43784. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43785. /**
  43786. * Oculus Touch Controller
  43787. */
  43788. export class OculusTouchController extends WebVRController {
  43789. /**
  43790. * Base Url for the controller model.
  43791. */
  43792. static MODEL_BASE_URL: string;
  43793. /**
  43794. * File name for the left controller model.
  43795. */
  43796. static MODEL_LEFT_FILENAME: string;
  43797. /**
  43798. * File name for the right controller model.
  43799. */
  43800. static MODEL_RIGHT_FILENAME: string;
  43801. /**
  43802. * Base Url for the Quest controller model.
  43803. */
  43804. static QUEST_MODEL_BASE_URL: string;
  43805. /**
  43806. * @hidden
  43807. * If the controllers are running on a device that needs the updated Quest controller models
  43808. */
  43809. static _IsQuest: boolean;
  43810. /**
  43811. * Fired when the secondary trigger on this controller is modified
  43812. */
  43813. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43814. /**
  43815. * Fired when the thumb rest on this controller is modified
  43816. */
  43817. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43818. /**
  43819. * Creates a new OculusTouchController from a gamepad
  43820. * @param vrGamepad the gamepad that the controller should be created from
  43821. */
  43822. constructor(vrGamepad: any);
  43823. /**
  43824. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43825. * @param scene scene in which to add meshes
  43826. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43827. */
  43828. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43829. /**
  43830. * Fired when the A button on this controller is modified
  43831. */
  43832. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43833. /**
  43834. * Fired when the B button on this controller is modified
  43835. */
  43836. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43837. /**
  43838. * Fired when the X button on this controller is modified
  43839. */
  43840. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43841. /**
  43842. * Fired when the Y button on this controller is modified
  43843. */
  43844. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43845. /**
  43846. * Called once for each button that changed state since the last frame
  43847. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43848. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43849. * 2) secondary trigger (same)
  43850. * 3) A (right) X (left), touch, pressed = value
  43851. * 4) B / Y
  43852. * 5) thumb rest
  43853. * @param buttonIdx Which button index changed
  43854. * @param state New state of the button
  43855. * @param changes Which properties on the state changed since last frame
  43856. */
  43857. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43858. }
  43859. }
  43860. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43861. import { Scene } from "babylonjs/scene";
  43862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43863. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43864. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43865. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43866. import { Observable } from "babylonjs/Misc/observable";
  43867. /**
  43868. * Vive Controller
  43869. */
  43870. export class ViveController extends WebVRController {
  43871. /**
  43872. * Base Url for the controller model.
  43873. */
  43874. static MODEL_BASE_URL: string;
  43875. /**
  43876. * File name for the controller model.
  43877. */
  43878. static MODEL_FILENAME: string;
  43879. /**
  43880. * Creates a new ViveController from a gamepad
  43881. * @param vrGamepad the gamepad that the controller should be created from
  43882. */
  43883. constructor(vrGamepad: any);
  43884. /**
  43885. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43886. * @param scene scene in which to add meshes
  43887. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43888. */
  43889. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43890. /**
  43891. * Fired when the left button on this controller is modified
  43892. */
  43893. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43894. /**
  43895. * Fired when the right button on this controller is modified
  43896. */
  43897. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43898. /**
  43899. * Fired when the menu button on this controller is modified
  43900. */
  43901. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43902. /**
  43903. * Called once for each button that changed state since the last frame
  43904. * Vive mapping:
  43905. * 0: touchpad
  43906. * 1: trigger
  43907. * 2: left AND right buttons
  43908. * 3: menu button
  43909. * @param buttonIdx Which button index changed
  43910. * @param state New state of the button
  43911. * @param changes Which properties on the state changed since last frame
  43912. */
  43913. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43914. }
  43915. }
  43916. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43917. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43918. /**
  43919. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43920. */
  43921. export class WebXRControllerModelLoader {
  43922. /**
  43923. * Creates the WebXRControllerModelLoader
  43924. * @param input xr input that creates the controllers
  43925. */
  43926. constructor(input: WebXRInput);
  43927. }
  43928. }
  43929. declare module "babylonjs/Cameras/XR/index" {
  43930. export * from "babylonjs/Cameras/XR/webXRCamera";
  43931. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43932. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43933. export * from "babylonjs/Cameras/XR/webXRInput";
  43934. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43935. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43936. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43937. export * from "babylonjs/Cameras/XR/webXRController";
  43938. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43939. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43940. }
  43941. declare module "babylonjs/Cameras/RigModes/index" {
  43942. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43943. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43944. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43945. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43946. }
  43947. declare module "babylonjs/Cameras/index" {
  43948. export * from "babylonjs/Cameras/Inputs/index";
  43949. export * from "babylonjs/Cameras/cameraInputsManager";
  43950. export * from "babylonjs/Cameras/camera";
  43951. export * from "babylonjs/Cameras/targetCamera";
  43952. export * from "babylonjs/Cameras/freeCamera";
  43953. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43954. export * from "babylonjs/Cameras/touchCamera";
  43955. export * from "babylonjs/Cameras/arcRotateCamera";
  43956. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43957. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43958. export * from "babylonjs/Cameras/flyCamera";
  43959. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43960. export * from "babylonjs/Cameras/followCamera";
  43961. export * from "babylonjs/Cameras/followCameraInputsManager";
  43962. export * from "babylonjs/Cameras/gamepadCamera";
  43963. export * from "babylonjs/Cameras/Stereoscopic/index";
  43964. export * from "babylonjs/Cameras/universalCamera";
  43965. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43966. export * from "babylonjs/Cameras/VR/index";
  43967. export * from "babylonjs/Cameras/XR/index";
  43968. export * from "babylonjs/Cameras/RigModes/index";
  43969. }
  43970. declare module "babylonjs/Collisions/index" {
  43971. export * from "babylonjs/Collisions/collider";
  43972. export * from "babylonjs/Collisions/collisionCoordinator";
  43973. export * from "babylonjs/Collisions/pickingInfo";
  43974. export * from "babylonjs/Collisions/intersectionInfo";
  43975. export * from "babylonjs/Collisions/meshCollisionData";
  43976. }
  43977. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43978. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43979. import { Vector3 } from "babylonjs/Maths/math.vector";
  43980. import { Ray } from "babylonjs/Culling/ray";
  43981. import { Plane } from "babylonjs/Maths/math.plane";
  43982. /**
  43983. * Contains an array of blocks representing the octree
  43984. */
  43985. export interface IOctreeContainer<T> {
  43986. /**
  43987. * Blocks within the octree
  43988. */
  43989. blocks: Array<OctreeBlock<T>>;
  43990. }
  43991. /**
  43992. * Class used to store a cell in an octree
  43993. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43994. */
  43995. export class OctreeBlock<T> {
  43996. /**
  43997. * Gets the content of the current block
  43998. */
  43999. entries: T[];
  44000. /**
  44001. * Gets the list of block children
  44002. */
  44003. blocks: Array<OctreeBlock<T>>;
  44004. private _depth;
  44005. private _maxDepth;
  44006. private _capacity;
  44007. private _minPoint;
  44008. private _maxPoint;
  44009. private _boundingVectors;
  44010. private _creationFunc;
  44011. /**
  44012. * Creates a new block
  44013. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44014. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44015. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44016. * @param depth defines the current depth of this block in the octree
  44017. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44018. * @param creationFunc defines a callback to call when an element is added to the block
  44019. */
  44020. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44021. /**
  44022. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44023. */
  44024. readonly capacity: number;
  44025. /**
  44026. * Gets the minimum vector (in world space) of the block's bounding box
  44027. */
  44028. readonly minPoint: Vector3;
  44029. /**
  44030. * Gets the maximum vector (in world space) of the block's bounding box
  44031. */
  44032. readonly maxPoint: Vector3;
  44033. /**
  44034. * Add a new element to this block
  44035. * @param entry defines the element to add
  44036. */
  44037. addEntry(entry: T): void;
  44038. /**
  44039. * Remove an element from this block
  44040. * @param entry defines the element to remove
  44041. */
  44042. removeEntry(entry: T): void;
  44043. /**
  44044. * Add an array of elements to this block
  44045. * @param entries defines the array of elements to add
  44046. */
  44047. addEntries(entries: T[]): void;
  44048. /**
  44049. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44050. * @param frustumPlanes defines the frustum planes to test
  44051. * @param selection defines the array to store current content if selection is positive
  44052. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44053. */
  44054. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44055. /**
  44056. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44057. * @param sphereCenter defines the bounding sphere center
  44058. * @param sphereRadius defines the bounding sphere radius
  44059. * @param selection defines the array to store current content if selection is positive
  44060. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44061. */
  44062. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44063. /**
  44064. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44065. * @param ray defines the ray to test with
  44066. * @param selection defines the array to store current content if selection is positive
  44067. */
  44068. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44069. /**
  44070. * Subdivide the content into child blocks (this block will then be empty)
  44071. */
  44072. createInnerBlocks(): void;
  44073. /**
  44074. * @hidden
  44075. */
  44076. 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;
  44077. }
  44078. }
  44079. declare module "babylonjs/Culling/Octrees/octree" {
  44080. import { SmartArray } from "babylonjs/Misc/smartArray";
  44081. import { Vector3 } from "babylonjs/Maths/math.vector";
  44082. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44084. import { Ray } from "babylonjs/Culling/ray";
  44085. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44086. import { Plane } from "babylonjs/Maths/math.plane";
  44087. /**
  44088. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44089. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44090. */
  44091. export class Octree<T> {
  44092. /** 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.) */
  44093. maxDepth: number;
  44094. /**
  44095. * Blocks within the octree containing objects
  44096. */
  44097. blocks: Array<OctreeBlock<T>>;
  44098. /**
  44099. * Content stored in the octree
  44100. */
  44101. dynamicContent: T[];
  44102. private _maxBlockCapacity;
  44103. private _selectionContent;
  44104. private _creationFunc;
  44105. /**
  44106. * Creates a octree
  44107. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44108. * @param creationFunc function to be used to instatiate the octree
  44109. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44110. * @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.)
  44111. */
  44112. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44113. /** 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.) */
  44114. maxDepth?: number);
  44115. /**
  44116. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44117. * @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);
  44118. * @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);
  44119. * @param entries meshes to be added to the octree blocks
  44120. */
  44121. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44122. /**
  44123. * Adds a mesh to the octree
  44124. * @param entry Mesh to add to the octree
  44125. */
  44126. addMesh(entry: T): void;
  44127. /**
  44128. * Remove an element from the octree
  44129. * @param entry defines the element to remove
  44130. */
  44131. removeMesh(entry: T): void;
  44132. /**
  44133. * Selects an array of meshes within the frustum
  44134. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44135. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44136. * @returns array of meshes within the frustum
  44137. */
  44138. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44139. /**
  44140. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44141. * @param sphereCenter defines the bounding sphere center
  44142. * @param sphereRadius defines the bounding sphere radius
  44143. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44144. * @returns an array of objects that intersect the sphere
  44145. */
  44146. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44147. /**
  44148. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44149. * @param ray defines the ray to test with
  44150. * @returns array of intersected objects
  44151. */
  44152. intersectsRay(ray: Ray): SmartArray<T>;
  44153. /**
  44154. * Adds a mesh into the octree block if it intersects the block
  44155. */
  44156. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44157. /**
  44158. * Adds a submesh into the octree block if it intersects the block
  44159. */
  44160. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44161. }
  44162. }
  44163. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44164. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44165. import { Scene } from "babylonjs/scene";
  44166. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44168. import { Ray } from "babylonjs/Culling/ray";
  44169. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44170. import { Collider } from "babylonjs/Collisions/collider";
  44171. module "babylonjs/scene" {
  44172. interface Scene {
  44173. /**
  44174. * @hidden
  44175. * Backing Filed
  44176. */
  44177. _selectionOctree: Octree<AbstractMesh>;
  44178. /**
  44179. * Gets the octree used to boost mesh selection (picking)
  44180. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44181. */
  44182. selectionOctree: Octree<AbstractMesh>;
  44183. /**
  44184. * Creates or updates the octree used to boost selection (picking)
  44185. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44186. * @param maxCapacity defines the maximum capacity per leaf
  44187. * @param maxDepth defines the maximum depth of the octree
  44188. * @returns an octree of AbstractMesh
  44189. */
  44190. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44191. }
  44192. }
  44193. module "babylonjs/Meshes/abstractMesh" {
  44194. interface AbstractMesh {
  44195. /**
  44196. * @hidden
  44197. * Backing Field
  44198. */
  44199. _submeshesOctree: Octree<SubMesh>;
  44200. /**
  44201. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44202. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44203. * @param maxCapacity defines the maximum size of each block (64 by default)
  44204. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44205. * @returns the new octree
  44206. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44207. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44208. */
  44209. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44210. }
  44211. }
  44212. /**
  44213. * Defines the octree scene component responsible to manage any octrees
  44214. * in a given scene.
  44215. */
  44216. export class OctreeSceneComponent {
  44217. /**
  44218. * The component name help to identify the component in the list of scene components.
  44219. */
  44220. readonly name: string;
  44221. /**
  44222. * The scene the component belongs to.
  44223. */
  44224. scene: Scene;
  44225. /**
  44226. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44227. */
  44228. readonly checksIsEnabled: boolean;
  44229. /**
  44230. * Creates a new instance of the component for the given scene
  44231. * @param scene Defines the scene to register the component in
  44232. */
  44233. constructor(scene: Scene);
  44234. /**
  44235. * Registers the component in a given scene
  44236. */
  44237. register(): void;
  44238. /**
  44239. * Return the list of active meshes
  44240. * @returns the list of active meshes
  44241. */
  44242. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44243. /**
  44244. * Return the list of active sub meshes
  44245. * @param mesh The mesh to get the candidates sub meshes from
  44246. * @returns the list of active sub meshes
  44247. */
  44248. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44249. private _tempRay;
  44250. /**
  44251. * Return the list of sub meshes intersecting with a given local ray
  44252. * @param mesh defines the mesh to find the submesh for
  44253. * @param localRay defines the ray in local space
  44254. * @returns the list of intersecting sub meshes
  44255. */
  44256. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44257. /**
  44258. * Return the list of sub meshes colliding with a collider
  44259. * @param mesh defines the mesh to find the submesh for
  44260. * @param collider defines the collider to evaluate the collision against
  44261. * @returns the list of colliding sub meshes
  44262. */
  44263. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44264. /**
  44265. * Rebuilds the elements related to this component in case of
  44266. * context lost for instance.
  44267. */
  44268. rebuild(): void;
  44269. /**
  44270. * Disposes the component and the associated ressources.
  44271. */
  44272. dispose(): void;
  44273. }
  44274. }
  44275. declare module "babylonjs/Culling/Octrees/index" {
  44276. export * from "babylonjs/Culling/Octrees/octree";
  44277. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44278. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44279. }
  44280. declare module "babylonjs/Culling/index" {
  44281. export * from "babylonjs/Culling/boundingBox";
  44282. export * from "babylonjs/Culling/boundingInfo";
  44283. export * from "babylonjs/Culling/boundingSphere";
  44284. export * from "babylonjs/Culling/Octrees/index";
  44285. export * from "babylonjs/Culling/ray";
  44286. }
  44287. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44288. import { IDisposable, Scene } from "babylonjs/scene";
  44289. import { Nullable } from "babylonjs/types";
  44290. import { Observable } from "babylonjs/Misc/observable";
  44291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44292. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44293. import { Camera } from "babylonjs/Cameras/camera";
  44294. /**
  44295. * Renders a layer on top of an existing scene
  44296. */
  44297. export class UtilityLayerRenderer implements IDisposable {
  44298. /** the original scene that will be rendered on top of */
  44299. originalScene: Scene;
  44300. private _pointerCaptures;
  44301. private _lastPointerEvents;
  44302. private static _DefaultUtilityLayer;
  44303. private static _DefaultKeepDepthUtilityLayer;
  44304. private _sharedGizmoLight;
  44305. private _renderCamera;
  44306. /**
  44307. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44308. * @returns the camera that is used when rendering the utility layer
  44309. */
  44310. getRenderCamera(): Nullable<Camera>;
  44311. /**
  44312. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44313. * @param cam the camera that should be used when rendering the utility layer
  44314. */
  44315. setRenderCamera(cam: Nullable<Camera>): void;
  44316. /**
  44317. * @hidden
  44318. * Light which used by gizmos to get light shading
  44319. */
  44320. _getSharedGizmoLight(): HemisphericLight;
  44321. /**
  44322. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44323. */
  44324. pickUtilitySceneFirst: boolean;
  44325. /**
  44326. * 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)
  44327. */
  44328. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44329. /**
  44330. * 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)
  44331. */
  44332. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44333. /**
  44334. * The scene that is rendered on top of the original scene
  44335. */
  44336. utilityLayerScene: Scene;
  44337. /**
  44338. * If the utility layer should automatically be rendered on top of existing scene
  44339. */
  44340. shouldRender: boolean;
  44341. /**
  44342. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44343. */
  44344. onlyCheckPointerDownEvents: boolean;
  44345. /**
  44346. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44347. */
  44348. processAllEvents: boolean;
  44349. /**
  44350. * Observable raised when the pointer move from the utility layer scene to the main scene
  44351. */
  44352. onPointerOutObservable: Observable<number>;
  44353. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44354. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44355. private _afterRenderObserver;
  44356. private _sceneDisposeObserver;
  44357. private _originalPointerObserver;
  44358. /**
  44359. * Instantiates a UtilityLayerRenderer
  44360. * @param originalScene the original scene that will be rendered on top of
  44361. * @param handleEvents boolean indicating if the utility layer should handle events
  44362. */
  44363. constructor(
  44364. /** the original scene that will be rendered on top of */
  44365. originalScene: Scene, handleEvents?: boolean);
  44366. private _notifyObservers;
  44367. /**
  44368. * Renders the utility layers scene on top of the original scene
  44369. */
  44370. render(): void;
  44371. /**
  44372. * Disposes of the renderer
  44373. */
  44374. dispose(): void;
  44375. private _updateCamera;
  44376. }
  44377. }
  44378. declare module "babylonjs/Gizmos/gizmo" {
  44379. import { Nullable } from "babylonjs/types";
  44380. import { IDisposable } from "babylonjs/scene";
  44381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44382. import { Mesh } from "babylonjs/Meshes/mesh";
  44383. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44384. /**
  44385. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44386. */
  44387. export class Gizmo implements IDisposable {
  44388. /** The utility layer the gizmo will be added to */
  44389. gizmoLayer: UtilityLayerRenderer;
  44390. /**
  44391. * The root mesh of the gizmo
  44392. */
  44393. _rootMesh: Mesh;
  44394. private _attachedMesh;
  44395. /**
  44396. * Ratio for the scale of the gizmo (Default: 1)
  44397. */
  44398. scaleRatio: number;
  44399. /**
  44400. * If a custom mesh has been set (Default: false)
  44401. */
  44402. protected _customMeshSet: boolean;
  44403. /**
  44404. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44405. * * When set, interactions will be enabled
  44406. */
  44407. attachedMesh: Nullable<AbstractMesh>;
  44408. /**
  44409. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44410. * @param mesh The mesh to replace the default mesh of the gizmo
  44411. */
  44412. setCustomMesh(mesh: Mesh): void;
  44413. /**
  44414. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44415. */
  44416. updateGizmoRotationToMatchAttachedMesh: boolean;
  44417. /**
  44418. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44419. */
  44420. updateGizmoPositionToMatchAttachedMesh: boolean;
  44421. /**
  44422. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44423. */
  44424. updateScale: boolean;
  44425. protected _interactionsEnabled: boolean;
  44426. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44427. private _beforeRenderObserver;
  44428. private _tempVector;
  44429. /**
  44430. * Creates a gizmo
  44431. * @param gizmoLayer The utility layer the gizmo will be added to
  44432. */
  44433. constructor(
  44434. /** The utility layer the gizmo will be added to */
  44435. gizmoLayer?: UtilityLayerRenderer);
  44436. /**
  44437. * Updates the gizmo to match the attached mesh's position/rotation
  44438. */
  44439. protected _update(): void;
  44440. /**
  44441. * Disposes of the gizmo
  44442. */
  44443. dispose(): void;
  44444. }
  44445. }
  44446. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44447. import { Observable } from "babylonjs/Misc/observable";
  44448. import { Nullable } from "babylonjs/types";
  44449. import { Vector3 } from "babylonjs/Maths/math.vector";
  44450. import { Color3 } from "babylonjs/Maths/math.color";
  44451. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44453. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44454. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44455. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44456. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44457. import { Scene } from "babylonjs/scene";
  44458. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44459. /**
  44460. * Single plane drag gizmo
  44461. */
  44462. export class PlaneDragGizmo extends Gizmo {
  44463. /**
  44464. * Drag behavior responsible for the gizmos dragging interactions
  44465. */
  44466. dragBehavior: PointerDragBehavior;
  44467. private _pointerObserver;
  44468. /**
  44469. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44470. */
  44471. snapDistance: number;
  44472. /**
  44473. * Event that fires each time the gizmo snaps to a new location.
  44474. * * snapDistance is the the change in distance
  44475. */
  44476. onSnapObservable: Observable<{
  44477. snapDistance: number;
  44478. }>;
  44479. private _plane;
  44480. private _coloredMaterial;
  44481. private _hoverMaterial;
  44482. private _isEnabled;
  44483. private _parent;
  44484. /** @hidden */
  44485. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44486. /** @hidden */
  44487. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44488. /**
  44489. * Creates a PlaneDragGizmo
  44490. * @param gizmoLayer The utility layer the gizmo will be added to
  44491. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44492. * @param color The color of the gizmo
  44493. */
  44494. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44495. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44496. /**
  44497. * If the gizmo is enabled
  44498. */
  44499. isEnabled: boolean;
  44500. /**
  44501. * Disposes of the gizmo
  44502. */
  44503. dispose(): void;
  44504. }
  44505. }
  44506. declare module "babylonjs/Gizmos/positionGizmo" {
  44507. import { Observable } from "babylonjs/Misc/observable";
  44508. import { Nullable } from "babylonjs/types";
  44509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44510. import { Mesh } from "babylonjs/Meshes/mesh";
  44511. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44512. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44513. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44514. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44515. /**
  44516. * Gizmo that enables dragging a mesh along 3 axis
  44517. */
  44518. export class PositionGizmo extends Gizmo {
  44519. /**
  44520. * Internal gizmo used for interactions on the x axis
  44521. */
  44522. xGizmo: AxisDragGizmo;
  44523. /**
  44524. * Internal gizmo used for interactions on the y axis
  44525. */
  44526. yGizmo: AxisDragGizmo;
  44527. /**
  44528. * Internal gizmo used for interactions on the z axis
  44529. */
  44530. zGizmo: AxisDragGizmo;
  44531. /**
  44532. * Internal gizmo used for interactions on the yz plane
  44533. */
  44534. xPlaneGizmo: PlaneDragGizmo;
  44535. /**
  44536. * Internal gizmo used for interactions on the xz plane
  44537. */
  44538. yPlaneGizmo: PlaneDragGizmo;
  44539. /**
  44540. * Internal gizmo used for interactions on the xy plane
  44541. */
  44542. zPlaneGizmo: PlaneDragGizmo;
  44543. /**
  44544. * private variables
  44545. */
  44546. private _meshAttached;
  44547. private _updateGizmoRotationToMatchAttachedMesh;
  44548. private _snapDistance;
  44549. private _scaleRatio;
  44550. /** Fires an event when any of it's sub gizmos are dragged */
  44551. onDragStartObservable: Observable<unknown>;
  44552. /** Fires an event when any of it's sub gizmos are released from dragging */
  44553. onDragEndObservable: Observable<unknown>;
  44554. /**
  44555. * If set to true, planar drag is enabled
  44556. */
  44557. private _planarGizmoEnabled;
  44558. attachedMesh: Nullable<AbstractMesh>;
  44559. /**
  44560. * Creates a PositionGizmo
  44561. * @param gizmoLayer The utility layer the gizmo will be added to
  44562. */
  44563. constructor(gizmoLayer?: UtilityLayerRenderer);
  44564. /**
  44565. * If the planar drag gizmo is enabled
  44566. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44567. */
  44568. planarGizmoEnabled: boolean;
  44569. updateGizmoRotationToMatchAttachedMesh: boolean;
  44570. /**
  44571. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44572. */
  44573. snapDistance: number;
  44574. /**
  44575. * Ratio for the scale of the gizmo (Default: 1)
  44576. */
  44577. scaleRatio: number;
  44578. /**
  44579. * Disposes of the gizmo
  44580. */
  44581. dispose(): void;
  44582. /**
  44583. * CustomMeshes are not supported by this gizmo
  44584. * @param mesh The mesh to replace the default mesh of the gizmo
  44585. */
  44586. setCustomMesh(mesh: Mesh): void;
  44587. }
  44588. }
  44589. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44590. import { Observable } from "babylonjs/Misc/observable";
  44591. import { Nullable } from "babylonjs/types";
  44592. import { Vector3 } from "babylonjs/Maths/math.vector";
  44593. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44595. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44596. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44597. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44598. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44599. import { Scene } from "babylonjs/scene";
  44600. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44601. import { Color3 } from "babylonjs/Maths/math.color";
  44602. /**
  44603. * Single axis drag gizmo
  44604. */
  44605. export class AxisDragGizmo extends Gizmo {
  44606. /**
  44607. * Drag behavior responsible for the gizmos dragging interactions
  44608. */
  44609. dragBehavior: PointerDragBehavior;
  44610. private _pointerObserver;
  44611. /**
  44612. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44613. */
  44614. snapDistance: number;
  44615. /**
  44616. * Event that fires each time the gizmo snaps to a new location.
  44617. * * snapDistance is the the change in distance
  44618. */
  44619. onSnapObservable: Observable<{
  44620. snapDistance: number;
  44621. }>;
  44622. private _isEnabled;
  44623. private _parent;
  44624. private _arrow;
  44625. private _coloredMaterial;
  44626. private _hoverMaterial;
  44627. /** @hidden */
  44628. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44629. /** @hidden */
  44630. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44631. /**
  44632. * Creates an AxisDragGizmo
  44633. * @param gizmoLayer The utility layer the gizmo will be added to
  44634. * @param dragAxis The axis which the gizmo will be able to drag on
  44635. * @param color The color of the gizmo
  44636. */
  44637. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44638. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44639. /**
  44640. * If the gizmo is enabled
  44641. */
  44642. isEnabled: boolean;
  44643. /**
  44644. * Disposes of the gizmo
  44645. */
  44646. dispose(): void;
  44647. }
  44648. }
  44649. declare module "babylonjs/Debug/axesViewer" {
  44650. import { Vector3 } from "babylonjs/Maths/math.vector";
  44651. import { Nullable } from "babylonjs/types";
  44652. import { Scene } from "babylonjs/scene";
  44653. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44654. /**
  44655. * The Axes viewer will show 3 axes in a specific point in space
  44656. */
  44657. export class AxesViewer {
  44658. private _xAxis;
  44659. private _yAxis;
  44660. private _zAxis;
  44661. private _scaleLinesFactor;
  44662. private _instanced;
  44663. /**
  44664. * Gets the hosting scene
  44665. */
  44666. scene: Scene;
  44667. /**
  44668. * Gets or sets a number used to scale line length
  44669. */
  44670. scaleLines: number;
  44671. /** Gets the node hierarchy used to render x-axis */
  44672. readonly xAxis: TransformNode;
  44673. /** Gets the node hierarchy used to render y-axis */
  44674. readonly yAxis: TransformNode;
  44675. /** Gets the node hierarchy used to render z-axis */
  44676. readonly zAxis: TransformNode;
  44677. /**
  44678. * Creates a new AxesViewer
  44679. * @param scene defines the hosting scene
  44680. * @param scaleLines defines a number used to scale line length (1 by default)
  44681. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44682. * @param xAxis defines the node hierarchy used to render the x-axis
  44683. * @param yAxis defines the node hierarchy used to render the y-axis
  44684. * @param zAxis defines the node hierarchy used to render the z-axis
  44685. */
  44686. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44687. /**
  44688. * Force the viewer to update
  44689. * @param position defines the position of the viewer
  44690. * @param xaxis defines the x axis of the viewer
  44691. * @param yaxis defines the y axis of the viewer
  44692. * @param zaxis defines the z axis of the viewer
  44693. */
  44694. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44695. /**
  44696. * Creates an instance of this axes viewer.
  44697. * @returns a new axes viewer with instanced meshes
  44698. */
  44699. createInstance(): AxesViewer;
  44700. /** Releases resources */
  44701. dispose(): void;
  44702. private static _SetRenderingGroupId;
  44703. }
  44704. }
  44705. declare module "babylonjs/Debug/boneAxesViewer" {
  44706. import { Nullable } from "babylonjs/types";
  44707. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44708. import { Vector3 } from "babylonjs/Maths/math.vector";
  44709. import { Mesh } from "babylonjs/Meshes/mesh";
  44710. import { Bone } from "babylonjs/Bones/bone";
  44711. import { Scene } from "babylonjs/scene";
  44712. /**
  44713. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44714. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44715. */
  44716. export class BoneAxesViewer extends AxesViewer {
  44717. /**
  44718. * Gets or sets the target mesh where to display the axes viewer
  44719. */
  44720. mesh: Nullable<Mesh>;
  44721. /**
  44722. * Gets or sets the target bone where to display the axes viewer
  44723. */
  44724. bone: Nullable<Bone>;
  44725. /** Gets current position */
  44726. pos: Vector3;
  44727. /** Gets direction of X axis */
  44728. xaxis: Vector3;
  44729. /** Gets direction of Y axis */
  44730. yaxis: Vector3;
  44731. /** Gets direction of Z axis */
  44732. zaxis: Vector3;
  44733. /**
  44734. * Creates a new BoneAxesViewer
  44735. * @param scene defines the hosting scene
  44736. * @param bone defines the target bone
  44737. * @param mesh defines the target mesh
  44738. * @param scaleLines defines a scaling factor for line length (1 by default)
  44739. */
  44740. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44741. /**
  44742. * Force the viewer to update
  44743. */
  44744. update(): void;
  44745. /** Releases resources */
  44746. dispose(): void;
  44747. }
  44748. }
  44749. declare module "babylonjs/Debug/debugLayer" {
  44750. import { Scene } from "babylonjs/scene";
  44751. /**
  44752. * Interface used to define scene explorer extensibility option
  44753. */
  44754. export interface IExplorerExtensibilityOption {
  44755. /**
  44756. * Define the option label
  44757. */
  44758. label: string;
  44759. /**
  44760. * Defines the action to execute on click
  44761. */
  44762. action: (entity: any) => void;
  44763. }
  44764. /**
  44765. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44766. */
  44767. export interface IExplorerExtensibilityGroup {
  44768. /**
  44769. * Defines a predicate to test if a given type mut be extended
  44770. */
  44771. predicate: (entity: any) => boolean;
  44772. /**
  44773. * Gets the list of options added to a type
  44774. */
  44775. entries: IExplorerExtensibilityOption[];
  44776. }
  44777. /**
  44778. * Interface used to define the options to use to create the Inspector
  44779. */
  44780. export interface IInspectorOptions {
  44781. /**
  44782. * Display in overlay mode (default: false)
  44783. */
  44784. overlay?: boolean;
  44785. /**
  44786. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44787. */
  44788. globalRoot?: HTMLElement;
  44789. /**
  44790. * Display the Scene explorer
  44791. */
  44792. showExplorer?: boolean;
  44793. /**
  44794. * Display the property inspector
  44795. */
  44796. showInspector?: boolean;
  44797. /**
  44798. * Display in embed mode (both panes on the right)
  44799. */
  44800. embedMode?: boolean;
  44801. /**
  44802. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44803. */
  44804. handleResize?: boolean;
  44805. /**
  44806. * Allow the panes to popup (default: true)
  44807. */
  44808. enablePopup?: boolean;
  44809. /**
  44810. * Allow the panes to be closed by users (default: true)
  44811. */
  44812. enableClose?: boolean;
  44813. /**
  44814. * Optional list of extensibility entries
  44815. */
  44816. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44817. /**
  44818. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44819. */
  44820. inspectorURL?: string;
  44821. }
  44822. module "babylonjs/scene" {
  44823. interface Scene {
  44824. /**
  44825. * @hidden
  44826. * Backing field
  44827. */
  44828. _debugLayer: DebugLayer;
  44829. /**
  44830. * Gets the debug layer (aka Inspector) associated with the scene
  44831. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44832. */
  44833. debugLayer: DebugLayer;
  44834. }
  44835. }
  44836. /**
  44837. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44838. * what is happening in your scene
  44839. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44840. */
  44841. export class DebugLayer {
  44842. /**
  44843. * Define the url to get the inspector script from.
  44844. * By default it uses the babylonjs CDN.
  44845. * @ignoreNaming
  44846. */
  44847. static InspectorURL: string;
  44848. private _scene;
  44849. private BJSINSPECTOR;
  44850. private _onPropertyChangedObservable?;
  44851. /**
  44852. * Observable triggered when a property is changed through the inspector.
  44853. */
  44854. readonly onPropertyChangedObservable: any;
  44855. /**
  44856. * Instantiates a new debug layer.
  44857. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44858. * what is happening in your scene
  44859. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44860. * @param scene Defines the scene to inspect
  44861. */
  44862. constructor(scene: Scene);
  44863. /** Creates the inspector window. */
  44864. private _createInspector;
  44865. /**
  44866. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44867. * @param entity defines the entity to select
  44868. * @param lineContainerTitle defines the specific block to highlight
  44869. */
  44870. select(entity: any, lineContainerTitle?: string): void;
  44871. /** Get the inspector from bundle or global */
  44872. private _getGlobalInspector;
  44873. /**
  44874. * Get if the inspector is visible or not.
  44875. * @returns true if visible otherwise, false
  44876. */
  44877. isVisible(): boolean;
  44878. /**
  44879. * Hide the inspector and close its window.
  44880. */
  44881. hide(): void;
  44882. /**
  44883. * Launch the debugLayer.
  44884. * @param config Define the configuration of the inspector
  44885. * @return a promise fulfilled when the debug layer is visible
  44886. */
  44887. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44888. }
  44889. }
  44890. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44891. import { Nullable } from "babylonjs/types";
  44892. import { Scene } from "babylonjs/scene";
  44893. import { Vector4 } from "babylonjs/Maths/math.vector";
  44894. import { Color4 } from "babylonjs/Maths/math.color";
  44895. import { Mesh } from "babylonjs/Meshes/mesh";
  44896. /**
  44897. * Class containing static functions to help procedurally build meshes
  44898. */
  44899. export class BoxBuilder {
  44900. /**
  44901. * Creates a box mesh
  44902. * * The parameter `size` sets the size (float) of each box side (default 1)
  44903. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44904. * * 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)
  44905. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44907. * * 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
  44908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44909. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44910. * @param name defines the name of the mesh
  44911. * @param options defines the options used to create the mesh
  44912. * @param scene defines the hosting scene
  44913. * @returns the box mesh
  44914. */
  44915. static CreateBox(name: string, options: {
  44916. size?: number;
  44917. width?: number;
  44918. height?: number;
  44919. depth?: number;
  44920. faceUV?: Vector4[];
  44921. faceColors?: Color4[];
  44922. sideOrientation?: number;
  44923. frontUVs?: Vector4;
  44924. backUVs?: Vector4;
  44925. wrap?: boolean;
  44926. topBaseAt?: number;
  44927. bottomBaseAt?: number;
  44928. updatable?: boolean;
  44929. }, scene?: Nullable<Scene>): Mesh;
  44930. }
  44931. }
  44932. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44933. import { Vector4 } from "babylonjs/Maths/math.vector";
  44934. import { Mesh } from "babylonjs/Meshes/mesh";
  44935. import { Scene } from "babylonjs/scene";
  44936. import { Nullable } from "babylonjs/types";
  44937. /**
  44938. * Class containing static functions to help procedurally build meshes
  44939. */
  44940. export class SphereBuilder {
  44941. /**
  44942. * Creates a sphere mesh
  44943. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44944. * * 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`)
  44945. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44946. * * 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
  44947. * * 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)
  44948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44949. * * 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
  44950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44951. * @param name defines the name of the mesh
  44952. * @param options defines the options used to create the mesh
  44953. * @param scene defines the hosting scene
  44954. * @returns the sphere mesh
  44955. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44956. */
  44957. static CreateSphere(name: string, options: {
  44958. segments?: number;
  44959. diameter?: number;
  44960. diameterX?: number;
  44961. diameterY?: number;
  44962. diameterZ?: number;
  44963. arc?: number;
  44964. slice?: number;
  44965. sideOrientation?: number;
  44966. frontUVs?: Vector4;
  44967. backUVs?: Vector4;
  44968. updatable?: boolean;
  44969. }, scene?: Nullable<Scene>): Mesh;
  44970. }
  44971. }
  44972. declare module "babylonjs/Debug/physicsViewer" {
  44973. import { Nullable } from "babylonjs/types";
  44974. import { Scene } from "babylonjs/scene";
  44975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44976. import { Mesh } from "babylonjs/Meshes/mesh";
  44977. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44978. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44979. /**
  44980. * Used to show the physics impostor around the specific mesh
  44981. */
  44982. export class PhysicsViewer {
  44983. /** @hidden */
  44984. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44985. /** @hidden */
  44986. protected _meshes: Array<Nullable<AbstractMesh>>;
  44987. /** @hidden */
  44988. protected _scene: Nullable<Scene>;
  44989. /** @hidden */
  44990. protected _numMeshes: number;
  44991. /** @hidden */
  44992. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44993. private _renderFunction;
  44994. private _utilityLayer;
  44995. private _debugBoxMesh;
  44996. private _debugSphereMesh;
  44997. private _debugCylinderMesh;
  44998. private _debugMaterial;
  44999. private _debugMeshMeshes;
  45000. /**
  45001. * Creates a new PhysicsViewer
  45002. * @param scene defines the hosting scene
  45003. */
  45004. constructor(scene: Scene);
  45005. /** @hidden */
  45006. protected _updateDebugMeshes(): void;
  45007. /**
  45008. * Renders a specified physic impostor
  45009. * @param impostor defines the impostor to render
  45010. * @param targetMesh defines the mesh represented by the impostor
  45011. * @returns the new debug mesh used to render the impostor
  45012. */
  45013. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45014. /**
  45015. * Hides a specified physic impostor
  45016. * @param impostor defines the impostor to hide
  45017. */
  45018. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45019. private _getDebugMaterial;
  45020. private _getDebugBoxMesh;
  45021. private _getDebugSphereMesh;
  45022. private _getDebugCylinderMesh;
  45023. private _getDebugMeshMesh;
  45024. private _getDebugMesh;
  45025. /** Releases all resources */
  45026. dispose(): void;
  45027. }
  45028. }
  45029. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45030. import { Vector3 } from "babylonjs/Maths/math.vector";
  45031. import { Color4 } from "babylonjs/Maths/math.color";
  45032. import { Nullable } from "babylonjs/types";
  45033. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45034. import { Scene } from "babylonjs/scene";
  45035. /**
  45036. * Class containing static functions to help procedurally build meshes
  45037. */
  45038. export class LinesBuilder {
  45039. /**
  45040. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45041. * * 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
  45042. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45043. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45044. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45045. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45046. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45047. * * 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
  45048. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45050. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45051. * @param name defines the name of the new line system
  45052. * @param options defines the options used to create the line system
  45053. * @param scene defines the hosting scene
  45054. * @returns a new line system mesh
  45055. */
  45056. static CreateLineSystem(name: string, options: {
  45057. lines: Vector3[][];
  45058. updatable?: boolean;
  45059. instance?: Nullable<LinesMesh>;
  45060. colors?: Nullable<Color4[][]>;
  45061. useVertexAlpha?: boolean;
  45062. }, scene: Nullable<Scene>): LinesMesh;
  45063. /**
  45064. * Creates a line mesh
  45065. * 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
  45066. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45067. * * The parameter `points` is an array successive Vector3
  45068. * * 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
  45069. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45070. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45071. * * When updating an instance, remember that only point positions can change, not the number of points
  45072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45073. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45074. * @param name defines the name of the new line system
  45075. * @param options defines the options used to create the line system
  45076. * @param scene defines the hosting scene
  45077. * @returns a new line mesh
  45078. */
  45079. static CreateLines(name: string, options: {
  45080. points: Vector3[];
  45081. updatable?: boolean;
  45082. instance?: Nullable<LinesMesh>;
  45083. colors?: Color4[];
  45084. useVertexAlpha?: boolean;
  45085. }, scene?: Nullable<Scene>): LinesMesh;
  45086. /**
  45087. * Creates a dashed line mesh
  45088. * * 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
  45089. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45090. * * The parameter `points` is an array successive Vector3
  45091. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45092. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45093. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45094. * * 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
  45095. * * When updating an instance, remember that only point positions can change, not the number of points
  45096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45097. * @param name defines the name of the mesh
  45098. * @param options defines the options used to create the mesh
  45099. * @param scene defines the hosting scene
  45100. * @returns the dashed line mesh
  45101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45102. */
  45103. static CreateDashedLines(name: string, options: {
  45104. points: Vector3[];
  45105. dashSize?: number;
  45106. gapSize?: number;
  45107. dashNb?: number;
  45108. updatable?: boolean;
  45109. instance?: LinesMesh;
  45110. }, scene?: Nullable<Scene>): LinesMesh;
  45111. }
  45112. }
  45113. declare module "babylonjs/Debug/rayHelper" {
  45114. import { Nullable } from "babylonjs/types";
  45115. import { Ray } from "babylonjs/Culling/ray";
  45116. import { Vector3 } from "babylonjs/Maths/math.vector";
  45117. import { Color3 } from "babylonjs/Maths/math.color";
  45118. import { Scene } from "babylonjs/scene";
  45119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45120. import "babylonjs/Meshes/Builders/linesBuilder";
  45121. /**
  45122. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45123. * in order to better appreciate the issue one might have.
  45124. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45125. */
  45126. export class RayHelper {
  45127. /**
  45128. * Defines the ray we are currently tryin to visualize.
  45129. */
  45130. ray: Nullable<Ray>;
  45131. private _renderPoints;
  45132. private _renderLine;
  45133. private _renderFunction;
  45134. private _scene;
  45135. private _updateToMeshFunction;
  45136. private _attachedToMesh;
  45137. private _meshSpaceDirection;
  45138. private _meshSpaceOrigin;
  45139. /**
  45140. * Helper function to create a colored helper in a scene in one line.
  45141. * @param ray Defines the ray we are currently tryin to visualize
  45142. * @param scene Defines the scene the ray is used in
  45143. * @param color Defines the color we want to see the ray in
  45144. * @returns The newly created ray helper.
  45145. */
  45146. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45147. /**
  45148. * Instantiate a new ray helper.
  45149. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45150. * in order to better appreciate the issue one might have.
  45151. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45152. * @param ray Defines the ray we are currently tryin to visualize
  45153. */
  45154. constructor(ray: Ray);
  45155. /**
  45156. * Shows the ray we are willing to debug.
  45157. * @param scene Defines the scene the ray needs to be rendered in
  45158. * @param color Defines the color the ray needs to be rendered in
  45159. */
  45160. show(scene: Scene, color?: Color3): void;
  45161. /**
  45162. * Hides the ray we are debugging.
  45163. */
  45164. hide(): void;
  45165. private _render;
  45166. /**
  45167. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45168. * @param mesh Defines the mesh we want the helper attached to
  45169. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45170. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45171. * @param length Defines the length of the ray
  45172. */
  45173. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45174. /**
  45175. * Detach the ray helper from the mesh it has previously been attached to.
  45176. */
  45177. detachFromMesh(): void;
  45178. private _updateToMesh;
  45179. /**
  45180. * Dispose the helper and release its associated resources.
  45181. */
  45182. dispose(): void;
  45183. }
  45184. }
  45185. declare module "babylonjs/Debug/skeletonViewer" {
  45186. import { Color3 } from "babylonjs/Maths/math.color";
  45187. import { Scene } from "babylonjs/scene";
  45188. import { Nullable } from "babylonjs/types";
  45189. import { Skeleton } from "babylonjs/Bones/skeleton";
  45190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45191. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45192. /**
  45193. * Class used to render a debug view of a given skeleton
  45194. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45195. */
  45196. export class SkeletonViewer {
  45197. /** defines the skeleton to render */
  45198. skeleton: Skeleton;
  45199. /** defines the mesh attached to the skeleton */
  45200. mesh: AbstractMesh;
  45201. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45202. autoUpdateBonesMatrices: boolean;
  45203. /** defines the rendering group id to use with the viewer */
  45204. renderingGroupId: number;
  45205. /** Gets or sets the color used to render the skeleton */
  45206. color: Color3;
  45207. private _scene;
  45208. private _debugLines;
  45209. private _debugMesh;
  45210. private _isEnabled;
  45211. private _renderFunction;
  45212. private _utilityLayer;
  45213. /**
  45214. * Returns the mesh used to render the bones
  45215. */
  45216. readonly debugMesh: Nullable<LinesMesh>;
  45217. /**
  45218. * Creates a new SkeletonViewer
  45219. * @param skeleton defines the skeleton to render
  45220. * @param mesh defines the mesh attached to the skeleton
  45221. * @param scene defines the hosting scene
  45222. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45223. * @param renderingGroupId defines the rendering group id to use with the viewer
  45224. */
  45225. constructor(
  45226. /** defines the skeleton to render */
  45227. skeleton: Skeleton,
  45228. /** defines the mesh attached to the skeleton */
  45229. mesh: AbstractMesh, scene: Scene,
  45230. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45231. autoUpdateBonesMatrices?: boolean,
  45232. /** defines the rendering group id to use with the viewer */
  45233. renderingGroupId?: number);
  45234. /** Gets or sets a boolean indicating if the viewer is enabled */
  45235. isEnabled: boolean;
  45236. private _getBonePosition;
  45237. private _getLinesForBonesWithLength;
  45238. private _getLinesForBonesNoLength;
  45239. /** Update the viewer to sync with current skeleton state */
  45240. update(): void;
  45241. /** Release associated resources */
  45242. dispose(): void;
  45243. }
  45244. }
  45245. declare module "babylonjs/Debug/index" {
  45246. export * from "babylonjs/Debug/axesViewer";
  45247. export * from "babylonjs/Debug/boneAxesViewer";
  45248. export * from "babylonjs/Debug/debugLayer";
  45249. export * from "babylonjs/Debug/physicsViewer";
  45250. export * from "babylonjs/Debug/rayHelper";
  45251. export * from "babylonjs/Debug/skeletonViewer";
  45252. }
  45253. declare module "babylonjs/Engines/nullEngine" {
  45254. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45255. import { Scene } from "babylonjs/scene";
  45256. import { Engine } from "babylonjs/Engines/engine";
  45257. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45258. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45259. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45260. import { Effect } from "babylonjs/Materials/effect";
  45261. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45262. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45263. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45264. /**
  45265. * Options to create the null engine
  45266. */
  45267. export class NullEngineOptions {
  45268. /**
  45269. * Render width (Default: 512)
  45270. */
  45271. renderWidth: number;
  45272. /**
  45273. * Render height (Default: 256)
  45274. */
  45275. renderHeight: number;
  45276. /**
  45277. * Texture size (Default: 512)
  45278. */
  45279. textureSize: number;
  45280. /**
  45281. * If delta time between frames should be constant
  45282. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45283. */
  45284. deterministicLockstep: boolean;
  45285. /**
  45286. * Maximum about of steps between frames (Default: 4)
  45287. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45288. */
  45289. lockstepMaxSteps: number;
  45290. }
  45291. /**
  45292. * The null engine class provides support for headless version of babylon.js.
  45293. * This can be used in server side scenario or for testing purposes
  45294. */
  45295. export class NullEngine extends Engine {
  45296. private _options;
  45297. /**
  45298. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45299. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45300. * @returns true if engine is in deterministic lock step mode
  45301. */
  45302. isDeterministicLockStep(): boolean;
  45303. /**
  45304. * Gets the max steps when engine is running in deterministic lock step
  45305. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45306. * @returns the max steps
  45307. */
  45308. getLockstepMaxSteps(): number;
  45309. /**
  45310. * Gets the current hardware scaling level.
  45311. * By default the hardware scaling level is computed from the window device ratio.
  45312. * 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.
  45313. * @returns a number indicating the current hardware scaling level
  45314. */
  45315. getHardwareScalingLevel(): number;
  45316. constructor(options?: NullEngineOptions);
  45317. /**
  45318. * Creates a vertex buffer
  45319. * @param vertices the data for the vertex buffer
  45320. * @returns the new WebGL static buffer
  45321. */
  45322. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45323. /**
  45324. * Creates a new index buffer
  45325. * @param indices defines the content of the index buffer
  45326. * @param updatable defines if the index buffer must be updatable
  45327. * @returns a new webGL buffer
  45328. */
  45329. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45330. /**
  45331. * Clear the current render buffer or the current render target (if any is set up)
  45332. * @param color defines the color to use
  45333. * @param backBuffer defines if the back buffer must be cleared
  45334. * @param depth defines if the depth buffer must be cleared
  45335. * @param stencil defines if the stencil buffer must be cleared
  45336. */
  45337. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45338. /**
  45339. * Gets the current render width
  45340. * @param useScreen defines if screen size must be used (or the current render target if any)
  45341. * @returns a number defining the current render width
  45342. */
  45343. getRenderWidth(useScreen?: boolean): number;
  45344. /**
  45345. * Gets the current render height
  45346. * @param useScreen defines if screen size must be used (or the current render target if any)
  45347. * @returns a number defining the current render height
  45348. */
  45349. getRenderHeight(useScreen?: boolean): number;
  45350. /**
  45351. * Set the WebGL's viewport
  45352. * @param viewport defines the viewport element to be used
  45353. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45354. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45355. */
  45356. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45357. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45358. /**
  45359. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45360. * @param pipelineContext defines the pipeline context to use
  45361. * @param uniformsNames defines the list of uniform names
  45362. * @returns an array of webGL uniform locations
  45363. */
  45364. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45365. /**
  45366. * Gets the lsit of active attributes for a given webGL program
  45367. * @param pipelineContext defines the pipeline context to use
  45368. * @param attributesNames defines the list of attribute names to get
  45369. * @returns an array of indices indicating the offset of each attribute
  45370. */
  45371. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45372. /**
  45373. * Binds an effect to the webGL context
  45374. * @param effect defines the effect to bind
  45375. */
  45376. bindSamplers(effect: Effect): void;
  45377. /**
  45378. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45379. * @param effect defines the effect to activate
  45380. */
  45381. enableEffect(effect: Effect): void;
  45382. /**
  45383. * Set various states to the webGL context
  45384. * @param culling defines backface culling state
  45385. * @param zOffset defines the value to apply to zOffset (0 by default)
  45386. * @param force defines if states must be applied even if cache is up to date
  45387. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45388. */
  45389. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45390. /**
  45391. * Set the value of an uniform to an array of int32
  45392. * @param uniform defines the webGL uniform location where to store the value
  45393. * @param array defines the array of int32 to store
  45394. */
  45395. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45396. /**
  45397. * Set the value of an uniform to an array of int32 (stored as vec2)
  45398. * @param uniform defines the webGL uniform location where to store the value
  45399. * @param array defines the array of int32 to store
  45400. */
  45401. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45402. /**
  45403. * Set the value of an uniform to an array of int32 (stored as vec3)
  45404. * @param uniform defines the webGL uniform location where to store the value
  45405. * @param array defines the array of int32 to store
  45406. */
  45407. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45408. /**
  45409. * Set the value of an uniform to an array of int32 (stored as vec4)
  45410. * @param uniform defines the webGL uniform location where to store the value
  45411. * @param array defines the array of int32 to store
  45412. */
  45413. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45414. /**
  45415. * Set the value of an uniform to an array of float32
  45416. * @param uniform defines the webGL uniform location where to store the value
  45417. * @param array defines the array of float32 to store
  45418. */
  45419. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45420. /**
  45421. * Set the value of an uniform to an array of float32 (stored as vec2)
  45422. * @param uniform defines the webGL uniform location where to store the value
  45423. * @param array defines the array of float32 to store
  45424. */
  45425. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45426. /**
  45427. * Set the value of an uniform to an array of float32 (stored as vec3)
  45428. * @param uniform defines the webGL uniform location where to store the value
  45429. * @param array defines the array of float32 to store
  45430. */
  45431. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45432. /**
  45433. * Set the value of an uniform to an array of float32 (stored as vec4)
  45434. * @param uniform defines the webGL uniform location where to store the value
  45435. * @param array defines the array of float32 to store
  45436. */
  45437. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45438. /**
  45439. * Set the value of an uniform to an array of number
  45440. * @param uniform defines the webGL uniform location where to store the value
  45441. * @param array defines the array of number to store
  45442. */
  45443. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45444. /**
  45445. * Set the value of an uniform to an array of number (stored as vec2)
  45446. * @param uniform defines the webGL uniform location where to store the value
  45447. * @param array defines the array of number to store
  45448. */
  45449. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45450. /**
  45451. * Set the value of an uniform to an array of number (stored as vec3)
  45452. * @param uniform defines the webGL uniform location where to store the value
  45453. * @param array defines the array of number to store
  45454. */
  45455. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45456. /**
  45457. * Set the value of an uniform to an array of number (stored as vec4)
  45458. * @param uniform defines the webGL uniform location where to store the value
  45459. * @param array defines the array of number to store
  45460. */
  45461. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45462. /**
  45463. * Set the value of an uniform to an array of float32 (stored as matrices)
  45464. * @param uniform defines the webGL uniform location where to store the value
  45465. * @param matrices defines the array of float32 to store
  45466. */
  45467. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45468. /**
  45469. * Set the value of an uniform to a matrix (3x3)
  45470. * @param uniform defines the webGL uniform location where to store the value
  45471. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45472. */
  45473. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45474. /**
  45475. * Set the value of an uniform to a matrix (2x2)
  45476. * @param uniform defines the webGL uniform location where to store the value
  45477. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45478. */
  45479. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45480. /**
  45481. * Set the value of an uniform to a number (float)
  45482. * @param uniform defines the webGL uniform location where to store the value
  45483. * @param value defines the float number to store
  45484. */
  45485. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45486. /**
  45487. * Set the value of an uniform to a vec2
  45488. * @param uniform defines the webGL uniform location where to store the value
  45489. * @param x defines the 1st component of the value
  45490. * @param y defines the 2nd component of the value
  45491. */
  45492. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45493. /**
  45494. * Set the value of an uniform to a vec3
  45495. * @param uniform defines the webGL uniform location where to store the value
  45496. * @param x defines the 1st component of the value
  45497. * @param y defines the 2nd component of the value
  45498. * @param z defines the 3rd component of the value
  45499. */
  45500. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45501. /**
  45502. * Set the value of an uniform to a boolean
  45503. * @param uniform defines the webGL uniform location where to store the value
  45504. * @param bool defines the boolean to store
  45505. */
  45506. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45507. /**
  45508. * Set the value of an uniform to a vec4
  45509. * @param uniform defines the webGL uniform location where to store the value
  45510. * @param x defines the 1st component of the value
  45511. * @param y defines the 2nd component of the value
  45512. * @param z defines the 3rd component of the value
  45513. * @param w defines the 4th component of the value
  45514. */
  45515. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45516. /**
  45517. * Sets the current alpha mode
  45518. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45519. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45520. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45521. */
  45522. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45523. /**
  45524. * Bind webGl buffers directly to the webGL context
  45525. * @param vertexBuffers defines the vertex buffer to bind
  45526. * @param indexBuffer defines the index buffer to bind
  45527. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45528. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45529. * @param effect defines the effect associated with the vertex buffer
  45530. */
  45531. bindBuffers(vertexBuffers: {
  45532. [key: string]: VertexBuffer;
  45533. }, indexBuffer: DataBuffer, effect: Effect): void;
  45534. /**
  45535. * Force the entire cache to be cleared
  45536. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45537. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45538. */
  45539. wipeCaches(bruteForce?: boolean): void;
  45540. /**
  45541. * Send a draw order
  45542. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45543. * @param indexStart defines the starting index
  45544. * @param indexCount defines the number of index to draw
  45545. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45546. */
  45547. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45548. /**
  45549. * Draw a list of indexed primitives
  45550. * @param fillMode defines the primitive to use
  45551. * @param indexStart defines the starting index
  45552. * @param indexCount defines the number of index to draw
  45553. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45554. */
  45555. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45556. /**
  45557. * Draw a list of unindexed primitives
  45558. * @param fillMode defines the primitive to use
  45559. * @param verticesStart defines the index of first vertex to draw
  45560. * @param verticesCount defines the count of vertices to draw
  45561. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45562. */
  45563. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45564. /** @hidden */
  45565. _createTexture(): WebGLTexture;
  45566. /** @hidden */
  45567. _releaseTexture(texture: InternalTexture): void;
  45568. /**
  45569. * Usually called from Texture.ts.
  45570. * Passed information to create a WebGLTexture
  45571. * @param urlArg defines a value which contains one of the following:
  45572. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45573. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45574. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45575. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45576. * @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)
  45577. * @param scene needed for loading to the correct scene
  45578. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45579. * @param onLoad optional callback to be called upon successful completion
  45580. * @param onError optional callback to be called upon failure
  45581. * @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
  45582. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45583. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45584. * @param forcedExtension defines the extension to use to pick the right loader
  45585. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45586. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45587. */
  45588. 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;
  45589. /**
  45590. * Creates a new render target texture
  45591. * @param size defines the size of the texture
  45592. * @param options defines the options used to create the texture
  45593. * @returns a new render target texture stored in an InternalTexture
  45594. */
  45595. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45596. /**
  45597. * Update the sampling mode of a given texture
  45598. * @param samplingMode defines the required sampling mode
  45599. * @param texture defines the texture to update
  45600. */
  45601. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45602. /**
  45603. * Binds the frame buffer to the specified texture.
  45604. * @param texture The texture to render to or null for the default canvas
  45605. * @param faceIndex The face of the texture to render to in case of cube texture
  45606. * @param requiredWidth The width of the target to render to
  45607. * @param requiredHeight The height of the target to render to
  45608. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45609. * @param depthStencilTexture The depth stencil texture to use to render
  45610. * @param lodLevel defines le lod level to bind to the frame buffer
  45611. */
  45612. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45613. /**
  45614. * Unbind the current render target texture from the webGL context
  45615. * @param texture defines the render target texture to unbind
  45616. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45617. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45618. */
  45619. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45620. /**
  45621. * Creates a dynamic vertex buffer
  45622. * @param vertices the data for the dynamic vertex buffer
  45623. * @returns the new WebGL dynamic buffer
  45624. */
  45625. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45626. /**
  45627. * Update the content of a dynamic texture
  45628. * @param texture defines the texture to update
  45629. * @param canvas defines the canvas containing the source
  45630. * @param invertY defines if data must be stored with Y axis inverted
  45631. * @param premulAlpha defines if alpha is stored as premultiplied
  45632. * @param format defines the format of the data
  45633. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45634. */
  45635. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45636. /**
  45637. * Gets a boolean indicating if all created effects are ready
  45638. * @returns true if all effects are ready
  45639. */
  45640. areAllEffectsReady(): boolean;
  45641. /**
  45642. * @hidden
  45643. * Get the current error code of the webGL context
  45644. * @returns the error code
  45645. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45646. */
  45647. getError(): number;
  45648. /** @hidden */
  45649. _getUnpackAlignement(): number;
  45650. /** @hidden */
  45651. _unpackFlipY(value: boolean): void;
  45652. /**
  45653. * Update a dynamic index buffer
  45654. * @param indexBuffer defines the target index buffer
  45655. * @param indices defines the data to update
  45656. * @param offset defines the offset in the target index buffer where update should start
  45657. */
  45658. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45659. /**
  45660. * Updates a dynamic vertex buffer.
  45661. * @param vertexBuffer the vertex buffer to update
  45662. * @param vertices the data used to update the vertex buffer
  45663. * @param byteOffset the byte offset of the data (optional)
  45664. * @param byteLength the byte length of the data (optional)
  45665. */
  45666. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45667. /** @hidden */
  45668. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45669. /** @hidden */
  45670. _bindTexture(channel: number, texture: InternalTexture): void;
  45671. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45672. /**
  45673. * 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
  45674. */
  45675. releaseEffects(): void;
  45676. displayLoadingUI(): void;
  45677. hideLoadingUI(): void;
  45678. /** @hidden */
  45679. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45680. /** @hidden */
  45681. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45682. /** @hidden */
  45683. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45684. /** @hidden */
  45685. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45686. }
  45687. }
  45688. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45689. import { Nullable, int } from "babylonjs/types";
  45690. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45691. /** @hidden */
  45692. export class _OcclusionDataStorage {
  45693. /** @hidden */
  45694. occlusionInternalRetryCounter: number;
  45695. /** @hidden */
  45696. isOcclusionQueryInProgress: boolean;
  45697. /** @hidden */
  45698. isOccluded: boolean;
  45699. /** @hidden */
  45700. occlusionRetryCount: number;
  45701. /** @hidden */
  45702. occlusionType: number;
  45703. /** @hidden */
  45704. occlusionQueryAlgorithmType: number;
  45705. }
  45706. module "babylonjs/Engines/engine" {
  45707. interface Engine {
  45708. /**
  45709. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45710. * @return the new query
  45711. */
  45712. createQuery(): WebGLQuery;
  45713. /**
  45714. * Delete and release a webGL query
  45715. * @param query defines the query to delete
  45716. * @return the current engine
  45717. */
  45718. deleteQuery(query: WebGLQuery): Engine;
  45719. /**
  45720. * Check if a given query has resolved and got its value
  45721. * @param query defines the query to check
  45722. * @returns true if the query got its value
  45723. */
  45724. isQueryResultAvailable(query: WebGLQuery): boolean;
  45725. /**
  45726. * Gets the value of a given query
  45727. * @param query defines the query to check
  45728. * @returns the value of the query
  45729. */
  45730. getQueryResult(query: WebGLQuery): number;
  45731. /**
  45732. * Initiates an occlusion query
  45733. * @param algorithmType defines the algorithm to use
  45734. * @param query defines the query to use
  45735. * @returns the current engine
  45736. * @see http://doc.babylonjs.com/features/occlusionquery
  45737. */
  45738. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45739. /**
  45740. * Ends an occlusion query
  45741. * @see http://doc.babylonjs.com/features/occlusionquery
  45742. * @param algorithmType defines the algorithm to use
  45743. * @returns the current engine
  45744. */
  45745. endOcclusionQuery(algorithmType: number): Engine;
  45746. /**
  45747. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45748. * Please note that only one query can be issued at a time
  45749. * @returns a time token used to track the time span
  45750. */
  45751. startTimeQuery(): Nullable<_TimeToken>;
  45752. /**
  45753. * Ends a time query
  45754. * @param token defines the token used to measure the time span
  45755. * @returns the time spent (in ns)
  45756. */
  45757. endTimeQuery(token: _TimeToken): int;
  45758. /** @hidden */
  45759. _currentNonTimestampToken: Nullable<_TimeToken>;
  45760. /** @hidden */
  45761. _createTimeQuery(): WebGLQuery;
  45762. /** @hidden */
  45763. _deleteTimeQuery(query: WebGLQuery): void;
  45764. /** @hidden */
  45765. _getGlAlgorithmType(algorithmType: number): number;
  45766. /** @hidden */
  45767. _getTimeQueryResult(query: WebGLQuery): any;
  45768. /** @hidden */
  45769. _getTimeQueryAvailability(query: WebGLQuery): any;
  45770. }
  45771. }
  45772. module "babylonjs/Meshes/abstractMesh" {
  45773. interface AbstractMesh {
  45774. /**
  45775. * Backing filed
  45776. * @hidden
  45777. */
  45778. __occlusionDataStorage: _OcclusionDataStorage;
  45779. /**
  45780. * Access property
  45781. * @hidden
  45782. */
  45783. _occlusionDataStorage: _OcclusionDataStorage;
  45784. /**
  45785. * 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.
  45786. * The default value is -1 which means don't break the query and wait till the result
  45787. * @see http://doc.babylonjs.com/features/occlusionquery
  45788. */
  45789. occlusionRetryCount: number;
  45790. /**
  45791. * 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:
  45792. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45793. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45794. * * 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.
  45795. * @see http://doc.babylonjs.com/features/occlusionquery
  45796. */
  45797. occlusionType: number;
  45798. /**
  45799. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45800. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45801. * * 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.
  45802. * @see http://doc.babylonjs.com/features/occlusionquery
  45803. */
  45804. occlusionQueryAlgorithmType: number;
  45805. /**
  45806. * 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
  45807. * @see http://doc.babylonjs.com/features/occlusionquery
  45808. */
  45809. isOccluded: boolean;
  45810. /**
  45811. * Flag to check the progress status of the query
  45812. * @see http://doc.babylonjs.com/features/occlusionquery
  45813. */
  45814. isOcclusionQueryInProgress: boolean;
  45815. }
  45816. }
  45817. }
  45818. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45819. import { Nullable } from "babylonjs/types";
  45820. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45821. /** @hidden */
  45822. export var _forceTransformFeedbackToBundle: boolean;
  45823. module "babylonjs/Engines/engine" {
  45824. interface Engine {
  45825. /**
  45826. * Creates a webGL transform feedback object
  45827. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45828. * @returns the webGL transform feedback object
  45829. */
  45830. createTransformFeedback(): WebGLTransformFeedback;
  45831. /**
  45832. * Delete a webGL transform feedback object
  45833. * @param value defines the webGL transform feedback object to delete
  45834. */
  45835. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45836. /**
  45837. * Bind a webGL transform feedback object to the webgl context
  45838. * @param value defines the webGL transform feedback object to bind
  45839. */
  45840. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45841. /**
  45842. * Begins a transform feedback operation
  45843. * @param usePoints defines if points or triangles must be used
  45844. */
  45845. beginTransformFeedback(usePoints: boolean): void;
  45846. /**
  45847. * Ends a transform feedback operation
  45848. */
  45849. endTransformFeedback(): void;
  45850. /**
  45851. * Specify the varyings to use with transform feedback
  45852. * @param program defines the associated webGL program
  45853. * @param value defines the list of strings representing the varying names
  45854. */
  45855. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45856. /**
  45857. * Bind a webGL buffer for a transform feedback operation
  45858. * @param value defines the webGL buffer to bind
  45859. */
  45860. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45861. }
  45862. }
  45863. }
  45864. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45865. import { Scene } from "babylonjs/scene";
  45866. import { Engine } from "babylonjs/Engines/engine";
  45867. import { Texture } from "babylonjs/Materials/Textures/texture";
  45868. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45869. import "babylonjs/Engines/Extensions/engine.multiRender";
  45870. /**
  45871. * Creation options of the multi render target texture.
  45872. */
  45873. export interface IMultiRenderTargetOptions {
  45874. /**
  45875. * Define if the texture needs to create mip maps after render.
  45876. */
  45877. generateMipMaps?: boolean;
  45878. /**
  45879. * Define the types of all the draw buffers we want to create
  45880. */
  45881. types?: number[];
  45882. /**
  45883. * Define the sampling modes of all the draw buffers we want to create
  45884. */
  45885. samplingModes?: number[];
  45886. /**
  45887. * Define if a depth buffer is required
  45888. */
  45889. generateDepthBuffer?: boolean;
  45890. /**
  45891. * Define if a stencil buffer is required
  45892. */
  45893. generateStencilBuffer?: boolean;
  45894. /**
  45895. * Define if a depth texture is required instead of a depth buffer
  45896. */
  45897. generateDepthTexture?: boolean;
  45898. /**
  45899. * Define the number of desired draw buffers
  45900. */
  45901. textureCount?: number;
  45902. /**
  45903. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45904. */
  45905. doNotChangeAspectRatio?: boolean;
  45906. /**
  45907. * Define the default type of the buffers we are creating
  45908. */
  45909. defaultType?: number;
  45910. }
  45911. /**
  45912. * A multi render target, like a render target provides the ability to render to a texture.
  45913. * Unlike the render target, it can render to several draw buffers in one draw.
  45914. * This is specially interesting in deferred rendering or for any effects requiring more than
  45915. * just one color from a single pass.
  45916. */
  45917. export class MultiRenderTarget extends RenderTargetTexture {
  45918. private _internalTextures;
  45919. private _textures;
  45920. private _multiRenderTargetOptions;
  45921. /**
  45922. * Get if draw buffers are currently supported by the used hardware and browser.
  45923. */
  45924. readonly isSupported: boolean;
  45925. /**
  45926. * Get the list of textures generated by the multi render target.
  45927. */
  45928. readonly textures: Texture[];
  45929. /**
  45930. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45931. */
  45932. readonly depthTexture: Texture;
  45933. /**
  45934. * Set the wrapping mode on U of all the textures we are rendering to.
  45935. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45936. */
  45937. wrapU: number;
  45938. /**
  45939. * Set the wrapping mode on V of all the textures we are rendering to.
  45940. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45941. */
  45942. wrapV: number;
  45943. /**
  45944. * Instantiate a new multi render target texture.
  45945. * A multi render target, like a render target provides the ability to render to a texture.
  45946. * Unlike the render target, it can render to several draw buffers in one draw.
  45947. * This is specially interesting in deferred rendering or for any effects requiring more than
  45948. * just one color from a single pass.
  45949. * @param name Define the name of the texture
  45950. * @param size Define the size of the buffers to render to
  45951. * @param count Define the number of target we are rendering into
  45952. * @param scene Define the scene the texture belongs to
  45953. * @param options Define the options used to create the multi render target
  45954. */
  45955. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45956. /** @hidden */
  45957. _rebuild(): void;
  45958. private _createInternalTextures;
  45959. private _createTextures;
  45960. /**
  45961. * Define the number of samples used if MSAA is enabled.
  45962. */
  45963. samples: number;
  45964. /**
  45965. * Resize all the textures in the multi render target.
  45966. * Be carrefull as it will recreate all the data in the new texture.
  45967. * @param size Define the new size
  45968. */
  45969. resize(size: any): void;
  45970. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45971. /**
  45972. * Dispose the render targets and their associated resources
  45973. */
  45974. dispose(): void;
  45975. /**
  45976. * Release all the underlying texture used as draw buffers.
  45977. */
  45978. releaseInternalTextures(): void;
  45979. }
  45980. }
  45981. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45982. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45983. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45984. import { Nullable } from "babylonjs/types";
  45985. module "babylonjs/Engines/thinEngine" {
  45986. interface ThinEngine {
  45987. /**
  45988. * Unbind a list of render target textures from the webGL context
  45989. * This is used only when drawBuffer extension or webGL2 are active
  45990. * @param textures defines the render target textures to unbind
  45991. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45992. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45993. */
  45994. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45995. /**
  45996. * Create a multi render target texture
  45997. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45998. * @param size defines the size of the texture
  45999. * @param options defines the creation options
  46000. * @returns the cube texture as an InternalTexture
  46001. */
  46002. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46003. /**
  46004. * Update the sample count for a given multiple render target texture
  46005. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46006. * @param textures defines the textures to update
  46007. * @param samples defines the sample count to set
  46008. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46009. */
  46010. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46011. }
  46012. }
  46013. }
  46014. declare module "babylonjs/Engines/Extensions/index" {
  46015. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46016. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46017. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46018. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46019. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46020. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46021. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46022. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46023. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46024. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46025. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46026. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46027. }
  46028. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46029. import { Nullable } from "babylonjs/types";
  46030. /**
  46031. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46032. */
  46033. export interface CubeMapInfo {
  46034. /**
  46035. * The pixel array for the front face.
  46036. * This is stored in format, left to right, up to down format.
  46037. */
  46038. front: Nullable<ArrayBufferView>;
  46039. /**
  46040. * The pixel array for the back face.
  46041. * This is stored in format, left to right, up to down format.
  46042. */
  46043. back: Nullable<ArrayBufferView>;
  46044. /**
  46045. * The pixel array for the left face.
  46046. * This is stored in format, left to right, up to down format.
  46047. */
  46048. left: Nullable<ArrayBufferView>;
  46049. /**
  46050. * The pixel array for the right face.
  46051. * This is stored in format, left to right, up to down format.
  46052. */
  46053. right: Nullable<ArrayBufferView>;
  46054. /**
  46055. * The pixel array for the up face.
  46056. * This is stored in format, left to right, up to down format.
  46057. */
  46058. up: Nullable<ArrayBufferView>;
  46059. /**
  46060. * The pixel array for the down face.
  46061. * This is stored in format, left to right, up to down format.
  46062. */
  46063. down: Nullable<ArrayBufferView>;
  46064. /**
  46065. * The size of the cubemap stored.
  46066. *
  46067. * Each faces will be size * size pixels.
  46068. */
  46069. size: number;
  46070. /**
  46071. * The format of the texture.
  46072. *
  46073. * RGBA, RGB.
  46074. */
  46075. format: number;
  46076. /**
  46077. * The type of the texture data.
  46078. *
  46079. * UNSIGNED_INT, FLOAT.
  46080. */
  46081. type: number;
  46082. /**
  46083. * Specifies whether the texture is in gamma space.
  46084. */
  46085. gammaSpace: boolean;
  46086. }
  46087. /**
  46088. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46089. */
  46090. export class PanoramaToCubeMapTools {
  46091. private static FACE_FRONT;
  46092. private static FACE_BACK;
  46093. private static FACE_RIGHT;
  46094. private static FACE_LEFT;
  46095. private static FACE_DOWN;
  46096. private static FACE_UP;
  46097. /**
  46098. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46099. *
  46100. * @param float32Array The source data.
  46101. * @param inputWidth The width of the input panorama.
  46102. * @param inputHeight The height of the input panorama.
  46103. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46104. * @return The cubemap data
  46105. */
  46106. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46107. private static CreateCubemapTexture;
  46108. private static CalcProjectionSpherical;
  46109. }
  46110. }
  46111. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46112. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46113. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46114. import { Nullable } from "babylonjs/types";
  46115. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46116. /**
  46117. * Helper class dealing with the extraction of spherical polynomial dataArray
  46118. * from a cube map.
  46119. */
  46120. export class CubeMapToSphericalPolynomialTools {
  46121. private static FileFaces;
  46122. /**
  46123. * Converts a texture to the according Spherical Polynomial data.
  46124. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46125. *
  46126. * @param texture The texture to extract the information from.
  46127. * @return The Spherical Polynomial data.
  46128. */
  46129. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46130. /**
  46131. * Converts a cubemap to the according Spherical Polynomial data.
  46132. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46133. *
  46134. * @param cubeInfo The Cube map to extract the information from.
  46135. * @return The Spherical Polynomial data.
  46136. */
  46137. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46138. }
  46139. }
  46140. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46141. import { Nullable } from "babylonjs/types";
  46142. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46143. module "babylonjs/Materials/Textures/baseTexture" {
  46144. interface BaseTexture {
  46145. /**
  46146. * Get the polynomial representation of the texture data.
  46147. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46148. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46149. */
  46150. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46151. }
  46152. }
  46153. }
  46154. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46155. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46156. /** @hidden */
  46157. export var rgbdEncodePixelShader: {
  46158. name: string;
  46159. shader: string;
  46160. };
  46161. }
  46162. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46163. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46164. /** @hidden */
  46165. export var rgbdDecodePixelShader: {
  46166. name: string;
  46167. shader: string;
  46168. };
  46169. }
  46170. declare module "babylonjs/Misc/environmentTextureTools" {
  46171. import { Nullable } from "babylonjs/types";
  46172. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46173. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46174. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46175. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46176. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46177. import "babylonjs/Shaders/rgbdEncode.fragment";
  46178. import "babylonjs/Shaders/rgbdDecode.fragment";
  46179. /**
  46180. * Raw texture data and descriptor sufficient for WebGL texture upload
  46181. */
  46182. export interface EnvironmentTextureInfo {
  46183. /**
  46184. * Version of the environment map
  46185. */
  46186. version: number;
  46187. /**
  46188. * Width of image
  46189. */
  46190. width: number;
  46191. /**
  46192. * Irradiance information stored in the file.
  46193. */
  46194. irradiance: any;
  46195. /**
  46196. * Specular information stored in the file.
  46197. */
  46198. specular: any;
  46199. }
  46200. /**
  46201. * Defines One Image in the file. It requires only the position in the file
  46202. * as well as the length.
  46203. */
  46204. interface BufferImageData {
  46205. /**
  46206. * Length of the image data.
  46207. */
  46208. length: number;
  46209. /**
  46210. * Position of the data from the null terminator delimiting the end of the JSON.
  46211. */
  46212. position: number;
  46213. }
  46214. /**
  46215. * Defines the specular data enclosed in the file.
  46216. * This corresponds to the version 1 of the data.
  46217. */
  46218. export interface EnvironmentTextureSpecularInfoV1 {
  46219. /**
  46220. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46221. */
  46222. specularDataPosition?: number;
  46223. /**
  46224. * This contains all the images data needed to reconstruct the cubemap.
  46225. */
  46226. mipmaps: Array<BufferImageData>;
  46227. /**
  46228. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46229. */
  46230. lodGenerationScale: number;
  46231. }
  46232. /**
  46233. * Sets of helpers addressing the serialization and deserialization of environment texture
  46234. * stored in a BabylonJS env file.
  46235. * Those files are usually stored as .env files.
  46236. */
  46237. export class EnvironmentTextureTools {
  46238. /**
  46239. * Magic number identifying the env file.
  46240. */
  46241. private static _MagicBytes;
  46242. /**
  46243. * Gets the environment info from an env file.
  46244. * @param data The array buffer containing the .env bytes.
  46245. * @returns the environment file info (the json header) if successfully parsed.
  46246. */
  46247. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46248. /**
  46249. * Creates an environment texture from a loaded cube texture.
  46250. * @param texture defines the cube texture to convert in env file
  46251. * @return a promise containing the environment data if succesfull.
  46252. */
  46253. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46254. /**
  46255. * Creates a JSON representation of the spherical data.
  46256. * @param texture defines the texture containing the polynomials
  46257. * @return the JSON representation of the spherical info
  46258. */
  46259. private static _CreateEnvTextureIrradiance;
  46260. /**
  46261. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46262. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46263. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46264. * @return the views described by info providing access to the underlying buffer
  46265. */
  46266. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46267. /**
  46268. * Uploads the texture info contained in the env file to the GPU.
  46269. * @param texture defines the internal texture to upload to
  46270. * @param arrayBuffer defines the buffer cotaining the data to load
  46271. * @param info defines the texture info retrieved through the GetEnvInfo method
  46272. * @returns a promise
  46273. */
  46274. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46275. /**
  46276. * Uploads the levels of image data to the GPU.
  46277. * @param texture defines the internal texture to upload to
  46278. * @param imageData defines the array buffer views of image data [mipmap][face]
  46279. * @returns a promise
  46280. */
  46281. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46282. /**
  46283. * Uploads spherical polynomials information to the texture.
  46284. * @param texture defines the texture we are trying to upload the information to
  46285. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46286. */
  46287. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46288. /** @hidden */
  46289. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46290. }
  46291. }
  46292. declare module "babylonjs/Maths/math.vertexFormat" {
  46293. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46294. /**
  46295. * Contains position and normal vectors for a vertex
  46296. */
  46297. export class PositionNormalVertex {
  46298. /** the position of the vertex (defaut: 0,0,0) */
  46299. position: Vector3;
  46300. /** the normal of the vertex (defaut: 0,1,0) */
  46301. normal: Vector3;
  46302. /**
  46303. * Creates a PositionNormalVertex
  46304. * @param position the position of the vertex (defaut: 0,0,0)
  46305. * @param normal the normal of the vertex (defaut: 0,1,0)
  46306. */
  46307. constructor(
  46308. /** the position of the vertex (defaut: 0,0,0) */
  46309. position?: Vector3,
  46310. /** the normal of the vertex (defaut: 0,1,0) */
  46311. normal?: Vector3);
  46312. /**
  46313. * Clones the PositionNormalVertex
  46314. * @returns the cloned PositionNormalVertex
  46315. */
  46316. clone(): PositionNormalVertex;
  46317. }
  46318. /**
  46319. * Contains position, normal and uv vectors for a vertex
  46320. */
  46321. export class PositionNormalTextureVertex {
  46322. /** the position of the vertex (defaut: 0,0,0) */
  46323. position: Vector3;
  46324. /** the normal of the vertex (defaut: 0,1,0) */
  46325. normal: Vector3;
  46326. /** the uv of the vertex (default: 0,0) */
  46327. uv: Vector2;
  46328. /**
  46329. * Creates a PositionNormalTextureVertex
  46330. * @param position the position of the vertex (defaut: 0,0,0)
  46331. * @param normal the normal of the vertex (defaut: 0,1,0)
  46332. * @param uv the uv of the vertex (default: 0,0)
  46333. */
  46334. constructor(
  46335. /** the position of the vertex (defaut: 0,0,0) */
  46336. position?: Vector3,
  46337. /** the normal of the vertex (defaut: 0,1,0) */
  46338. normal?: Vector3,
  46339. /** the uv of the vertex (default: 0,0) */
  46340. uv?: Vector2);
  46341. /**
  46342. * Clones the PositionNormalTextureVertex
  46343. * @returns the cloned PositionNormalTextureVertex
  46344. */
  46345. clone(): PositionNormalTextureVertex;
  46346. }
  46347. }
  46348. declare module "babylonjs/Maths/math" {
  46349. export * from "babylonjs/Maths/math.axis";
  46350. export * from "babylonjs/Maths/math.color";
  46351. export * from "babylonjs/Maths/math.constants";
  46352. export * from "babylonjs/Maths/math.frustum";
  46353. export * from "babylonjs/Maths/math.path";
  46354. export * from "babylonjs/Maths/math.plane";
  46355. export * from "babylonjs/Maths/math.size";
  46356. export * from "babylonjs/Maths/math.vector";
  46357. export * from "babylonjs/Maths/math.vertexFormat";
  46358. export * from "babylonjs/Maths/math.viewport";
  46359. }
  46360. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46361. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46362. /** @hidden */
  46363. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46364. private _genericAttributeLocation;
  46365. private _varyingLocationCount;
  46366. private _varyingLocationMap;
  46367. private _replacements;
  46368. private _textureCount;
  46369. private _uniforms;
  46370. lineProcessor(line: string): string;
  46371. attributeProcessor(attribute: string): string;
  46372. varyingProcessor(varying: string, isFragment: boolean): string;
  46373. uniformProcessor(uniform: string): string;
  46374. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46375. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46376. }
  46377. }
  46378. declare module "babylonjs/Engines/nativeEngine" {
  46379. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46380. import { Engine } from "babylonjs/Engines/engine";
  46381. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46383. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46384. import { Effect } from "babylonjs/Materials/effect";
  46385. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46386. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46387. import { Scene } from "babylonjs/scene";
  46388. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46389. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46390. /**
  46391. * Container for accessors for natively-stored mesh data buffers.
  46392. */
  46393. class NativeDataBuffer extends DataBuffer {
  46394. /**
  46395. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46396. */
  46397. nativeIndexBuffer?: any;
  46398. /**
  46399. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46400. */
  46401. nativeVertexBuffer?: any;
  46402. }
  46403. /** @hidden */
  46404. export class NativeEngine extends Engine {
  46405. private readonly _native;
  46406. getHardwareScalingLevel(): number;
  46407. constructor();
  46408. /**
  46409. * Can be used to override the current requestAnimationFrame requester.
  46410. * @hidden
  46411. */
  46412. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46413. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46414. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46415. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46416. recordVertexArrayObject(vertexBuffers: {
  46417. [key: string]: VertexBuffer;
  46418. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46419. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46420. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46421. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46422. /**
  46423. * Draw a list of indexed primitives
  46424. * @param fillMode defines the primitive to use
  46425. * @param indexStart defines the starting index
  46426. * @param indexCount defines the number of index to draw
  46427. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46428. */
  46429. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46430. /**
  46431. * Draw a list of unindexed primitives
  46432. * @param fillMode defines the primitive to use
  46433. * @param verticesStart defines the index of first vertex to draw
  46434. * @param verticesCount defines the count of vertices to draw
  46435. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46436. */
  46437. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46438. createPipelineContext(): IPipelineContext;
  46439. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46440. /** @hidden */
  46441. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46442. /** @hidden */
  46443. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46444. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46445. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46446. protected _setProgram(program: WebGLProgram): void;
  46447. _releaseEffect(effect: Effect): void;
  46448. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46449. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46450. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46451. bindSamplers(effect: Effect): void;
  46452. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46453. getRenderWidth(useScreen?: boolean): number;
  46454. getRenderHeight(useScreen?: boolean): number;
  46455. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46456. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46457. /**
  46458. * Set the z offset to apply to current rendering
  46459. * @param value defines the offset to apply
  46460. */
  46461. setZOffset(value: number): void;
  46462. /**
  46463. * Gets the current value of the zOffset
  46464. * @returns the current zOffset state
  46465. */
  46466. getZOffset(): number;
  46467. /**
  46468. * Enable or disable depth buffering
  46469. * @param enable defines the state to set
  46470. */
  46471. setDepthBuffer(enable: boolean): void;
  46472. /**
  46473. * Gets a boolean indicating if depth writing is enabled
  46474. * @returns the current depth writing state
  46475. */
  46476. getDepthWrite(): boolean;
  46477. /**
  46478. * Enable or disable depth writing
  46479. * @param enable defines the state to set
  46480. */
  46481. setDepthWrite(enable: boolean): void;
  46482. /**
  46483. * Enable or disable color writing
  46484. * @param enable defines the state to set
  46485. */
  46486. setColorWrite(enable: boolean): void;
  46487. /**
  46488. * Gets a boolean indicating if color writing is enabled
  46489. * @returns the current color writing state
  46490. */
  46491. getColorWrite(): boolean;
  46492. /**
  46493. * Sets alpha constants used by some alpha blending modes
  46494. * @param r defines the red component
  46495. * @param g defines the green component
  46496. * @param b defines the blue component
  46497. * @param a defines the alpha component
  46498. */
  46499. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46500. /**
  46501. * Sets the current alpha mode
  46502. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46503. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46504. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46505. */
  46506. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46507. /**
  46508. * Gets the current alpha mode
  46509. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46510. * @returns the current alpha mode
  46511. */
  46512. getAlphaMode(): number;
  46513. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46514. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46515. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46516. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46517. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46518. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46519. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46520. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46521. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46522. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46523. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46524. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46525. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46526. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46527. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46528. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46529. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46530. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46531. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46532. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46533. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46534. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46535. wipeCaches(bruteForce?: boolean): void;
  46536. _createTexture(): WebGLTexture;
  46537. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46538. /**
  46539. * Usually called from BABYLON.Texture.ts.
  46540. * Passed information to create a WebGLTexture
  46541. * @param urlArg defines a value which contains one of the following:
  46542. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46543. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46544. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46545. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46546. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46547. * @param scene needed for loading to the correct scene
  46548. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46549. * @param onLoad optional callback to be called upon successful completion
  46550. * @param onError optional callback to be called upon failure
  46551. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46552. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46553. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46554. * @param forcedExtension defines the extension to use to pick the right loader
  46555. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46556. */
  46557. 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;
  46558. /**
  46559. * Creates a cube texture
  46560. * @param rootUrl defines the url where the files to load is located
  46561. * @param scene defines the current scene
  46562. * @param files defines the list of files to load (1 per face)
  46563. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46564. * @param onLoad defines an optional callback raised when the texture is loaded
  46565. * @param onError defines an optional callback raised if there is an issue to load the texture
  46566. * @param format defines the format of the data
  46567. * @param forcedExtension defines the extension to use to pick the right loader
  46568. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46569. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46570. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46571. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46572. * @returns the cube texture as an InternalTexture
  46573. */
  46574. 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;
  46575. private _getSamplingFilter;
  46576. private static _GetNativeTextureFormat;
  46577. createRenderTargetTexture(size: number | {
  46578. width: number;
  46579. height: number;
  46580. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46581. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46582. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46583. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46584. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46585. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46586. /**
  46587. * Updates a dynamic vertex buffer.
  46588. * @param vertexBuffer the vertex buffer to update
  46589. * @param data the data used to update the vertex buffer
  46590. * @param byteOffset the byte offset of the data (optional)
  46591. * @param byteLength the byte length of the data (optional)
  46592. */
  46593. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46594. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46595. private _updateAnisotropicLevel;
  46596. private _getAddressMode;
  46597. /** @hidden */
  46598. _bindTexture(channel: number, texture: InternalTexture): void;
  46599. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46600. releaseEffects(): void;
  46601. /** @hidden */
  46602. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46603. /** @hidden */
  46604. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46605. /** @hidden */
  46606. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46607. /** @hidden */
  46608. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46609. }
  46610. }
  46611. declare module "babylonjs/Engines/index" {
  46612. export * from "babylonjs/Engines/constants";
  46613. export * from "babylonjs/Engines/engineCapabilities";
  46614. export * from "babylonjs/Engines/instancingAttributeInfo";
  46615. export * from "babylonjs/Engines/thinEngine";
  46616. export * from "babylonjs/Engines/engine";
  46617. export * from "babylonjs/Engines/engineStore";
  46618. export * from "babylonjs/Engines/nullEngine";
  46619. export * from "babylonjs/Engines/Extensions/index";
  46620. export * from "babylonjs/Engines/IPipelineContext";
  46621. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46622. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46623. export * from "babylonjs/Engines/nativeEngine";
  46624. }
  46625. declare module "babylonjs/Events/clipboardEvents" {
  46626. /**
  46627. * Gather the list of clipboard event types as constants.
  46628. */
  46629. export class ClipboardEventTypes {
  46630. /**
  46631. * The clipboard event is fired when a copy command is active (pressed).
  46632. */
  46633. static readonly COPY: number;
  46634. /**
  46635. * The clipboard event is fired when a cut command is active (pressed).
  46636. */
  46637. static readonly CUT: number;
  46638. /**
  46639. * The clipboard event is fired when a paste command is active (pressed).
  46640. */
  46641. static readonly PASTE: number;
  46642. }
  46643. /**
  46644. * This class is used to store clipboard related info for the onClipboardObservable event.
  46645. */
  46646. export class ClipboardInfo {
  46647. /**
  46648. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46649. */
  46650. type: number;
  46651. /**
  46652. * Defines the related dom event
  46653. */
  46654. event: ClipboardEvent;
  46655. /**
  46656. *Creates an instance of ClipboardInfo.
  46657. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46658. * @param event Defines the related dom event
  46659. */
  46660. constructor(
  46661. /**
  46662. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46663. */
  46664. type: number,
  46665. /**
  46666. * Defines the related dom event
  46667. */
  46668. event: ClipboardEvent);
  46669. /**
  46670. * Get the clipboard event's type from the keycode.
  46671. * @param keyCode Defines the keyCode for the current keyboard event.
  46672. * @return {number}
  46673. */
  46674. static GetTypeFromCharacter(keyCode: number): number;
  46675. }
  46676. }
  46677. declare module "babylonjs/Events/index" {
  46678. export * from "babylonjs/Events/keyboardEvents";
  46679. export * from "babylonjs/Events/pointerEvents";
  46680. export * from "babylonjs/Events/clipboardEvents";
  46681. }
  46682. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46683. import { Scene } from "babylonjs/scene";
  46684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46685. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46686. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46687. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46688. /**
  46689. * Google Daydream controller
  46690. */
  46691. export class DaydreamController extends WebVRController {
  46692. /**
  46693. * Base Url for the controller model.
  46694. */
  46695. static MODEL_BASE_URL: string;
  46696. /**
  46697. * File name for the controller model.
  46698. */
  46699. static MODEL_FILENAME: string;
  46700. /**
  46701. * Gamepad Id prefix used to identify Daydream Controller.
  46702. */
  46703. static readonly GAMEPAD_ID_PREFIX: string;
  46704. /**
  46705. * Creates a new DaydreamController from a gamepad
  46706. * @param vrGamepad the gamepad that the controller should be created from
  46707. */
  46708. constructor(vrGamepad: any);
  46709. /**
  46710. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46711. * @param scene scene in which to add meshes
  46712. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46713. */
  46714. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46715. /**
  46716. * Called once for each button that changed state since the last frame
  46717. * @param buttonIdx Which button index changed
  46718. * @param state New state of the button
  46719. * @param changes Which properties on the state changed since last frame
  46720. */
  46721. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46722. }
  46723. }
  46724. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46725. import { Scene } from "babylonjs/scene";
  46726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46727. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46728. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46729. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46730. /**
  46731. * Gear VR Controller
  46732. */
  46733. export class GearVRController extends WebVRController {
  46734. /**
  46735. * Base Url for the controller model.
  46736. */
  46737. static MODEL_BASE_URL: string;
  46738. /**
  46739. * File name for the controller model.
  46740. */
  46741. static MODEL_FILENAME: string;
  46742. /**
  46743. * Gamepad Id prefix used to identify this controller.
  46744. */
  46745. static readonly GAMEPAD_ID_PREFIX: string;
  46746. private readonly _buttonIndexToObservableNameMap;
  46747. /**
  46748. * Creates a new GearVRController from a gamepad
  46749. * @param vrGamepad the gamepad that the controller should be created from
  46750. */
  46751. constructor(vrGamepad: any);
  46752. /**
  46753. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46754. * @param scene scene in which to add meshes
  46755. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46756. */
  46757. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46758. /**
  46759. * Called once for each button that changed state since the last frame
  46760. * @param buttonIdx Which button index changed
  46761. * @param state New state of the button
  46762. * @param changes Which properties on the state changed since last frame
  46763. */
  46764. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46765. }
  46766. }
  46767. declare module "babylonjs/Gamepads/Controllers/index" {
  46768. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46769. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46770. export * from "babylonjs/Gamepads/Controllers/genericController";
  46771. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46772. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46773. export * from "babylonjs/Gamepads/Controllers/viveController";
  46774. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46775. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46776. }
  46777. declare module "babylonjs/Gamepads/index" {
  46778. export * from "babylonjs/Gamepads/Controllers/index";
  46779. export * from "babylonjs/Gamepads/gamepad";
  46780. export * from "babylonjs/Gamepads/gamepadManager";
  46781. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46782. export * from "babylonjs/Gamepads/xboxGamepad";
  46783. export * from "babylonjs/Gamepads/dualShockGamepad";
  46784. }
  46785. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46786. import { Scene } from "babylonjs/scene";
  46787. import { Vector4 } from "babylonjs/Maths/math.vector";
  46788. import { Color4 } from "babylonjs/Maths/math.color";
  46789. import { Mesh } from "babylonjs/Meshes/mesh";
  46790. import { Nullable } from "babylonjs/types";
  46791. /**
  46792. * Class containing static functions to help procedurally build meshes
  46793. */
  46794. export class PolyhedronBuilder {
  46795. /**
  46796. * Creates a polyhedron mesh
  46797. * * 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
  46798. * * The parameter `size` (positive float, default 1) sets the polygon size
  46799. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46800. * * 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`
  46801. * * 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
  46802. * * 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)`)
  46803. * * 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
  46804. * * 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
  46805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46806. * * 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
  46807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46808. * @param name defines the name of the mesh
  46809. * @param options defines the options used to create the mesh
  46810. * @param scene defines the hosting scene
  46811. * @returns the polyhedron mesh
  46812. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46813. */
  46814. static CreatePolyhedron(name: string, options: {
  46815. type?: number;
  46816. size?: number;
  46817. sizeX?: number;
  46818. sizeY?: number;
  46819. sizeZ?: number;
  46820. custom?: any;
  46821. faceUV?: Vector4[];
  46822. faceColors?: Color4[];
  46823. flat?: boolean;
  46824. updatable?: boolean;
  46825. sideOrientation?: number;
  46826. frontUVs?: Vector4;
  46827. backUVs?: Vector4;
  46828. }, scene?: Nullable<Scene>): Mesh;
  46829. }
  46830. }
  46831. declare module "babylonjs/Gizmos/scaleGizmo" {
  46832. import { Observable } from "babylonjs/Misc/observable";
  46833. import { Nullable } from "babylonjs/types";
  46834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46835. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46836. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46837. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46838. /**
  46839. * Gizmo that enables scaling a mesh along 3 axis
  46840. */
  46841. export class ScaleGizmo extends Gizmo {
  46842. /**
  46843. * Internal gizmo used for interactions on the x axis
  46844. */
  46845. xGizmo: AxisScaleGizmo;
  46846. /**
  46847. * Internal gizmo used for interactions on the y axis
  46848. */
  46849. yGizmo: AxisScaleGizmo;
  46850. /**
  46851. * Internal gizmo used for interactions on the z axis
  46852. */
  46853. zGizmo: AxisScaleGizmo;
  46854. /**
  46855. * Internal gizmo used to scale all axis equally
  46856. */
  46857. uniformScaleGizmo: AxisScaleGizmo;
  46858. private _meshAttached;
  46859. private _updateGizmoRotationToMatchAttachedMesh;
  46860. private _snapDistance;
  46861. private _scaleRatio;
  46862. private _uniformScalingMesh;
  46863. private _octahedron;
  46864. /** Fires an event when any of it's sub gizmos are dragged */
  46865. onDragStartObservable: Observable<unknown>;
  46866. /** Fires an event when any of it's sub gizmos are released from dragging */
  46867. onDragEndObservable: Observable<unknown>;
  46868. attachedMesh: Nullable<AbstractMesh>;
  46869. /**
  46870. * Creates a ScaleGizmo
  46871. * @param gizmoLayer The utility layer the gizmo will be added to
  46872. */
  46873. constructor(gizmoLayer?: UtilityLayerRenderer);
  46874. updateGizmoRotationToMatchAttachedMesh: boolean;
  46875. /**
  46876. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46877. */
  46878. snapDistance: number;
  46879. /**
  46880. * Ratio for the scale of the gizmo (Default: 1)
  46881. */
  46882. scaleRatio: number;
  46883. /**
  46884. * Disposes of the gizmo
  46885. */
  46886. dispose(): void;
  46887. }
  46888. }
  46889. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46890. import { Observable } from "babylonjs/Misc/observable";
  46891. import { Nullable } from "babylonjs/types";
  46892. import { Vector3 } from "babylonjs/Maths/math.vector";
  46893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46894. import { Mesh } from "babylonjs/Meshes/mesh";
  46895. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46896. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46897. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46898. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46899. import { Color3 } from "babylonjs/Maths/math.color";
  46900. /**
  46901. * Single axis scale gizmo
  46902. */
  46903. export class AxisScaleGizmo extends Gizmo {
  46904. /**
  46905. * Drag behavior responsible for the gizmos dragging interactions
  46906. */
  46907. dragBehavior: PointerDragBehavior;
  46908. private _pointerObserver;
  46909. /**
  46910. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46911. */
  46912. snapDistance: number;
  46913. /**
  46914. * Event that fires each time the gizmo snaps to a new location.
  46915. * * snapDistance is the the change in distance
  46916. */
  46917. onSnapObservable: Observable<{
  46918. snapDistance: number;
  46919. }>;
  46920. /**
  46921. * If the scaling operation should be done on all axis (default: false)
  46922. */
  46923. uniformScaling: boolean;
  46924. private _isEnabled;
  46925. private _parent;
  46926. private _arrow;
  46927. private _coloredMaterial;
  46928. private _hoverMaterial;
  46929. /**
  46930. * Creates an AxisScaleGizmo
  46931. * @param gizmoLayer The utility layer the gizmo will be added to
  46932. * @param dragAxis The axis which the gizmo will be able to scale on
  46933. * @param color The color of the gizmo
  46934. */
  46935. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46936. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46937. /**
  46938. * If the gizmo is enabled
  46939. */
  46940. isEnabled: boolean;
  46941. /**
  46942. * Disposes of the gizmo
  46943. */
  46944. dispose(): void;
  46945. /**
  46946. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46947. * @param mesh The mesh to replace the default mesh of the gizmo
  46948. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46949. */
  46950. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46951. }
  46952. }
  46953. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46954. import { Observable } from "babylonjs/Misc/observable";
  46955. import { Nullable } from "babylonjs/types";
  46956. import { Vector3 } from "babylonjs/Maths/math.vector";
  46957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46958. import { Mesh } from "babylonjs/Meshes/mesh";
  46959. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46960. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46961. import { Color3 } from "babylonjs/Maths/math.color";
  46962. import "babylonjs/Meshes/Builders/boxBuilder";
  46963. /**
  46964. * Bounding box gizmo
  46965. */
  46966. export class BoundingBoxGizmo extends Gizmo {
  46967. private _lineBoundingBox;
  46968. private _rotateSpheresParent;
  46969. private _scaleBoxesParent;
  46970. private _boundingDimensions;
  46971. private _renderObserver;
  46972. private _pointerObserver;
  46973. private _scaleDragSpeed;
  46974. private _tmpQuaternion;
  46975. private _tmpVector;
  46976. private _tmpRotationMatrix;
  46977. /**
  46978. * 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)
  46979. */
  46980. ignoreChildren: boolean;
  46981. /**
  46982. * 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)
  46983. */
  46984. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46985. /**
  46986. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46987. */
  46988. rotationSphereSize: number;
  46989. /**
  46990. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46991. */
  46992. scaleBoxSize: number;
  46993. /**
  46994. * 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)
  46995. */
  46996. fixedDragMeshScreenSize: boolean;
  46997. /**
  46998. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46999. */
  47000. fixedDragMeshScreenSizeDistanceFactor: number;
  47001. /**
  47002. * Fired when a rotation sphere or scale box is dragged
  47003. */
  47004. onDragStartObservable: Observable<{}>;
  47005. /**
  47006. * Fired when a scale box is dragged
  47007. */
  47008. onScaleBoxDragObservable: Observable<{}>;
  47009. /**
  47010. * Fired when a scale box drag is ended
  47011. */
  47012. onScaleBoxDragEndObservable: Observable<{}>;
  47013. /**
  47014. * Fired when a rotation sphere is dragged
  47015. */
  47016. onRotationSphereDragObservable: Observable<{}>;
  47017. /**
  47018. * Fired when a rotation sphere drag is ended
  47019. */
  47020. onRotationSphereDragEndObservable: Observable<{}>;
  47021. /**
  47022. * 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)
  47023. */
  47024. scalePivot: Nullable<Vector3>;
  47025. /**
  47026. * Mesh used as a pivot to rotate the attached mesh
  47027. */
  47028. private _anchorMesh;
  47029. private _existingMeshScale;
  47030. private _dragMesh;
  47031. private pointerDragBehavior;
  47032. private coloredMaterial;
  47033. private hoverColoredMaterial;
  47034. /**
  47035. * Sets the color of the bounding box gizmo
  47036. * @param color the color to set
  47037. */
  47038. setColor(color: Color3): void;
  47039. /**
  47040. * Creates an BoundingBoxGizmo
  47041. * @param gizmoLayer The utility layer the gizmo will be added to
  47042. * @param color The color of the gizmo
  47043. */
  47044. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47045. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47046. private _selectNode;
  47047. /**
  47048. * Updates the bounding box information for the Gizmo
  47049. */
  47050. updateBoundingBox(): void;
  47051. private _updateRotationSpheres;
  47052. private _updateScaleBoxes;
  47053. /**
  47054. * Enables rotation on the specified axis and disables rotation on the others
  47055. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47056. */
  47057. setEnabledRotationAxis(axis: string): void;
  47058. /**
  47059. * Enables/disables scaling
  47060. * @param enable if scaling should be enabled
  47061. */
  47062. setEnabledScaling(enable: boolean): void;
  47063. private _updateDummy;
  47064. /**
  47065. * Enables a pointer drag behavior on the bounding box of the gizmo
  47066. */
  47067. enableDragBehavior(): void;
  47068. /**
  47069. * Disposes of the gizmo
  47070. */
  47071. dispose(): void;
  47072. /**
  47073. * 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)
  47074. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47075. * @returns the bounding box mesh with the passed in mesh as a child
  47076. */
  47077. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47078. /**
  47079. * CustomMeshes are not supported by this gizmo
  47080. * @param mesh The mesh to replace the default mesh of the gizmo
  47081. */
  47082. setCustomMesh(mesh: Mesh): void;
  47083. }
  47084. }
  47085. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47086. import { Observable } from "babylonjs/Misc/observable";
  47087. import { Nullable } from "babylonjs/types";
  47088. import { Vector3 } from "babylonjs/Maths/math.vector";
  47089. import { Color3 } from "babylonjs/Maths/math.color";
  47090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47091. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47092. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47093. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47094. import "babylonjs/Meshes/Builders/linesBuilder";
  47095. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47096. /**
  47097. * Single plane rotation gizmo
  47098. */
  47099. export class PlaneRotationGizmo extends Gizmo {
  47100. /**
  47101. * Drag behavior responsible for the gizmos dragging interactions
  47102. */
  47103. dragBehavior: PointerDragBehavior;
  47104. private _pointerObserver;
  47105. /**
  47106. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47107. */
  47108. snapDistance: number;
  47109. /**
  47110. * Event that fires each time the gizmo snaps to a new location.
  47111. * * snapDistance is the the change in distance
  47112. */
  47113. onSnapObservable: Observable<{
  47114. snapDistance: number;
  47115. }>;
  47116. private _isEnabled;
  47117. private _parent;
  47118. /**
  47119. * Creates a PlaneRotationGizmo
  47120. * @param gizmoLayer The utility layer the gizmo will be added to
  47121. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47122. * @param color The color of the gizmo
  47123. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47124. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47125. */
  47126. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47127. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47128. /**
  47129. * If the gizmo is enabled
  47130. */
  47131. isEnabled: boolean;
  47132. /**
  47133. * Disposes of the gizmo
  47134. */
  47135. dispose(): void;
  47136. }
  47137. }
  47138. declare module "babylonjs/Gizmos/rotationGizmo" {
  47139. import { Observable } from "babylonjs/Misc/observable";
  47140. import { Nullable } from "babylonjs/types";
  47141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47142. import { Mesh } from "babylonjs/Meshes/mesh";
  47143. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47144. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47145. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47146. /**
  47147. * Gizmo that enables rotating a mesh along 3 axis
  47148. */
  47149. export class RotationGizmo extends Gizmo {
  47150. /**
  47151. * Internal gizmo used for interactions on the x axis
  47152. */
  47153. xGizmo: PlaneRotationGizmo;
  47154. /**
  47155. * Internal gizmo used for interactions on the y axis
  47156. */
  47157. yGizmo: PlaneRotationGizmo;
  47158. /**
  47159. * Internal gizmo used for interactions on the z axis
  47160. */
  47161. zGizmo: PlaneRotationGizmo;
  47162. /** Fires an event when any of it's sub gizmos are dragged */
  47163. onDragStartObservable: Observable<unknown>;
  47164. /** Fires an event when any of it's sub gizmos are released from dragging */
  47165. onDragEndObservable: Observable<unknown>;
  47166. private _meshAttached;
  47167. attachedMesh: Nullable<AbstractMesh>;
  47168. /**
  47169. * Creates a RotationGizmo
  47170. * @param gizmoLayer The utility layer the gizmo will be added to
  47171. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47172. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47173. */
  47174. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47175. updateGizmoRotationToMatchAttachedMesh: boolean;
  47176. /**
  47177. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47178. */
  47179. snapDistance: number;
  47180. /**
  47181. * Ratio for the scale of the gizmo (Default: 1)
  47182. */
  47183. scaleRatio: number;
  47184. /**
  47185. * Disposes of the gizmo
  47186. */
  47187. dispose(): void;
  47188. /**
  47189. * CustomMeshes are not supported by this gizmo
  47190. * @param mesh The mesh to replace the default mesh of the gizmo
  47191. */
  47192. setCustomMesh(mesh: Mesh): void;
  47193. }
  47194. }
  47195. declare module "babylonjs/Gizmos/gizmoManager" {
  47196. import { Observable } from "babylonjs/Misc/observable";
  47197. import { Nullable } from "babylonjs/types";
  47198. import { Scene, IDisposable } from "babylonjs/scene";
  47199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47200. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47201. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47202. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47203. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47204. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47205. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47206. /**
  47207. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47208. */
  47209. export class GizmoManager implements IDisposable {
  47210. private scene;
  47211. /**
  47212. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47213. */
  47214. gizmos: {
  47215. positionGizmo: Nullable<PositionGizmo>;
  47216. rotationGizmo: Nullable<RotationGizmo>;
  47217. scaleGizmo: Nullable<ScaleGizmo>;
  47218. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47219. };
  47220. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47221. clearGizmoOnEmptyPointerEvent: boolean;
  47222. /** Fires an event when the manager is attached to a mesh */
  47223. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47224. private _gizmosEnabled;
  47225. private _pointerObserver;
  47226. private _attachedMesh;
  47227. private _boundingBoxColor;
  47228. private _defaultUtilityLayer;
  47229. private _defaultKeepDepthUtilityLayer;
  47230. /**
  47231. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47232. */
  47233. boundingBoxDragBehavior: SixDofDragBehavior;
  47234. /**
  47235. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47236. */
  47237. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47238. /**
  47239. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47240. */
  47241. usePointerToAttachGizmos: boolean;
  47242. /**
  47243. * Utility layer that the bounding box gizmo belongs to
  47244. */
  47245. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47246. /**
  47247. * Utility layer that all gizmos besides bounding box belong to
  47248. */
  47249. readonly utilityLayer: UtilityLayerRenderer;
  47250. /**
  47251. * Instatiates a gizmo manager
  47252. * @param scene the scene to overlay the gizmos on top of
  47253. */
  47254. constructor(scene: Scene);
  47255. /**
  47256. * Attaches a set of gizmos to the specified mesh
  47257. * @param mesh The mesh the gizmo's should be attached to
  47258. */
  47259. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47260. /**
  47261. * If the position gizmo is enabled
  47262. */
  47263. positionGizmoEnabled: boolean;
  47264. /**
  47265. * If the rotation gizmo is enabled
  47266. */
  47267. rotationGizmoEnabled: boolean;
  47268. /**
  47269. * If the scale gizmo is enabled
  47270. */
  47271. scaleGizmoEnabled: boolean;
  47272. /**
  47273. * If the boundingBox gizmo is enabled
  47274. */
  47275. boundingBoxGizmoEnabled: boolean;
  47276. /**
  47277. * Disposes of the gizmo manager
  47278. */
  47279. dispose(): void;
  47280. }
  47281. }
  47282. declare module "babylonjs/Lights/directionalLight" {
  47283. import { Camera } from "babylonjs/Cameras/camera";
  47284. import { Scene } from "babylonjs/scene";
  47285. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47287. import { Light } from "babylonjs/Lights/light";
  47288. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47289. import { Effect } from "babylonjs/Materials/effect";
  47290. /**
  47291. * A directional light is defined by a direction (what a surprise!).
  47292. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47293. * 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.
  47294. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47295. */
  47296. export class DirectionalLight extends ShadowLight {
  47297. private _shadowFrustumSize;
  47298. /**
  47299. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47300. */
  47301. /**
  47302. * Specifies a fix frustum size for the shadow generation.
  47303. */
  47304. shadowFrustumSize: number;
  47305. private _shadowOrthoScale;
  47306. /**
  47307. * Gets the shadow projection scale against the optimal computed one.
  47308. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47309. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47310. */
  47311. /**
  47312. * Sets the shadow projection scale against the optimal computed one.
  47313. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47314. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47315. */
  47316. shadowOrthoScale: number;
  47317. /**
  47318. * Automatically compute the projection matrix to best fit (including all the casters)
  47319. * on each frame.
  47320. */
  47321. autoUpdateExtends: boolean;
  47322. private _orthoLeft;
  47323. private _orthoRight;
  47324. private _orthoTop;
  47325. private _orthoBottom;
  47326. /**
  47327. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47328. * The directional light is emitted from everywhere in the given direction.
  47329. * It can cast shadows.
  47330. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47331. * @param name The friendly name of the light
  47332. * @param direction The direction of the light
  47333. * @param scene The scene the light belongs to
  47334. */
  47335. constructor(name: string, direction: Vector3, scene: Scene);
  47336. /**
  47337. * Returns the string "DirectionalLight".
  47338. * @return The class name
  47339. */
  47340. getClassName(): string;
  47341. /**
  47342. * Returns the integer 1.
  47343. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47344. */
  47345. getTypeID(): number;
  47346. /**
  47347. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47348. * Returns the DirectionalLight Shadow projection matrix.
  47349. */
  47350. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47351. /**
  47352. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47353. * Returns the DirectionalLight Shadow projection matrix.
  47354. */
  47355. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47356. /**
  47357. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47358. * Returns the DirectionalLight Shadow projection matrix.
  47359. */
  47360. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47361. protected _buildUniformLayout(): void;
  47362. /**
  47363. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47364. * @param effect The effect to update
  47365. * @param lightIndex The index of the light in the effect to update
  47366. * @returns The directional light
  47367. */
  47368. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47369. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47370. /**
  47371. * Gets the minZ used for shadow according to both the scene and the light.
  47372. *
  47373. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47374. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47375. * @param activeCamera The camera we are returning the min for
  47376. * @returns the depth min z
  47377. */
  47378. getDepthMinZ(activeCamera: Camera): number;
  47379. /**
  47380. * Gets the maxZ used for shadow according to both the scene and the light.
  47381. *
  47382. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47383. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47384. * @param activeCamera The camera we are returning the max for
  47385. * @returns the depth max z
  47386. */
  47387. getDepthMaxZ(activeCamera: Camera): number;
  47388. /**
  47389. * Prepares the list of defines specific to the light type.
  47390. * @param defines the list of defines
  47391. * @param lightIndex defines the index of the light for the effect
  47392. */
  47393. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47394. }
  47395. }
  47396. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47397. import { Mesh } from "babylonjs/Meshes/mesh";
  47398. /**
  47399. * Class containing static functions to help procedurally build meshes
  47400. */
  47401. export class HemisphereBuilder {
  47402. /**
  47403. * Creates a hemisphere mesh
  47404. * @param name defines the name of the mesh
  47405. * @param options defines the options used to create the mesh
  47406. * @param scene defines the hosting scene
  47407. * @returns the hemisphere mesh
  47408. */
  47409. static CreateHemisphere(name: string, options: {
  47410. segments?: number;
  47411. diameter?: number;
  47412. sideOrientation?: number;
  47413. }, scene: any): Mesh;
  47414. }
  47415. }
  47416. declare module "babylonjs/Lights/spotLight" {
  47417. import { Nullable } from "babylonjs/types";
  47418. import { Scene } from "babylonjs/scene";
  47419. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47421. import { Effect } from "babylonjs/Materials/effect";
  47422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47423. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47424. /**
  47425. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47426. * These values define a cone of light starting from the position, emitting toward the direction.
  47427. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47428. * and the exponent defines the speed of the decay of the light with distance (reach).
  47429. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47430. */
  47431. export class SpotLight extends ShadowLight {
  47432. private _angle;
  47433. private _innerAngle;
  47434. private _cosHalfAngle;
  47435. private _lightAngleScale;
  47436. private _lightAngleOffset;
  47437. /**
  47438. * Gets the cone angle of the spot light in Radians.
  47439. */
  47440. /**
  47441. * Sets the cone angle of the spot light in Radians.
  47442. */
  47443. angle: number;
  47444. /**
  47445. * Only used in gltf falloff mode, this defines the angle where
  47446. * the directional falloff will start before cutting at angle which could be seen
  47447. * as outer angle.
  47448. */
  47449. /**
  47450. * Only used in gltf falloff mode, this defines the angle where
  47451. * the directional falloff will start before cutting at angle which could be seen
  47452. * as outer angle.
  47453. */
  47454. innerAngle: number;
  47455. private _shadowAngleScale;
  47456. /**
  47457. * Allows scaling the angle of the light for shadow generation only.
  47458. */
  47459. /**
  47460. * Allows scaling the angle of the light for shadow generation only.
  47461. */
  47462. shadowAngleScale: number;
  47463. /**
  47464. * The light decay speed with the distance from the emission spot.
  47465. */
  47466. exponent: number;
  47467. private _projectionTextureMatrix;
  47468. /**
  47469. * Allows reading the projecton texture
  47470. */
  47471. readonly projectionTextureMatrix: Matrix;
  47472. protected _projectionTextureLightNear: number;
  47473. /**
  47474. * Gets the near clip of the Spotlight for texture projection.
  47475. */
  47476. /**
  47477. * Sets the near clip of the Spotlight for texture projection.
  47478. */
  47479. projectionTextureLightNear: number;
  47480. protected _projectionTextureLightFar: number;
  47481. /**
  47482. * Gets the far clip of the Spotlight for texture projection.
  47483. */
  47484. /**
  47485. * Sets the far clip of the Spotlight for texture projection.
  47486. */
  47487. projectionTextureLightFar: number;
  47488. protected _projectionTextureUpDirection: Vector3;
  47489. /**
  47490. * Gets the Up vector of the Spotlight for texture projection.
  47491. */
  47492. /**
  47493. * Sets the Up vector of the Spotlight for texture projection.
  47494. */
  47495. projectionTextureUpDirection: Vector3;
  47496. private _projectionTexture;
  47497. /**
  47498. * Gets the projection texture of the light.
  47499. */
  47500. /**
  47501. * Sets the projection texture of the light.
  47502. */
  47503. projectionTexture: Nullable<BaseTexture>;
  47504. private _projectionTextureViewLightDirty;
  47505. private _projectionTextureProjectionLightDirty;
  47506. private _projectionTextureDirty;
  47507. private _projectionTextureViewTargetVector;
  47508. private _projectionTextureViewLightMatrix;
  47509. private _projectionTextureProjectionLightMatrix;
  47510. private _projectionTextureScalingMatrix;
  47511. /**
  47512. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47513. * It can cast shadows.
  47514. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47515. * @param name The light friendly name
  47516. * @param position The position of the spot light in the scene
  47517. * @param direction The direction of the light in the scene
  47518. * @param angle The cone angle of the light in Radians
  47519. * @param exponent The light decay speed with the distance from the emission spot
  47520. * @param scene The scene the lights belongs to
  47521. */
  47522. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47523. /**
  47524. * Returns the string "SpotLight".
  47525. * @returns the class name
  47526. */
  47527. getClassName(): string;
  47528. /**
  47529. * Returns the integer 2.
  47530. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47531. */
  47532. getTypeID(): number;
  47533. /**
  47534. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47535. */
  47536. protected _setDirection(value: Vector3): void;
  47537. /**
  47538. * Overrides the position setter to recompute the projection texture view light Matrix.
  47539. */
  47540. protected _setPosition(value: Vector3): void;
  47541. /**
  47542. * 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.
  47543. * Returns the SpotLight.
  47544. */
  47545. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47546. protected _computeProjectionTextureViewLightMatrix(): void;
  47547. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47548. /**
  47549. * Main function for light texture projection matrix computing.
  47550. */
  47551. protected _computeProjectionTextureMatrix(): void;
  47552. protected _buildUniformLayout(): void;
  47553. private _computeAngleValues;
  47554. /**
  47555. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47556. * @param effect The effect to update
  47557. * @param lightIndex The index of the light in the effect to update
  47558. * @returns The spot light
  47559. */
  47560. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47561. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47562. /**
  47563. * Disposes the light and the associated resources.
  47564. */
  47565. dispose(): void;
  47566. /**
  47567. * Prepares the list of defines specific to the light type.
  47568. * @param defines the list of defines
  47569. * @param lightIndex defines the index of the light for the effect
  47570. */
  47571. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47572. }
  47573. }
  47574. declare module "babylonjs/Gizmos/lightGizmo" {
  47575. import { Nullable } from "babylonjs/types";
  47576. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47577. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47578. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47579. import { Light } from "babylonjs/Lights/light";
  47580. /**
  47581. * Gizmo that enables viewing a light
  47582. */
  47583. export class LightGizmo extends Gizmo {
  47584. private _lightMesh;
  47585. private _material;
  47586. private cachedPosition;
  47587. private cachedForward;
  47588. /**
  47589. * Creates a LightGizmo
  47590. * @param gizmoLayer The utility layer the gizmo will be added to
  47591. */
  47592. constructor(gizmoLayer?: UtilityLayerRenderer);
  47593. private _light;
  47594. /**
  47595. * The light that the gizmo is attached to
  47596. */
  47597. light: Nullable<Light>;
  47598. /**
  47599. * Gets the material used to render the light gizmo
  47600. */
  47601. readonly material: StandardMaterial;
  47602. /**
  47603. * @hidden
  47604. * Updates the gizmo to match the attached mesh's position/rotation
  47605. */
  47606. protected _update(): void;
  47607. private static _Scale;
  47608. /**
  47609. * Creates the lines for a light mesh
  47610. */
  47611. private static _createLightLines;
  47612. /**
  47613. * Disposes of the light gizmo
  47614. */
  47615. dispose(): void;
  47616. private static _CreateHemisphericLightMesh;
  47617. private static _CreatePointLightMesh;
  47618. private static _CreateSpotLightMesh;
  47619. private static _CreateDirectionalLightMesh;
  47620. }
  47621. }
  47622. declare module "babylonjs/Gizmos/index" {
  47623. export * from "babylonjs/Gizmos/axisDragGizmo";
  47624. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47625. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47626. export * from "babylonjs/Gizmos/gizmo";
  47627. export * from "babylonjs/Gizmos/gizmoManager";
  47628. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47629. export * from "babylonjs/Gizmos/positionGizmo";
  47630. export * from "babylonjs/Gizmos/rotationGizmo";
  47631. export * from "babylonjs/Gizmos/scaleGizmo";
  47632. export * from "babylonjs/Gizmos/lightGizmo";
  47633. export * from "babylonjs/Gizmos/planeDragGizmo";
  47634. }
  47635. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47636. /** @hidden */
  47637. export var backgroundFragmentDeclaration: {
  47638. name: string;
  47639. shader: string;
  47640. };
  47641. }
  47642. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47643. /** @hidden */
  47644. export var backgroundUboDeclaration: {
  47645. name: string;
  47646. shader: string;
  47647. };
  47648. }
  47649. declare module "babylonjs/Shaders/background.fragment" {
  47650. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47651. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47652. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47653. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47654. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47655. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47656. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47657. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47658. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47659. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47660. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47661. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47662. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47663. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47664. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47665. /** @hidden */
  47666. export var backgroundPixelShader: {
  47667. name: string;
  47668. shader: string;
  47669. };
  47670. }
  47671. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47672. /** @hidden */
  47673. export var backgroundVertexDeclaration: {
  47674. name: string;
  47675. shader: string;
  47676. };
  47677. }
  47678. declare module "babylonjs/Shaders/background.vertex" {
  47679. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47680. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47681. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47682. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47683. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47684. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47685. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47686. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47687. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47688. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47689. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47690. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47691. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47692. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47693. /** @hidden */
  47694. export var backgroundVertexShader: {
  47695. name: string;
  47696. shader: string;
  47697. };
  47698. }
  47699. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47700. import { Nullable, int, float } from "babylonjs/types";
  47701. import { Scene } from "babylonjs/scene";
  47702. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47703. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47705. import { Mesh } from "babylonjs/Meshes/mesh";
  47706. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47707. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47708. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47709. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47710. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47711. import { Color3 } from "babylonjs/Maths/math.color";
  47712. import "babylonjs/Shaders/background.fragment";
  47713. import "babylonjs/Shaders/background.vertex";
  47714. /**
  47715. * Background material used to create an efficient environement around your scene.
  47716. */
  47717. export class BackgroundMaterial extends PushMaterial {
  47718. /**
  47719. * Standard reflectance value at parallel view angle.
  47720. */
  47721. static StandardReflectance0: number;
  47722. /**
  47723. * Standard reflectance value at grazing angle.
  47724. */
  47725. static StandardReflectance90: number;
  47726. protected _primaryColor: Color3;
  47727. /**
  47728. * Key light Color (multiply against the environement texture)
  47729. */
  47730. primaryColor: Color3;
  47731. protected __perceptualColor: Nullable<Color3>;
  47732. /**
  47733. * Experimental Internal Use Only.
  47734. *
  47735. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47736. * This acts as a helper to set the primary color to a more "human friendly" value.
  47737. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47738. * output color as close as possible from the chosen value.
  47739. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47740. * part of lighting setup.)
  47741. */
  47742. _perceptualColor: Nullable<Color3>;
  47743. protected _primaryColorShadowLevel: float;
  47744. /**
  47745. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47746. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47747. */
  47748. primaryColorShadowLevel: float;
  47749. protected _primaryColorHighlightLevel: float;
  47750. /**
  47751. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47752. * The primary color is used at the level chosen to define what the white area would look.
  47753. */
  47754. primaryColorHighlightLevel: float;
  47755. protected _reflectionTexture: Nullable<BaseTexture>;
  47756. /**
  47757. * Reflection Texture used in the material.
  47758. * Should be author in a specific way for the best result (refer to the documentation).
  47759. */
  47760. reflectionTexture: Nullable<BaseTexture>;
  47761. protected _reflectionBlur: float;
  47762. /**
  47763. * Reflection Texture level of blur.
  47764. *
  47765. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47766. * texture twice.
  47767. */
  47768. reflectionBlur: float;
  47769. protected _diffuseTexture: Nullable<BaseTexture>;
  47770. /**
  47771. * Diffuse Texture used in the material.
  47772. * Should be author in a specific way for the best result (refer to the documentation).
  47773. */
  47774. diffuseTexture: Nullable<BaseTexture>;
  47775. protected _shadowLights: Nullable<IShadowLight[]>;
  47776. /**
  47777. * Specify the list of lights casting shadow on the material.
  47778. * All scene shadow lights will be included if null.
  47779. */
  47780. shadowLights: Nullable<IShadowLight[]>;
  47781. protected _shadowLevel: float;
  47782. /**
  47783. * Helps adjusting the shadow to a softer level if required.
  47784. * 0 means black shadows and 1 means no shadows.
  47785. */
  47786. shadowLevel: float;
  47787. protected _sceneCenter: Vector3;
  47788. /**
  47789. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47790. * It is usually zero but might be interesting to modify according to your setup.
  47791. */
  47792. sceneCenter: Vector3;
  47793. protected _opacityFresnel: boolean;
  47794. /**
  47795. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47796. * This helps ensuring a nice transition when the camera goes under the ground.
  47797. */
  47798. opacityFresnel: boolean;
  47799. protected _reflectionFresnel: boolean;
  47800. /**
  47801. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47802. * This helps adding a mirror texture on the ground.
  47803. */
  47804. reflectionFresnel: boolean;
  47805. protected _reflectionFalloffDistance: number;
  47806. /**
  47807. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47808. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47809. */
  47810. reflectionFalloffDistance: number;
  47811. protected _reflectionAmount: number;
  47812. /**
  47813. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47814. */
  47815. reflectionAmount: number;
  47816. protected _reflectionReflectance0: number;
  47817. /**
  47818. * This specifies the weight of the reflection at grazing angle.
  47819. */
  47820. reflectionReflectance0: number;
  47821. protected _reflectionReflectance90: number;
  47822. /**
  47823. * This specifies the weight of the reflection at a perpendicular point of view.
  47824. */
  47825. reflectionReflectance90: number;
  47826. /**
  47827. * Sets the reflection reflectance fresnel values according to the default standard
  47828. * empirically know to work well :-)
  47829. */
  47830. reflectionStandardFresnelWeight: number;
  47831. protected _useRGBColor: boolean;
  47832. /**
  47833. * Helps to directly use the maps channels instead of their level.
  47834. */
  47835. useRGBColor: boolean;
  47836. protected _enableNoise: boolean;
  47837. /**
  47838. * This helps reducing the banding effect that could occur on the background.
  47839. */
  47840. enableNoise: boolean;
  47841. /**
  47842. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47843. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47844. * Recommended to be keep at 1.0 except for special cases.
  47845. */
  47846. fovMultiplier: number;
  47847. private _fovMultiplier;
  47848. /**
  47849. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47850. */
  47851. useEquirectangularFOV: boolean;
  47852. private _maxSimultaneousLights;
  47853. /**
  47854. * Number of Simultaneous lights allowed on the material.
  47855. */
  47856. maxSimultaneousLights: int;
  47857. /**
  47858. * Default configuration related to image processing available in the Background Material.
  47859. */
  47860. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47861. /**
  47862. * Keep track of the image processing observer to allow dispose and replace.
  47863. */
  47864. private _imageProcessingObserver;
  47865. /**
  47866. * Attaches a new image processing configuration to the PBR Material.
  47867. * @param configuration (if null the scene configuration will be use)
  47868. */
  47869. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47870. /**
  47871. * Gets the image processing configuration used either in this material.
  47872. */
  47873. /**
  47874. * Sets the Default image processing configuration used either in the this material.
  47875. *
  47876. * If sets to null, the scene one is in use.
  47877. */
  47878. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47879. /**
  47880. * Gets wether the color curves effect is enabled.
  47881. */
  47882. /**
  47883. * Sets wether the color curves effect is enabled.
  47884. */
  47885. cameraColorCurvesEnabled: boolean;
  47886. /**
  47887. * Gets wether the color grading effect is enabled.
  47888. */
  47889. /**
  47890. * Gets wether the color grading effect is enabled.
  47891. */
  47892. cameraColorGradingEnabled: boolean;
  47893. /**
  47894. * Gets wether tonemapping is enabled or not.
  47895. */
  47896. /**
  47897. * Sets wether tonemapping is enabled or not
  47898. */
  47899. cameraToneMappingEnabled: boolean;
  47900. /**
  47901. * The camera exposure used on this material.
  47902. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47903. * This corresponds to a photographic exposure.
  47904. */
  47905. /**
  47906. * The camera exposure used on this material.
  47907. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47908. * This corresponds to a photographic exposure.
  47909. */
  47910. cameraExposure: float;
  47911. /**
  47912. * Gets The camera contrast used on this material.
  47913. */
  47914. /**
  47915. * Sets The camera contrast used on this material.
  47916. */
  47917. cameraContrast: float;
  47918. /**
  47919. * Gets the Color Grading 2D Lookup Texture.
  47920. */
  47921. /**
  47922. * Sets the Color Grading 2D Lookup Texture.
  47923. */
  47924. cameraColorGradingTexture: Nullable<BaseTexture>;
  47925. /**
  47926. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47927. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47928. * 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;
  47929. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47930. */
  47931. /**
  47932. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47933. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47934. * 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;
  47935. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47936. */
  47937. cameraColorCurves: Nullable<ColorCurves>;
  47938. /**
  47939. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47940. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47941. */
  47942. switchToBGR: boolean;
  47943. private _renderTargets;
  47944. private _reflectionControls;
  47945. private _white;
  47946. private _primaryShadowColor;
  47947. private _primaryHighlightColor;
  47948. /**
  47949. * Instantiates a Background Material in the given scene
  47950. * @param name The friendly name of the material
  47951. * @param scene The scene to add the material to
  47952. */
  47953. constructor(name: string, scene: Scene);
  47954. /**
  47955. * Gets a boolean indicating that current material needs to register RTT
  47956. */
  47957. readonly hasRenderTargetTextures: boolean;
  47958. /**
  47959. * The entire material has been created in order to prevent overdraw.
  47960. * @returns false
  47961. */
  47962. needAlphaTesting(): boolean;
  47963. /**
  47964. * The entire material has been created in order to prevent overdraw.
  47965. * @returns true if blending is enable
  47966. */
  47967. needAlphaBlending(): boolean;
  47968. /**
  47969. * Checks wether the material is ready to be rendered for a given mesh.
  47970. * @param mesh The mesh to render
  47971. * @param subMesh The submesh to check against
  47972. * @param useInstances Specify wether or not the material is used with instances
  47973. * @returns true if all the dependencies are ready (Textures, Effects...)
  47974. */
  47975. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47976. /**
  47977. * Compute the primary color according to the chosen perceptual color.
  47978. */
  47979. private _computePrimaryColorFromPerceptualColor;
  47980. /**
  47981. * Compute the highlights and shadow colors according to their chosen levels.
  47982. */
  47983. private _computePrimaryColors;
  47984. /**
  47985. * Build the uniform buffer used in the material.
  47986. */
  47987. buildUniformLayout(): void;
  47988. /**
  47989. * Unbind the material.
  47990. */
  47991. unbind(): void;
  47992. /**
  47993. * Bind only the world matrix to the material.
  47994. * @param world The world matrix to bind.
  47995. */
  47996. bindOnlyWorldMatrix(world: Matrix): void;
  47997. /**
  47998. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47999. * @param world The world matrix to bind.
  48000. * @param subMesh The submesh to bind for.
  48001. */
  48002. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48003. /**
  48004. * Checks to see if a texture is used in the material.
  48005. * @param texture - Base texture to use.
  48006. * @returns - Boolean specifying if a texture is used in the material.
  48007. */
  48008. hasTexture(texture: BaseTexture): boolean;
  48009. /**
  48010. * Dispose the material.
  48011. * @param forceDisposeEffect Force disposal of the associated effect.
  48012. * @param forceDisposeTextures Force disposal of the associated textures.
  48013. */
  48014. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48015. /**
  48016. * Clones the material.
  48017. * @param name The cloned name.
  48018. * @returns The cloned material.
  48019. */
  48020. clone(name: string): BackgroundMaterial;
  48021. /**
  48022. * Serializes the current material to its JSON representation.
  48023. * @returns The JSON representation.
  48024. */
  48025. serialize(): any;
  48026. /**
  48027. * Gets the class name of the material
  48028. * @returns "BackgroundMaterial"
  48029. */
  48030. getClassName(): string;
  48031. /**
  48032. * Parse a JSON input to create back a background material.
  48033. * @param source The JSON data to parse
  48034. * @param scene The scene to create the parsed material in
  48035. * @param rootUrl The root url of the assets the material depends upon
  48036. * @returns the instantiated BackgroundMaterial.
  48037. */
  48038. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48039. }
  48040. }
  48041. declare module "babylonjs/Helpers/environmentHelper" {
  48042. import { Observable } from "babylonjs/Misc/observable";
  48043. import { Nullable } from "babylonjs/types";
  48044. import { Scene } from "babylonjs/scene";
  48045. import { Vector3 } from "babylonjs/Maths/math.vector";
  48046. import { Color3 } from "babylonjs/Maths/math.color";
  48047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48048. import { Mesh } from "babylonjs/Meshes/mesh";
  48049. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48050. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48051. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48052. import "babylonjs/Meshes/Builders/planeBuilder";
  48053. import "babylonjs/Meshes/Builders/boxBuilder";
  48054. /**
  48055. * Represents the different options available during the creation of
  48056. * a Environment helper.
  48057. *
  48058. * This can control the default ground, skybox and image processing setup of your scene.
  48059. */
  48060. export interface IEnvironmentHelperOptions {
  48061. /**
  48062. * Specifies wether or not to create a ground.
  48063. * True by default.
  48064. */
  48065. createGround: boolean;
  48066. /**
  48067. * Specifies the ground size.
  48068. * 15 by default.
  48069. */
  48070. groundSize: number;
  48071. /**
  48072. * The texture used on the ground for the main color.
  48073. * Comes from the BabylonJS CDN by default.
  48074. *
  48075. * Remarks: Can be either a texture or a url.
  48076. */
  48077. groundTexture: string | BaseTexture;
  48078. /**
  48079. * The color mixed in the ground texture by default.
  48080. * BabylonJS clearColor by default.
  48081. */
  48082. groundColor: Color3;
  48083. /**
  48084. * Specifies the ground opacity.
  48085. * 1 by default.
  48086. */
  48087. groundOpacity: number;
  48088. /**
  48089. * Enables the ground to receive shadows.
  48090. * True by default.
  48091. */
  48092. enableGroundShadow: boolean;
  48093. /**
  48094. * Helps preventing the shadow to be fully black on the ground.
  48095. * 0.5 by default.
  48096. */
  48097. groundShadowLevel: number;
  48098. /**
  48099. * Creates a mirror texture attach to the ground.
  48100. * false by default.
  48101. */
  48102. enableGroundMirror: boolean;
  48103. /**
  48104. * Specifies the ground mirror size ratio.
  48105. * 0.3 by default as the default kernel is 64.
  48106. */
  48107. groundMirrorSizeRatio: number;
  48108. /**
  48109. * Specifies the ground mirror blur kernel size.
  48110. * 64 by default.
  48111. */
  48112. groundMirrorBlurKernel: number;
  48113. /**
  48114. * Specifies the ground mirror visibility amount.
  48115. * 1 by default
  48116. */
  48117. groundMirrorAmount: number;
  48118. /**
  48119. * Specifies the ground mirror reflectance weight.
  48120. * This uses the standard weight of the background material to setup the fresnel effect
  48121. * of the mirror.
  48122. * 1 by default.
  48123. */
  48124. groundMirrorFresnelWeight: number;
  48125. /**
  48126. * Specifies the ground mirror Falloff distance.
  48127. * This can helps reducing the size of the reflection.
  48128. * 0 by Default.
  48129. */
  48130. groundMirrorFallOffDistance: number;
  48131. /**
  48132. * Specifies the ground mirror texture type.
  48133. * Unsigned Int by Default.
  48134. */
  48135. groundMirrorTextureType: number;
  48136. /**
  48137. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48138. * the shown objects.
  48139. */
  48140. groundYBias: number;
  48141. /**
  48142. * Specifies wether or not to create a skybox.
  48143. * True by default.
  48144. */
  48145. createSkybox: boolean;
  48146. /**
  48147. * Specifies the skybox size.
  48148. * 20 by default.
  48149. */
  48150. skyboxSize: number;
  48151. /**
  48152. * The texture used on the skybox for the main color.
  48153. * Comes from the BabylonJS CDN by default.
  48154. *
  48155. * Remarks: Can be either a texture or a url.
  48156. */
  48157. skyboxTexture: string | BaseTexture;
  48158. /**
  48159. * The color mixed in the skybox texture by default.
  48160. * BabylonJS clearColor by default.
  48161. */
  48162. skyboxColor: Color3;
  48163. /**
  48164. * The background rotation around the Y axis of the scene.
  48165. * This helps aligning the key lights of your scene with the background.
  48166. * 0 by default.
  48167. */
  48168. backgroundYRotation: number;
  48169. /**
  48170. * Compute automatically the size of the elements to best fit with the scene.
  48171. */
  48172. sizeAuto: boolean;
  48173. /**
  48174. * Default position of the rootMesh if autoSize is not true.
  48175. */
  48176. rootPosition: Vector3;
  48177. /**
  48178. * Sets up the image processing in the scene.
  48179. * true by default.
  48180. */
  48181. setupImageProcessing: boolean;
  48182. /**
  48183. * The texture used as your environment texture in the scene.
  48184. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48185. *
  48186. * Remarks: Can be either a texture or a url.
  48187. */
  48188. environmentTexture: string | BaseTexture;
  48189. /**
  48190. * The value of the exposure to apply to the scene.
  48191. * 0.6 by default if setupImageProcessing is true.
  48192. */
  48193. cameraExposure: number;
  48194. /**
  48195. * The value of the contrast to apply to the scene.
  48196. * 1.6 by default if setupImageProcessing is true.
  48197. */
  48198. cameraContrast: number;
  48199. /**
  48200. * Specifies wether or not tonemapping should be enabled in the scene.
  48201. * true by default if setupImageProcessing is true.
  48202. */
  48203. toneMappingEnabled: boolean;
  48204. }
  48205. /**
  48206. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48207. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48208. * It also helps with the default setup of your imageProcessing configuration.
  48209. */
  48210. export class EnvironmentHelper {
  48211. /**
  48212. * Default ground texture URL.
  48213. */
  48214. private static _groundTextureCDNUrl;
  48215. /**
  48216. * Default skybox texture URL.
  48217. */
  48218. private static _skyboxTextureCDNUrl;
  48219. /**
  48220. * Default environment texture URL.
  48221. */
  48222. private static _environmentTextureCDNUrl;
  48223. /**
  48224. * Creates the default options for the helper.
  48225. */
  48226. private static _getDefaultOptions;
  48227. private _rootMesh;
  48228. /**
  48229. * Gets the root mesh created by the helper.
  48230. */
  48231. readonly rootMesh: Mesh;
  48232. private _skybox;
  48233. /**
  48234. * Gets the skybox created by the helper.
  48235. */
  48236. readonly skybox: Nullable<Mesh>;
  48237. private _skyboxTexture;
  48238. /**
  48239. * Gets the skybox texture created by the helper.
  48240. */
  48241. readonly skyboxTexture: Nullable<BaseTexture>;
  48242. private _skyboxMaterial;
  48243. /**
  48244. * Gets the skybox material created by the helper.
  48245. */
  48246. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48247. private _ground;
  48248. /**
  48249. * Gets the ground mesh created by the helper.
  48250. */
  48251. readonly ground: Nullable<Mesh>;
  48252. private _groundTexture;
  48253. /**
  48254. * Gets the ground texture created by the helper.
  48255. */
  48256. readonly groundTexture: Nullable<BaseTexture>;
  48257. private _groundMirror;
  48258. /**
  48259. * Gets the ground mirror created by the helper.
  48260. */
  48261. readonly groundMirror: Nullable<MirrorTexture>;
  48262. /**
  48263. * Gets the ground mirror render list to helps pushing the meshes
  48264. * you wish in the ground reflection.
  48265. */
  48266. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48267. private _groundMaterial;
  48268. /**
  48269. * Gets the ground material created by the helper.
  48270. */
  48271. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48272. /**
  48273. * Stores the creation options.
  48274. */
  48275. private readonly _scene;
  48276. private _options;
  48277. /**
  48278. * This observable will be notified with any error during the creation of the environment,
  48279. * mainly texture creation errors.
  48280. */
  48281. onErrorObservable: Observable<{
  48282. message?: string;
  48283. exception?: any;
  48284. }>;
  48285. /**
  48286. * constructor
  48287. * @param options Defines the options we want to customize the helper
  48288. * @param scene The scene to add the material to
  48289. */
  48290. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48291. /**
  48292. * Updates the background according to the new options
  48293. * @param options
  48294. */
  48295. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48296. /**
  48297. * Sets the primary color of all the available elements.
  48298. * @param color the main color to affect to the ground and the background
  48299. */
  48300. setMainColor(color: Color3): void;
  48301. /**
  48302. * Setup the image processing according to the specified options.
  48303. */
  48304. private _setupImageProcessing;
  48305. /**
  48306. * Setup the environment texture according to the specified options.
  48307. */
  48308. private _setupEnvironmentTexture;
  48309. /**
  48310. * Setup the background according to the specified options.
  48311. */
  48312. private _setupBackground;
  48313. /**
  48314. * Get the scene sizes according to the setup.
  48315. */
  48316. private _getSceneSize;
  48317. /**
  48318. * Setup the ground according to the specified options.
  48319. */
  48320. private _setupGround;
  48321. /**
  48322. * Setup the ground material according to the specified options.
  48323. */
  48324. private _setupGroundMaterial;
  48325. /**
  48326. * Setup the ground diffuse texture according to the specified options.
  48327. */
  48328. private _setupGroundDiffuseTexture;
  48329. /**
  48330. * Setup the ground mirror texture according to the specified options.
  48331. */
  48332. private _setupGroundMirrorTexture;
  48333. /**
  48334. * Setup the ground to receive the mirror texture.
  48335. */
  48336. private _setupMirrorInGroundMaterial;
  48337. /**
  48338. * Setup the skybox according to the specified options.
  48339. */
  48340. private _setupSkybox;
  48341. /**
  48342. * Setup the skybox material according to the specified options.
  48343. */
  48344. private _setupSkyboxMaterial;
  48345. /**
  48346. * Setup the skybox reflection texture according to the specified options.
  48347. */
  48348. private _setupSkyboxReflectionTexture;
  48349. private _errorHandler;
  48350. /**
  48351. * Dispose all the elements created by the Helper.
  48352. */
  48353. dispose(): void;
  48354. }
  48355. }
  48356. declare module "babylonjs/Helpers/photoDome" {
  48357. import { Observable } from "babylonjs/Misc/observable";
  48358. import { Nullable } from "babylonjs/types";
  48359. import { Scene } from "babylonjs/scene";
  48360. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48361. import { Mesh } from "babylonjs/Meshes/mesh";
  48362. import { Texture } from "babylonjs/Materials/Textures/texture";
  48363. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48364. import "babylonjs/Meshes/Builders/sphereBuilder";
  48365. /**
  48366. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48367. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48368. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48369. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48370. */
  48371. export class PhotoDome extends TransformNode {
  48372. /**
  48373. * Define the image as a Monoscopic panoramic 360 image.
  48374. */
  48375. static readonly MODE_MONOSCOPIC: number;
  48376. /**
  48377. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48378. */
  48379. static readonly MODE_TOPBOTTOM: number;
  48380. /**
  48381. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48382. */
  48383. static readonly MODE_SIDEBYSIDE: number;
  48384. private _useDirectMapping;
  48385. /**
  48386. * The texture being displayed on the sphere
  48387. */
  48388. protected _photoTexture: Texture;
  48389. /**
  48390. * Gets or sets the texture being displayed on the sphere
  48391. */
  48392. photoTexture: Texture;
  48393. /**
  48394. * Observable raised when an error occured while loading the 360 image
  48395. */
  48396. onLoadErrorObservable: Observable<string>;
  48397. /**
  48398. * The skybox material
  48399. */
  48400. protected _material: BackgroundMaterial;
  48401. /**
  48402. * The surface used for the skybox
  48403. */
  48404. protected _mesh: Mesh;
  48405. /**
  48406. * Gets the mesh used for the skybox.
  48407. */
  48408. readonly mesh: Mesh;
  48409. /**
  48410. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48411. * Also see the options.resolution property.
  48412. */
  48413. fovMultiplier: number;
  48414. private _imageMode;
  48415. /**
  48416. * Gets or set the current video mode for the video. It can be:
  48417. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48418. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48419. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48420. */
  48421. imageMode: number;
  48422. /**
  48423. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48424. * @param name Element's name, child elements will append suffixes for their own names.
  48425. * @param urlsOfPhoto defines the url of the photo to display
  48426. * @param options defines an object containing optional or exposed sub element properties
  48427. * @param onError defines a callback called when an error occured while loading the texture
  48428. */
  48429. constructor(name: string, urlOfPhoto: string, options: {
  48430. resolution?: number;
  48431. size?: number;
  48432. useDirectMapping?: boolean;
  48433. faceForward?: boolean;
  48434. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48435. private _onBeforeCameraRenderObserver;
  48436. private _changeImageMode;
  48437. /**
  48438. * Releases resources associated with this node.
  48439. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48440. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48441. */
  48442. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48443. }
  48444. }
  48445. declare module "babylonjs/Misc/rgbdTextureTools" {
  48446. import "babylonjs/Shaders/rgbdDecode.fragment";
  48447. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48448. import { Texture } from "babylonjs/Materials/Textures/texture";
  48449. /**
  48450. * Class used to host RGBD texture specific utilities
  48451. */
  48452. export class RGBDTextureTools {
  48453. /**
  48454. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48455. * @param texture the texture to expand.
  48456. */
  48457. static ExpandRGBDTexture(texture: Texture): void;
  48458. }
  48459. }
  48460. declare module "babylonjs/Misc/brdfTextureTools" {
  48461. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48462. import { Scene } from "babylonjs/scene";
  48463. /**
  48464. * Class used to host texture specific utilities
  48465. */
  48466. export class BRDFTextureTools {
  48467. /**
  48468. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48469. * @param scene defines the hosting scene
  48470. * @returns the environment BRDF texture
  48471. */
  48472. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48473. private static _environmentBRDFBase64Texture;
  48474. }
  48475. }
  48476. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48477. import { Nullable } from "babylonjs/types";
  48478. import { Color3 } from "babylonjs/Maths/math.color";
  48479. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48480. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48481. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48482. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48483. import { Engine } from "babylonjs/Engines/engine";
  48484. import { Scene } from "babylonjs/scene";
  48485. /**
  48486. * @hidden
  48487. */
  48488. export interface IMaterialClearCoatDefines {
  48489. CLEARCOAT: boolean;
  48490. CLEARCOAT_DEFAULTIOR: boolean;
  48491. CLEARCOAT_TEXTURE: boolean;
  48492. CLEARCOAT_TEXTUREDIRECTUV: number;
  48493. CLEARCOAT_BUMP: boolean;
  48494. CLEARCOAT_BUMPDIRECTUV: number;
  48495. CLEARCOAT_TINT: boolean;
  48496. CLEARCOAT_TINT_TEXTURE: boolean;
  48497. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48498. /** @hidden */
  48499. _areTexturesDirty: boolean;
  48500. }
  48501. /**
  48502. * Define the code related to the clear coat parameters of the pbr material.
  48503. */
  48504. export class PBRClearCoatConfiguration {
  48505. /**
  48506. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48507. * The default fits with a polyurethane material.
  48508. */
  48509. private static readonly _DefaultIndexOfRefraction;
  48510. private _isEnabled;
  48511. /**
  48512. * Defines if the clear coat is enabled in the material.
  48513. */
  48514. isEnabled: boolean;
  48515. /**
  48516. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48517. */
  48518. intensity: number;
  48519. /**
  48520. * Defines the clear coat layer roughness.
  48521. */
  48522. roughness: number;
  48523. private _indexOfRefraction;
  48524. /**
  48525. * Defines the index of refraction of the clear coat.
  48526. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48527. * The default fits with a polyurethane material.
  48528. * Changing the default value is more performance intensive.
  48529. */
  48530. indexOfRefraction: number;
  48531. private _texture;
  48532. /**
  48533. * Stores the clear coat values in a texture.
  48534. */
  48535. texture: Nullable<BaseTexture>;
  48536. private _bumpTexture;
  48537. /**
  48538. * Define the clear coat specific bump texture.
  48539. */
  48540. bumpTexture: Nullable<BaseTexture>;
  48541. private _isTintEnabled;
  48542. /**
  48543. * Defines if the clear coat tint is enabled in the material.
  48544. */
  48545. isTintEnabled: boolean;
  48546. /**
  48547. * Defines the clear coat tint of the material.
  48548. * This is only use if tint is enabled
  48549. */
  48550. tintColor: Color3;
  48551. /**
  48552. * Defines the distance at which the tint color should be found in the
  48553. * clear coat media.
  48554. * This is only use if tint is enabled
  48555. */
  48556. tintColorAtDistance: number;
  48557. /**
  48558. * Defines the clear coat layer thickness.
  48559. * This is only use if tint is enabled
  48560. */
  48561. tintThickness: number;
  48562. private _tintTexture;
  48563. /**
  48564. * Stores the clear tint values in a texture.
  48565. * rgb is tint
  48566. * a is a thickness factor
  48567. */
  48568. tintTexture: Nullable<BaseTexture>;
  48569. /** @hidden */
  48570. private _internalMarkAllSubMeshesAsTexturesDirty;
  48571. /** @hidden */
  48572. _markAllSubMeshesAsTexturesDirty(): void;
  48573. /**
  48574. * Instantiate a new istance of clear coat configuration.
  48575. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48576. */
  48577. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48578. /**
  48579. * Gets wehter the submesh is ready to be used or not.
  48580. * @param defines the list of "defines" to update.
  48581. * @param scene defines the scene the material belongs to.
  48582. * @param engine defines the engine the material belongs to.
  48583. * @param disableBumpMap defines wether the material disables bump or not.
  48584. * @returns - boolean indicating that the submesh is ready or not.
  48585. */
  48586. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48587. /**
  48588. * Checks to see if a texture is used in the material.
  48589. * @param defines the list of "defines" to update.
  48590. * @param scene defines the scene to the material belongs to.
  48591. */
  48592. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48593. /**
  48594. * Binds the material data.
  48595. * @param uniformBuffer defines the Uniform buffer to fill in.
  48596. * @param scene defines the scene the material belongs to.
  48597. * @param engine defines the engine the material belongs to.
  48598. * @param disableBumpMap defines wether the material disables bump or not.
  48599. * @param isFrozen defines wether the material is frozen or not.
  48600. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48601. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48602. */
  48603. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48604. /**
  48605. * Checks to see if a texture is used in the material.
  48606. * @param texture - Base texture to use.
  48607. * @returns - Boolean specifying if a texture is used in the material.
  48608. */
  48609. hasTexture(texture: BaseTexture): boolean;
  48610. /**
  48611. * Returns an array of the actively used textures.
  48612. * @param activeTextures Array of BaseTextures
  48613. */
  48614. getActiveTextures(activeTextures: BaseTexture[]): void;
  48615. /**
  48616. * Returns the animatable textures.
  48617. * @param animatables Array of animatable textures.
  48618. */
  48619. getAnimatables(animatables: IAnimatable[]): void;
  48620. /**
  48621. * Disposes the resources of the material.
  48622. * @param forceDisposeTextures - Forces the disposal of all textures.
  48623. */
  48624. dispose(forceDisposeTextures?: boolean): void;
  48625. /**
  48626. * Get the current class name of the texture useful for serialization or dynamic coding.
  48627. * @returns "PBRClearCoatConfiguration"
  48628. */
  48629. getClassName(): string;
  48630. /**
  48631. * Add fallbacks to the effect fallbacks list.
  48632. * @param defines defines the Base texture to use.
  48633. * @param fallbacks defines the current fallback list.
  48634. * @param currentRank defines the current fallback rank.
  48635. * @returns the new fallback rank.
  48636. */
  48637. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48638. /**
  48639. * Add the required uniforms to the current list.
  48640. * @param uniforms defines the current uniform list.
  48641. */
  48642. static AddUniforms(uniforms: string[]): void;
  48643. /**
  48644. * Add the required samplers to the current list.
  48645. * @param samplers defines the current sampler list.
  48646. */
  48647. static AddSamplers(samplers: string[]): void;
  48648. /**
  48649. * Add the required uniforms to the current buffer.
  48650. * @param uniformBuffer defines the current uniform buffer.
  48651. */
  48652. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48653. /**
  48654. * Makes a duplicate of the current configuration into another one.
  48655. * @param clearCoatConfiguration define the config where to copy the info
  48656. */
  48657. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48658. /**
  48659. * Serializes this clear coat configuration.
  48660. * @returns - An object with the serialized config.
  48661. */
  48662. serialize(): any;
  48663. /**
  48664. * Parses a anisotropy Configuration from a serialized object.
  48665. * @param source - Serialized object.
  48666. * @param scene Defines the scene we are parsing for
  48667. * @param rootUrl Defines the rootUrl to load from
  48668. */
  48669. parse(source: any, scene: Scene, rootUrl: string): void;
  48670. }
  48671. }
  48672. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48673. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48675. import { Vector2 } from "babylonjs/Maths/math.vector";
  48676. import { Scene } from "babylonjs/scene";
  48677. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48678. import { Nullable } from "babylonjs/types";
  48679. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48680. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48681. /**
  48682. * @hidden
  48683. */
  48684. export interface IMaterialAnisotropicDefines {
  48685. ANISOTROPIC: boolean;
  48686. ANISOTROPIC_TEXTURE: boolean;
  48687. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48688. MAINUV1: boolean;
  48689. _areTexturesDirty: boolean;
  48690. _needUVs: boolean;
  48691. }
  48692. /**
  48693. * Define the code related to the anisotropic parameters of the pbr material.
  48694. */
  48695. export class PBRAnisotropicConfiguration {
  48696. private _isEnabled;
  48697. /**
  48698. * Defines if the anisotropy is enabled in the material.
  48699. */
  48700. isEnabled: boolean;
  48701. /**
  48702. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48703. */
  48704. intensity: number;
  48705. /**
  48706. * Defines if the effect is along the tangents, bitangents or in between.
  48707. * By default, the effect is "strectching" the highlights along the tangents.
  48708. */
  48709. direction: Vector2;
  48710. private _texture;
  48711. /**
  48712. * Stores the anisotropy values in a texture.
  48713. * rg is direction (like normal from -1 to 1)
  48714. * b is a intensity
  48715. */
  48716. texture: Nullable<BaseTexture>;
  48717. /** @hidden */
  48718. private _internalMarkAllSubMeshesAsTexturesDirty;
  48719. /** @hidden */
  48720. _markAllSubMeshesAsTexturesDirty(): void;
  48721. /**
  48722. * Instantiate a new istance of anisotropy configuration.
  48723. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48724. */
  48725. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48726. /**
  48727. * Specifies that the submesh is ready to be used.
  48728. * @param defines the list of "defines" to update.
  48729. * @param scene defines the scene the material belongs to.
  48730. * @returns - boolean indicating that the submesh is ready or not.
  48731. */
  48732. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48733. /**
  48734. * Checks to see if a texture is used in the material.
  48735. * @param defines the list of "defines" to update.
  48736. * @param mesh the mesh we are preparing the defines for.
  48737. * @param scene defines the scene the material belongs to.
  48738. */
  48739. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48740. /**
  48741. * Binds the material data.
  48742. * @param uniformBuffer defines the Uniform buffer to fill in.
  48743. * @param scene defines the scene the material belongs to.
  48744. * @param isFrozen defines wether the material is frozen or not.
  48745. */
  48746. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48747. /**
  48748. * Checks to see if a texture is used in the material.
  48749. * @param texture - Base texture to use.
  48750. * @returns - Boolean specifying if a texture is used in the material.
  48751. */
  48752. hasTexture(texture: BaseTexture): boolean;
  48753. /**
  48754. * Returns an array of the actively used textures.
  48755. * @param activeTextures Array of BaseTextures
  48756. */
  48757. getActiveTextures(activeTextures: BaseTexture[]): void;
  48758. /**
  48759. * Returns the animatable textures.
  48760. * @param animatables Array of animatable textures.
  48761. */
  48762. getAnimatables(animatables: IAnimatable[]): void;
  48763. /**
  48764. * Disposes the resources of the material.
  48765. * @param forceDisposeTextures - Forces the disposal of all textures.
  48766. */
  48767. dispose(forceDisposeTextures?: boolean): void;
  48768. /**
  48769. * Get the current class name of the texture useful for serialization or dynamic coding.
  48770. * @returns "PBRAnisotropicConfiguration"
  48771. */
  48772. getClassName(): string;
  48773. /**
  48774. * Add fallbacks to the effect fallbacks list.
  48775. * @param defines defines the Base texture to use.
  48776. * @param fallbacks defines the current fallback list.
  48777. * @param currentRank defines the current fallback rank.
  48778. * @returns the new fallback rank.
  48779. */
  48780. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48781. /**
  48782. * Add the required uniforms to the current list.
  48783. * @param uniforms defines the current uniform list.
  48784. */
  48785. static AddUniforms(uniforms: string[]): void;
  48786. /**
  48787. * Add the required uniforms to the current buffer.
  48788. * @param uniformBuffer defines the current uniform buffer.
  48789. */
  48790. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48791. /**
  48792. * Add the required samplers to the current list.
  48793. * @param samplers defines the current sampler list.
  48794. */
  48795. static AddSamplers(samplers: string[]): void;
  48796. /**
  48797. * Makes a duplicate of the current configuration into another one.
  48798. * @param anisotropicConfiguration define the config where to copy the info
  48799. */
  48800. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48801. /**
  48802. * Serializes this anisotropy configuration.
  48803. * @returns - An object with the serialized config.
  48804. */
  48805. serialize(): any;
  48806. /**
  48807. * Parses a anisotropy Configuration from a serialized object.
  48808. * @param source - Serialized object.
  48809. * @param scene Defines the scene we are parsing for
  48810. * @param rootUrl Defines the rootUrl to load from
  48811. */
  48812. parse(source: any, scene: Scene, rootUrl: string): void;
  48813. }
  48814. }
  48815. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48816. import { Scene } from "babylonjs/scene";
  48817. /**
  48818. * @hidden
  48819. */
  48820. export interface IMaterialBRDFDefines {
  48821. BRDF_V_HEIGHT_CORRELATED: boolean;
  48822. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48823. SPHERICAL_HARMONICS: boolean;
  48824. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48825. /** @hidden */
  48826. _areMiscDirty: boolean;
  48827. }
  48828. /**
  48829. * Define the code related to the BRDF parameters of the pbr material.
  48830. */
  48831. export class PBRBRDFConfiguration {
  48832. /**
  48833. * Default value used for the energy conservation.
  48834. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48835. */
  48836. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48837. /**
  48838. * Default value used for the Smith Visibility Height Correlated mode.
  48839. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48840. */
  48841. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48842. /**
  48843. * Default value used for the IBL diffuse part.
  48844. * This can help switching back to the polynomials mode globally which is a tiny bit
  48845. * less GPU intensive at the drawback of a lower quality.
  48846. */
  48847. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48848. /**
  48849. * Default value used for activating energy conservation for the specular workflow.
  48850. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48851. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48852. */
  48853. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48854. private _useEnergyConservation;
  48855. /**
  48856. * Defines if the material uses energy conservation.
  48857. */
  48858. useEnergyConservation: boolean;
  48859. private _useSmithVisibilityHeightCorrelated;
  48860. /**
  48861. * LEGACY Mode set to false
  48862. * Defines if the material uses height smith correlated visibility term.
  48863. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48864. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48865. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48866. * Not relying on height correlated will also disable energy conservation.
  48867. */
  48868. useSmithVisibilityHeightCorrelated: boolean;
  48869. private _useSphericalHarmonics;
  48870. /**
  48871. * LEGACY Mode set to false
  48872. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48873. * diffuse part of the IBL.
  48874. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48875. * to the ground truth.
  48876. */
  48877. useSphericalHarmonics: boolean;
  48878. private _useSpecularGlossinessInputEnergyConservation;
  48879. /**
  48880. * Defines if the material uses energy conservation, when the specular workflow is active.
  48881. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48882. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48883. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48884. */
  48885. useSpecularGlossinessInputEnergyConservation: boolean;
  48886. /** @hidden */
  48887. private _internalMarkAllSubMeshesAsMiscDirty;
  48888. /** @hidden */
  48889. _markAllSubMeshesAsMiscDirty(): void;
  48890. /**
  48891. * Instantiate a new istance of clear coat configuration.
  48892. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48893. */
  48894. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48895. /**
  48896. * Checks to see if a texture is used in the material.
  48897. * @param defines the list of "defines" to update.
  48898. */
  48899. prepareDefines(defines: IMaterialBRDFDefines): void;
  48900. /**
  48901. * Get the current class name of the texture useful for serialization or dynamic coding.
  48902. * @returns "PBRClearCoatConfiguration"
  48903. */
  48904. getClassName(): string;
  48905. /**
  48906. * Makes a duplicate of the current configuration into another one.
  48907. * @param brdfConfiguration define the config where to copy the info
  48908. */
  48909. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48910. /**
  48911. * Serializes this BRDF configuration.
  48912. * @returns - An object with the serialized config.
  48913. */
  48914. serialize(): any;
  48915. /**
  48916. * Parses a anisotropy Configuration from a serialized object.
  48917. * @param source - Serialized object.
  48918. * @param scene Defines the scene we are parsing for
  48919. * @param rootUrl Defines the rootUrl to load from
  48920. */
  48921. parse(source: any, scene: Scene, rootUrl: string): void;
  48922. }
  48923. }
  48924. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48925. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48926. import { Color3 } from "babylonjs/Maths/math.color";
  48927. import { Scene } from "babylonjs/scene";
  48928. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48929. import { Nullable } from "babylonjs/types";
  48930. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48931. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48932. /**
  48933. * @hidden
  48934. */
  48935. export interface IMaterialSheenDefines {
  48936. SHEEN: boolean;
  48937. SHEEN_TEXTURE: boolean;
  48938. SHEEN_TEXTUREDIRECTUV: number;
  48939. SHEEN_LINKWITHALBEDO: boolean;
  48940. /** @hidden */
  48941. _areTexturesDirty: boolean;
  48942. }
  48943. /**
  48944. * Define the code related to the Sheen parameters of the pbr material.
  48945. */
  48946. export class PBRSheenConfiguration {
  48947. private _isEnabled;
  48948. /**
  48949. * Defines if the material uses sheen.
  48950. */
  48951. isEnabled: boolean;
  48952. private _linkSheenWithAlbedo;
  48953. /**
  48954. * Defines if the sheen is linked to the sheen color.
  48955. */
  48956. linkSheenWithAlbedo: boolean;
  48957. /**
  48958. * Defines the sheen intensity.
  48959. */
  48960. intensity: number;
  48961. /**
  48962. * Defines the sheen color.
  48963. */
  48964. color: Color3;
  48965. private _texture;
  48966. /**
  48967. * Stores the sheen tint values in a texture.
  48968. * rgb is tint
  48969. * a is a intensity
  48970. */
  48971. texture: Nullable<BaseTexture>;
  48972. /** @hidden */
  48973. private _internalMarkAllSubMeshesAsTexturesDirty;
  48974. /** @hidden */
  48975. _markAllSubMeshesAsTexturesDirty(): void;
  48976. /**
  48977. * Instantiate a new istance of clear coat configuration.
  48978. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48979. */
  48980. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48981. /**
  48982. * Specifies that the submesh is ready to be used.
  48983. * @param defines the list of "defines" to update.
  48984. * @param scene defines the scene the material belongs to.
  48985. * @returns - boolean indicating that the submesh is ready or not.
  48986. */
  48987. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48988. /**
  48989. * Checks to see if a texture is used in the material.
  48990. * @param defines the list of "defines" to update.
  48991. * @param scene defines the scene the material belongs to.
  48992. */
  48993. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48994. /**
  48995. * Binds the material data.
  48996. * @param uniformBuffer defines the Uniform buffer to fill in.
  48997. * @param scene defines the scene the material belongs to.
  48998. * @param isFrozen defines wether the material is frozen or not.
  48999. */
  49000. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49001. /**
  49002. * Checks to see if a texture is used in the material.
  49003. * @param texture - Base texture to use.
  49004. * @returns - Boolean specifying if a texture is used in the material.
  49005. */
  49006. hasTexture(texture: BaseTexture): boolean;
  49007. /**
  49008. * Returns an array of the actively used textures.
  49009. * @param activeTextures Array of BaseTextures
  49010. */
  49011. getActiveTextures(activeTextures: BaseTexture[]): void;
  49012. /**
  49013. * Returns the animatable textures.
  49014. * @param animatables Array of animatable textures.
  49015. */
  49016. getAnimatables(animatables: IAnimatable[]): void;
  49017. /**
  49018. * Disposes the resources of the material.
  49019. * @param forceDisposeTextures - Forces the disposal of all textures.
  49020. */
  49021. dispose(forceDisposeTextures?: boolean): void;
  49022. /**
  49023. * Get the current class name of the texture useful for serialization or dynamic coding.
  49024. * @returns "PBRSheenConfiguration"
  49025. */
  49026. getClassName(): string;
  49027. /**
  49028. * Add fallbacks to the effect fallbacks list.
  49029. * @param defines defines the Base texture to use.
  49030. * @param fallbacks defines the current fallback list.
  49031. * @param currentRank defines the current fallback rank.
  49032. * @returns the new fallback rank.
  49033. */
  49034. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49035. /**
  49036. * Add the required uniforms to the current list.
  49037. * @param uniforms defines the current uniform list.
  49038. */
  49039. static AddUniforms(uniforms: string[]): void;
  49040. /**
  49041. * Add the required uniforms to the current buffer.
  49042. * @param uniformBuffer defines the current uniform buffer.
  49043. */
  49044. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49045. /**
  49046. * Add the required samplers to the current list.
  49047. * @param samplers defines the current sampler list.
  49048. */
  49049. static AddSamplers(samplers: string[]): void;
  49050. /**
  49051. * Makes a duplicate of the current configuration into another one.
  49052. * @param sheenConfiguration define the config where to copy the info
  49053. */
  49054. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49055. /**
  49056. * Serializes this BRDF configuration.
  49057. * @returns - An object with the serialized config.
  49058. */
  49059. serialize(): any;
  49060. /**
  49061. * Parses a anisotropy Configuration from a serialized object.
  49062. * @param source - Serialized object.
  49063. * @param scene Defines the scene we are parsing for
  49064. * @param rootUrl Defines the rootUrl to load from
  49065. */
  49066. parse(source: any, scene: Scene, rootUrl: string): void;
  49067. }
  49068. }
  49069. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49070. import { Nullable } from "babylonjs/types";
  49071. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49072. import { Color3 } from "babylonjs/Maths/math.color";
  49073. import { SmartArray } from "babylonjs/Misc/smartArray";
  49074. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49075. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49076. import { Effect } from "babylonjs/Materials/effect";
  49077. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49078. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49079. import { Engine } from "babylonjs/Engines/engine";
  49080. import { Scene } from "babylonjs/scene";
  49081. /**
  49082. * @hidden
  49083. */
  49084. export interface IMaterialSubSurfaceDefines {
  49085. SUBSURFACE: boolean;
  49086. SS_REFRACTION: boolean;
  49087. SS_TRANSLUCENCY: boolean;
  49088. SS_SCATERRING: boolean;
  49089. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49090. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49091. SS_REFRACTIONMAP_3D: boolean;
  49092. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49093. SS_LODINREFRACTIONALPHA: boolean;
  49094. SS_GAMMAREFRACTION: boolean;
  49095. SS_RGBDREFRACTION: boolean;
  49096. SS_LINEARSPECULARREFRACTION: boolean;
  49097. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49098. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49099. /** @hidden */
  49100. _areTexturesDirty: boolean;
  49101. }
  49102. /**
  49103. * Define the code related to the sub surface parameters of the pbr material.
  49104. */
  49105. export class PBRSubSurfaceConfiguration {
  49106. private _isRefractionEnabled;
  49107. /**
  49108. * Defines if the refraction is enabled in the material.
  49109. */
  49110. isRefractionEnabled: boolean;
  49111. private _isTranslucencyEnabled;
  49112. /**
  49113. * Defines if the translucency is enabled in the material.
  49114. */
  49115. isTranslucencyEnabled: boolean;
  49116. private _isScatteringEnabled;
  49117. /**
  49118. * Defines the refraction intensity of the material.
  49119. * The refraction when enabled replaces the Diffuse part of the material.
  49120. * The intensity helps transitionning between diffuse and refraction.
  49121. */
  49122. refractionIntensity: number;
  49123. /**
  49124. * Defines the translucency intensity of the material.
  49125. * When translucency has been enabled, this defines how much of the "translucency"
  49126. * is addded to the diffuse part of the material.
  49127. */
  49128. translucencyIntensity: number;
  49129. /**
  49130. * Defines the scattering intensity of the material.
  49131. * When scattering has been enabled, this defines how much of the "scattered light"
  49132. * is addded to the diffuse part of the material.
  49133. */
  49134. scatteringIntensity: number;
  49135. private _thicknessTexture;
  49136. /**
  49137. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49138. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49139. * 0 would mean minimumThickness
  49140. * 1 would mean maximumThickness
  49141. * The other channels might be use as a mask to vary the different effects intensity.
  49142. */
  49143. thicknessTexture: Nullable<BaseTexture>;
  49144. private _refractionTexture;
  49145. /**
  49146. * Defines the texture to use for refraction.
  49147. */
  49148. refractionTexture: Nullable<BaseTexture>;
  49149. private _indexOfRefraction;
  49150. /**
  49151. * Defines the index of refraction used in the material.
  49152. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49153. */
  49154. indexOfRefraction: number;
  49155. private _invertRefractionY;
  49156. /**
  49157. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49158. */
  49159. invertRefractionY: boolean;
  49160. private _linkRefractionWithTransparency;
  49161. /**
  49162. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49163. * Materials half opaque for instance using refraction could benefit from this control.
  49164. */
  49165. linkRefractionWithTransparency: boolean;
  49166. /**
  49167. * Defines the minimum thickness stored in the thickness map.
  49168. * If no thickness map is defined, this value will be used to simulate thickness.
  49169. */
  49170. minimumThickness: number;
  49171. /**
  49172. * Defines the maximum thickness stored in the thickness map.
  49173. */
  49174. maximumThickness: number;
  49175. /**
  49176. * Defines the volume tint of the material.
  49177. * This is used for both translucency and scattering.
  49178. */
  49179. tintColor: Color3;
  49180. /**
  49181. * Defines the distance at which the tint color should be found in the media.
  49182. * This is used for refraction only.
  49183. */
  49184. tintColorAtDistance: number;
  49185. /**
  49186. * Defines how far each channel transmit through the media.
  49187. * It is defined as a color to simplify it selection.
  49188. */
  49189. diffusionDistance: Color3;
  49190. private _useMaskFromThicknessTexture;
  49191. /**
  49192. * Stores the intensity of the different subsurface effects in the thickness texture.
  49193. * * the green channel is the translucency intensity.
  49194. * * the blue channel is the scattering intensity.
  49195. * * the alpha channel is the refraction intensity.
  49196. */
  49197. useMaskFromThicknessTexture: boolean;
  49198. /** @hidden */
  49199. private _internalMarkAllSubMeshesAsTexturesDirty;
  49200. /** @hidden */
  49201. _markAllSubMeshesAsTexturesDirty(): void;
  49202. /**
  49203. * Instantiate a new istance of sub surface configuration.
  49204. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49205. */
  49206. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49207. /**
  49208. * Gets wehter the submesh is ready to be used or not.
  49209. * @param defines the list of "defines" to update.
  49210. * @param scene defines the scene the material belongs to.
  49211. * @returns - boolean indicating that the submesh is ready or not.
  49212. */
  49213. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49214. /**
  49215. * Checks to see if a texture is used in the material.
  49216. * @param defines the list of "defines" to update.
  49217. * @param scene defines the scene to the material belongs to.
  49218. */
  49219. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49220. /**
  49221. * Binds the material data.
  49222. * @param uniformBuffer defines the Uniform buffer to fill in.
  49223. * @param scene defines the scene the material belongs to.
  49224. * @param engine defines the engine the material belongs to.
  49225. * @param isFrozen defines wether the material is frozen or not.
  49226. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49227. */
  49228. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49229. /**
  49230. * Unbinds the material from the mesh.
  49231. * @param activeEffect defines the effect that should be unbound from.
  49232. * @returns true if unbound, otherwise false
  49233. */
  49234. unbind(activeEffect: Effect): boolean;
  49235. /**
  49236. * Returns the texture used for refraction or null if none is used.
  49237. * @param scene defines the scene the material belongs to.
  49238. * @returns - Refraction texture if present. If no refraction texture and refraction
  49239. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49240. */
  49241. private _getRefractionTexture;
  49242. /**
  49243. * Returns true if alpha blending should be disabled.
  49244. */
  49245. readonly disableAlphaBlending: boolean;
  49246. /**
  49247. * Fills the list of render target textures.
  49248. * @param renderTargets the list of render targets to update
  49249. */
  49250. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49251. /**
  49252. * Checks to see if a texture is used in the material.
  49253. * @param texture - Base texture to use.
  49254. * @returns - Boolean specifying if a texture is used in the material.
  49255. */
  49256. hasTexture(texture: BaseTexture): boolean;
  49257. /**
  49258. * Gets a boolean indicating that current material needs to register RTT
  49259. * @returns true if this uses a render target otherwise false.
  49260. */
  49261. hasRenderTargetTextures(): boolean;
  49262. /**
  49263. * Returns an array of the actively used textures.
  49264. * @param activeTextures Array of BaseTextures
  49265. */
  49266. getActiveTextures(activeTextures: BaseTexture[]): void;
  49267. /**
  49268. * Returns the animatable textures.
  49269. * @param animatables Array of animatable textures.
  49270. */
  49271. getAnimatables(animatables: IAnimatable[]): void;
  49272. /**
  49273. * Disposes the resources of the material.
  49274. * @param forceDisposeTextures - Forces the disposal of all textures.
  49275. */
  49276. dispose(forceDisposeTextures?: boolean): void;
  49277. /**
  49278. * Get the current class name of the texture useful for serialization or dynamic coding.
  49279. * @returns "PBRSubSurfaceConfiguration"
  49280. */
  49281. getClassName(): string;
  49282. /**
  49283. * Add fallbacks to the effect fallbacks list.
  49284. * @param defines defines the Base texture to use.
  49285. * @param fallbacks defines the current fallback list.
  49286. * @param currentRank defines the current fallback rank.
  49287. * @returns the new fallback rank.
  49288. */
  49289. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49290. /**
  49291. * Add the required uniforms to the current list.
  49292. * @param uniforms defines the current uniform list.
  49293. */
  49294. static AddUniforms(uniforms: string[]): void;
  49295. /**
  49296. * Add the required samplers to the current list.
  49297. * @param samplers defines the current sampler list.
  49298. */
  49299. static AddSamplers(samplers: string[]): void;
  49300. /**
  49301. * Add the required uniforms to the current buffer.
  49302. * @param uniformBuffer defines the current uniform buffer.
  49303. */
  49304. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49305. /**
  49306. * Makes a duplicate of the current configuration into another one.
  49307. * @param configuration define the config where to copy the info
  49308. */
  49309. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49310. /**
  49311. * Serializes this Sub Surface configuration.
  49312. * @returns - An object with the serialized config.
  49313. */
  49314. serialize(): any;
  49315. /**
  49316. * Parses a anisotropy Configuration from a serialized object.
  49317. * @param source - Serialized object.
  49318. * @param scene Defines the scene we are parsing for
  49319. * @param rootUrl Defines the rootUrl to load from
  49320. */
  49321. parse(source: any, scene: Scene, rootUrl: string): void;
  49322. }
  49323. }
  49324. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49325. /** @hidden */
  49326. export var pbrFragmentDeclaration: {
  49327. name: string;
  49328. shader: string;
  49329. };
  49330. }
  49331. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49332. /** @hidden */
  49333. export var pbrUboDeclaration: {
  49334. name: string;
  49335. shader: string;
  49336. };
  49337. }
  49338. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49339. /** @hidden */
  49340. export var pbrFragmentExtraDeclaration: {
  49341. name: string;
  49342. shader: string;
  49343. };
  49344. }
  49345. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49346. /** @hidden */
  49347. export var pbrFragmentSamplersDeclaration: {
  49348. name: string;
  49349. shader: string;
  49350. };
  49351. }
  49352. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49353. /** @hidden */
  49354. export var pbrHelperFunctions: {
  49355. name: string;
  49356. shader: string;
  49357. };
  49358. }
  49359. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49360. /** @hidden */
  49361. export var harmonicsFunctions: {
  49362. name: string;
  49363. shader: string;
  49364. };
  49365. }
  49366. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49367. /** @hidden */
  49368. export var pbrDirectLightingSetupFunctions: {
  49369. name: string;
  49370. shader: string;
  49371. };
  49372. }
  49373. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49374. /** @hidden */
  49375. export var pbrDirectLightingFalloffFunctions: {
  49376. name: string;
  49377. shader: string;
  49378. };
  49379. }
  49380. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49381. /** @hidden */
  49382. export var pbrBRDFFunctions: {
  49383. name: string;
  49384. shader: string;
  49385. };
  49386. }
  49387. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49388. /** @hidden */
  49389. export var pbrDirectLightingFunctions: {
  49390. name: string;
  49391. shader: string;
  49392. };
  49393. }
  49394. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49395. /** @hidden */
  49396. export var pbrIBLFunctions: {
  49397. name: string;
  49398. shader: string;
  49399. };
  49400. }
  49401. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49402. /** @hidden */
  49403. export var pbrDebug: {
  49404. name: string;
  49405. shader: string;
  49406. };
  49407. }
  49408. declare module "babylonjs/Shaders/pbr.fragment" {
  49409. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49410. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49411. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49412. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49413. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49414. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49415. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49416. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49417. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49418. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49419. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49420. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49421. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49422. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49423. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49424. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49425. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49426. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49427. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49428. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49429. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49430. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49431. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49432. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49433. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49434. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49435. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49436. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49437. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49438. /** @hidden */
  49439. export var pbrPixelShader: {
  49440. name: string;
  49441. shader: string;
  49442. };
  49443. }
  49444. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49445. /** @hidden */
  49446. export var pbrVertexDeclaration: {
  49447. name: string;
  49448. shader: string;
  49449. };
  49450. }
  49451. declare module "babylonjs/Shaders/pbr.vertex" {
  49452. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49453. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49454. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49455. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49456. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49457. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49458. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49459. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49460. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49461. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49462. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49463. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49464. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49465. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49466. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49467. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49468. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49469. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49470. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49471. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49472. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49473. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49474. /** @hidden */
  49475. export var pbrVertexShader: {
  49476. name: string;
  49477. shader: string;
  49478. };
  49479. }
  49480. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49481. import { Nullable } from "babylonjs/types";
  49482. import { Scene } from "babylonjs/scene";
  49483. import { Matrix } from "babylonjs/Maths/math.vector";
  49484. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49486. import { Mesh } from "babylonjs/Meshes/mesh";
  49487. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49488. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49489. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49490. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49491. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49492. import { Color3 } from "babylonjs/Maths/math.color";
  49493. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49494. import { Material } from "babylonjs/Materials/material";
  49495. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49496. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49497. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49498. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49499. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49500. import "babylonjs/Shaders/pbr.fragment";
  49501. import "babylonjs/Shaders/pbr.vertex";
  49502. /**
  49503. * Manages the defines for the PBR Material.
  49504. * @hidden
  49505. */
  49506. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49507. PBR: boolean;
  49508. MAINUV1: boolean;
  49509. MAINUV2: boolean;
  49510. UV1: boolean;
  49511. UV2: boolean;
  49512. ALBEDO: boolean;
  49513. ALBEDODIRECTUV: number;
  49514. VERTEXCOLOR: boolean;
  49515. AMBIENT: boolean;
  49516. AMBIENTDIRECTUV: number;
  49517. AMBIENTINGRAYSCALE: boolean;
  49518. OPACITY: boolean;
  49519. VERTEXALPHA: boolean;
  49520. OPACITYDIRECTUV: number;
  49521. OPACITYRGB: boolean;
  49522. ALPHATEST: boolean;
  49523. DEPTHPREPASS: boolean;
  49524. ALPHABLEND: boolean;
  49525. ALPHAFROMALBEDO: boolean;
  49526. ALPHATESTVALUE: string;
  49527. SPECULAROVERALPHA: boolean;
  49528. RADIANCEOVERALPHA: boolean;
  49529. ALPHAFRESNEL: boolean;
  49530. LINEARALPHAFRESNEL: boolean;
  49531. PREMULTIPLYALPHA: boolean;
  49532. EMISSIVE: boolean;
  49533. EMISSIVEDIRECTUV: number;
  49534. REFLECTIVITY: boolean;
  49535. REFLECTIVITYDIRECTUV: number;
  49536. SPECULARTERM: boolean;
  49537. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49538. MICROSURFACEAUTOMATIC: boolean;
  49539. LODBASEDMICROSFURACE: boolean;
  49540. MICROSURFACEMAP: boolean;
  49541. MICROSURFACEMAPDIRECTUV: number;
  49542. METALLICWORKFLOW: boolean;
  49543. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49544. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49545. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49546. AOSTOREINMETALMAPRED: boolean;
  49547. ENVIRONMENTBRDF: boolean;
  49548. ENVIRONMENTBRDF_RGBD: boolean;
  49549. NORMAL: boolean;
  49550. TANGENT: boolean;
  49551. BUMP: boolean;
  49552. BUMPDIRECTUV: number;
  49553. OBJECTSPACE_NORMALMAP: boolean;
  49554. PARALLAX: boolean;
  49555. PARALLAXOCCLUSION: boolean;
  49556. NORMALXYSCALE: boolean;
  49557. LIGHTMAP: boolean;
  49558. LIGHTMAPDIRECTUV: number;
  49559. USELIGHTMAPASSHADOWMAP: boolean;
  49560. GAMMALIGHTMAP: boolean;
  49561. RGBDLIGHTMAP: boolean;
  49562. REFLECTION: boolean;
  49563. REFLECTIONMAP_3D: boolean;
  49564. REFLECTIONMAP_SPHERICAL: boolean;
  49565. REFLECTIONMAP_PLANAR: boolean;
  49566. REFLECTIONMAP_CUBIC: boolean;
  49567. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49568. REFLECTIONMAP_PROJECTION: boolean;
  49569. REFLECTIONMAP_SKYBOX: boolean;
  49570. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49571. REFLECTIONMAP_EXPLICIT: boolean;
  49572. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49573. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49574. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49575. INVERTCUBICMAP: boolean;
  49576. USESPHERICALFROMREFLECTIONMAP: boolean;
  49577. USEIRRADIANCEMAP: boolean;
  49578. SPHERICAL_HARMONICS: boolean;
  49579. USESPHERICALINVERTEX: boolean;
  49580. REFLECTIONMAP_OPPOSITEZ: boolean;
  49581. LODINREFLECTIONALPHA: boolean;
  49582. GAMMAREFLECTION: boolean;
  49583. RGBDREFLECTION: boolean;
  49584. LINEARSPECULARREFLECTION: boolean;
  49585. RADIANCEOCCLUSION: boolean;
  49586. HORIZONOCCLUSION: boolean;
  49587. INSTANCES: boolean;
  49588. NUM_BONE_INFLUENCERS: number;
  49589. BonesPerMesh: number;
  49590. BONETEXTURE: boolean;
  49591. NONUNIFORMSCALING: boolean;
  49592. MORPHTARGETS: boolean;
  49593. MORPHTARGETS_NORMAL: boolean;
  49594. MORPHTARGETS_TANGENT: boolean;
  49595. MORPHTARGETS_UV: boolean;
  49596. NUM_MORPH_INFLUENCERS: number;
  49597. IMAGEPROCESSING: boolean;
  49598. VIGNETTE: boolean;
  49599. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49600. VIGNETTEBLENDMODEOPAQUE: boolean;
  49601. TONEMAPPING: boolean;
  49602. TONEMAPPING_ACES: boolean;
  49603. CONTRAST: boolean;
  49604. COLORCURVES: boolean;
  49605. COLORGRADING: boolean;
  49606. COLORGRADING3D: boolean;
  49607. SAMPLER3DGREENDEPTH: boolean;
  49608. SAMPLER3DBGRMAP: boolean;
  49609. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49610. EXPOSURE: boolean;
  49611. MULTIVIEW: boolean;
  49612. USEPHYSICALLIGHTFALLOFF: boolean;
  49613. USEGLTFLIGHTFALLOFF: boolean;
  49614. TWOSIDEDLIGHTING: boolean;
  49615. SHADOWFLOAT: boolean;
  49616. CLIPPLANE: boolean;
  49617. CLIPPLANE2: boolean;
  49618. CLIPPLANE3: boolean;
  49619. CLIPPLANE4: boolean;
  49620. POINTSIZE: boolean;
  49621. FOG: boolean;
  49622. LOGARITHMICDEPTH: boolean;
  49623. FORCENORMALFORWARD: boolean;
  49624. SPECULARAA: boolean;
  49625. CLEARCOAT: boolean;
  49626. CLEARCOAT_DEFAULTIOR: boolean;
  49627. CLEARCOAT_TEXTURE: boolean;
  49628. CLEARCOAT_TEXTUREDIRECTUV: number;
  49629. CLEARCOAT_BUMP: boolean;
  49630. CLEARCOAT_BUMPDIRECTUV: number;
  49631. CLEARCOAT_TINT: boolean;
  49632. CLEARCOAT_TINT_TEXTURE: boolean;
  49633. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49634. ANISOTROPIC: boolean;
  49635. ANISOTROPIC_TEXTURE: boolean;
  49636. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49637. BRDF_V_HEIGHT_CORRELATED: boolean;
  49638. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49639. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49640. SHEEN: boolean;
  49641. SHEEN_TEXTURE: boolean;
  49642. SHEEN_TEXTUREDIRECTUV: number;
  49643. SHEEN_LINKWITHALBEDO: boolean;
  49644. SUBSURFACE: boolean;
  49645. SS_REFRACTION: boolean;
  49646. SS_TRANSLUCENCY: boolean;
  49647. SS_SCATERRING: boolean;
  49648. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49649. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49650. SS_REFRACTIONMAP_3D: boolean;
  49651. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49652. SS_LODINREFRACTIONALPHA: boolean;
  49653. SS_GAMMAREFRACTION: boolean;
  49654. SS_RGBDREFRACTION: boolean;
  49655. SS_LINEARSPECULARREFRACTION: boolean;
  49656. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49657. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49658. UNLIT: boolean;
  49659. DEBUGMODE: number;
  49660. /**
  49661. * Initializes the PBR Material defines.
  49662. */
  49663. constructor();
  49664. /**
  49665. * Resets the PBR Material defines.
  49666. */
  49667. reset(): void;
  49668. }
  49669. /**
  49670. * The Physically based material base class of BJS.
  49671. *
  49672. * This offers the main features of a standard PBR material.
  49673. * For more information, please refer to the documentation :
  49674. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49675. */
  49676. export abstract class PBRBaseMaterial extends PushMaterial {
  49677. /**
  49678. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49679. */
  49680. static readonly PBRMATERIAL_OPAQUE: number;
  49681. /**
  49682. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49683. */
  49684. static readonly PBRMATERIAL_ALPHATEST: number;
  49685. /**
  49686. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49687. */
  49688. static readonly PBRMATERIAL_ALPHABLEND: number;
  49689. /**
  49690. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49691. * They are also discarded below the alpha cutoff threshold to improve performances.
  49692. */
  49693. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49694. /**
  49695. * Defines the default value of how much AO map is occluding the analytical lights
  49696. * (point spot...).
  49697. */
  49698. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49699. /**
  49700. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49701. */
  49702. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49703. /**
  49704. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49705. * to enhance interoperability with other engines.
  49706. */
  49707. static readonly LIGHTFALLOFF_GLTF: number;
  49708. /**
  49709. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49710. * to enhance interoperability with other materials.
  49711. */
  49712. static readonly LIGHTFALLOFF_STANDARD: number;
  49713. /**
  49714. * Intensity of the direct lights e.g. the four lights available in your scene.
  49715. * This impacts both the direct diffuse and specular highlights.
  49716. */
  49717. protected _directIntensity: number;
  49718. /**
  49719. * Intensity of the emissive part of the material.
  49720. * This helps controlling the emissive effect without modifying the emissive color.
  49721. */
  49722. protected _emissiveIntensity: number;
  49723. /**
  49724. * Intensity of the environment e.g. how much the environment will light the object
  49725. * either through harmonics for rough material or through the refelction for shiny ones.
  49726. */
  49727. protected _environmentIntensity: number;
  49728. /**
  49729. * This is a special control allowing the reduction of the specular highlights coming from the
  49730. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49731. */
  49732. protected _specularIntensity: number;
  49733. /**
  49734. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49735. */
  49736. private _lightingInfos;
  49737. /**
  49738. * Debug Control allowing disabling the bump map on this material.
  49739. */
  49740. protected _disableBumpMap: boolean;
  49741. /**
  49742. * AKA Diffuse Texture in standard nomenclature.
  49743. */
  49744. protected _albedoTexture: Nullable<BaseTexture>;
  49745. /**
  49746. * AKA Occlusion Texture in other nomenclature.
  49747. */
  49748. protected _ambientTexture: Nullable<BaseTexture>;
  49749. /**
  49750. * AKA Occlusion Texture Intensity in other nomenclature.
  49751. */
  49752. protected _ambientTextureStrength: number;
  49753. /**
  49754. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49755. * 1 means it completely occludes it
  49756. * 0 mean it has no impact
  49757. */
  49758. protected _ambientTextureImpactOnAnalyticalLights: number;
  49759. /**
  49760. * Stores the alpha values in a texture.
  49761. */
  49762. protected _opacityTexture: Nullable<BaseTexture>;
  49763. /**
  49764. * Stores the reflection values in a texture.
  49765. */
  49766. protected _reflectionTexture: Nullable<BaseTexture>;
  49767. /**
  49768. * Stores the emissive values in a texture.
  49769. */
  49770. protected _emissiveTexture: Nullable<BaseTexture>;
  49771. /**
  49772. * AKA Specular texture in other nomenclature.
  49773. */
  49774. protected _reflectivityTexture: Nullable<BaseTexture>;
  49775. /**
  49776. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49777. */
  49778. protected _metallicTexture: Nullable<BaseTexture>;
  49779. /**
  49780. * Specifies the metallic scalar of the metallic/roughness workflow.
  49781. * Can also be used to scale the metalness values of the metallic texture.
  49782. */
  49783. protected _metallic: Nullable<number>;
  49784. /**
  49785. * Specifies the roughness scalar of the metallic/roughness workflow.
  49786. * Can also be used to scale the roughness values of the metallic texture.
  49787. */
  49788. protected _roughness: Nullable<number>;
  49789. /**
  49790. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49791. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49792. */
  49793. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49794. /**
  49795. * Stores surface normal data used to displace a mesh in a texture.
  49796. */
  49797. protected _bumpTexture: Nullable<BaseTexture>;
  49798. /**
  49799. * Stores the pre-calculated light information of a mesh in a texture.
  49800. */
  49801. protected _lightmapTexture: Nullable<BaseTexture>;
  49802. /**
  49803. * The color of a material in ambient lighting.
  49804. */
  49805. protected _ambientColor: Color3;
  49806. /**
  49807. * AKA Diffuse Color in other nomenclature.
  49808. */
  49809. protected _albedoColor: Color3;
  49810. /**
  49811. * AKA Specular Color in other nomenclature.
  49812. */
  49813. protected _reflectivityColor: Color3;
  49814. /**
  49815. * The color applied when light is reflected from a material.
  49816. */
  49817. protected _reflectionColor: Color3;
  49818. /**
  49819. * The color applied when light is emitted from a material.
  49820. */
  49821. protected _emissiveColor: Color3;
  49822. /**
  49823. * AKA Glossiness in other nomenclature.
  49824. */
  49825. protected _microSurface: number;
  49826. /**
  49827. * Specifies that the material will use the light map as a show map.
  49828. */
  49829. protected _useLightmapAsShadowmap: boolean;
  49830. /**
  49831. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49832. * makes the reflect vector face the model (under horizon).
  49833. */
  49834. protected _useHorizonOcclusion: boolean;
  49835. /**
  49836. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49837. * too much the area relying on ambient texture to define their ambient occlusion.
  49838. */
  49839. protected _useRadianceOcclusion: boolean;
  49840. /**
  49841. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49842. */
  49843. protected _useAlphaFromAlbedoTexture: boolean;
  49844. /**
  49845. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49846. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49847. */
  49848. protected _useSpecularOverAlpha: boolean;
  49849. /**
  49850. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49851. */
  49852. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49853. /**
  49854. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49855. */
  49856. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49857. /**
  49858. * Specifies if the metallic texture contains the roughness information in its green channel.
  49859. */
  49860. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49861. /**
  49862. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49863. */
  49864. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49865. /**
  49866. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49867. */
  49868. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49869. /**
  49870. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49871. */
  49872. protected _useAmbientInGrayScale: boolean;
  49873. /**
  49874. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49875. * The material will try to infer what glossiness each pixel should be.
  49876. */
  49877. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49878. /**
  49879. * Defines the falloff type used in this material.
  49880. * It by default is Physical.
  49881. */
  49882. protected _lightFalloff: number;
  49883. /**
  49884. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49885. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49886. */
  49887. protected _useRadianceOverAlpha: boolean;
  49888. /**
  49889. * Allows using an object space normal map (instead of tangent space).
  49890. */
  49891. protected _useObjectSpaceNormalMap: boolean;
  49892. /**
  49893. * Allows using the bump map in parallax mode.
  49894. */
  49895. protected _useParallax: boolean;
  49896. /**
  49897. * Allows using the bump map in parallax occlusion mode.
  49898. */
  49899. protected _useParallaxOcclusion: boolean;
  49900. /**
  49901. * Controls the scale bias of the parallax mode.
  49902. */
  49903. protected _parallaxScaleBias: number;
  49904. /**
  49905. * If sets to true, disables all the lights affecting the material.
  49906. */
  49907. protected _disableLighting: boolean;
  49908. /**
  49909. * Number of Simultaneous lights allowed on the material.
  49910. */
  49911. protected _maxSimultaneousLights: number;
  49912. /**
  49913. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49914. */
  49915. protected _invertNormalMapX: boolean;
  49916. /**
  49917. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49918. */
  49919. protected _invertNormalMapY: boolean;
  49920. /**
  49921. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49922. */
  49923. protected _twoSidedLighting: boolean;
  49924. /**
  49925. * Defines the alpha limits in alpha test mode.
  49926. */
  49927. protected _alphaCutOff: number;
  49928. /**
  49929. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49930. */
  49931. protected _forceAlphaTest: boolean;
  49932. /**
  49933. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49934. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49935. */
  49936. protected _useAlphaFresnel: boolean;
  49937. /**
  49938. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49939. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49940. */
  49941. protected _useLinearAlphaFresnel: boolean;
  49942. /**
  49943. * The transparency mode of the material.
  49944. */
  49945. protected _transparencyMode: Nullable<number>;
  49946. /**
  49947. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49948. * from cos thetav and roughness:
  49949. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49950. */
  49951. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49952. /**
  49953. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49954. */
  49955. protected _forceIrradianceInFragment: boolean;
  49956. /**
  49957. * Force normal to face away from face.
  49958. */
  49959. protected _forceNormalForward: boolean;
  49960. /**
  49961. * Enables specular anti aliasing in the PBR shader.
  49962. * It will both interacts on the Geometry for analytical and IBL lighting.
  49963. * It also prefilter the roughness map based on the bump values.
  49964. */
  49965. protected _enableSpecularAntiAliasing: boolean;
  49966. /**
  49967. * Default configuration related to image processing available in the PBR Material.
  49968. */
  49969. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49970. /**
  49971. * Keep track of the image processing observer to allow dispose and replace.
  49972. */
  49973. private _imageProcessingObserver;
  49974. /**
  49975. * Attaches a new image processing configuration to the PBR Material.
  49976. * @param configuration
  49977. */
  49978. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49979. /**
  49980. * Stores the available render targets.
  49981. */
  49982. private _renderTargets;
  49983. /**
  49984. * Sets the global ambient color for the material used in lighting calculations.
  49985. */
  49986. private _globalAmbientColor;
  49987. /**
  49988. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49989. */
  49990. private _useLogarithmicDepth;
  49991. /**
  49992. * If set to true, no lighting calculations will be applied.
  49993. */
  49994. private _unlit;
  49995. private _debugMode;
  49996. /**
  49997. * @hidden
  49998. * This is reserved for the inspector.
  49999. * Defines the material debug mode.
  50000. * It helps seeing only some components of the material while troubleshooting.
  50001. */
  50002. debugMode: number;
  50003. /**
  50004. * @hidden
  50005. * This is reserved for the inspector.
  50006. * Specify from where on screen the debug mode should start.
  50007. * The value goes from -1 (full screen) to 1 (not visible)
  50008. * It helps with side by side comparison against the final render
  50009. * This defaults to -1
  50010. */
  50011. private debugLimit;
  50012. /**
  50013. * @hidden
  50014. * This is reserved for the inspector.
  50015. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50016. * You can use the factor to better multiply the final value.
  50017. */
  50018. private debugFactor;
  50019. /**
  50020. * Defines the clear coat layer parameters for the material.
  50021. */
  50022. readonly clearCoat: PBRClearCoatConfiguration;
  50023. /**
  50024. * Defines the anisotropic parameters for the material.
  50025. */
  50026. readonly anisotropy: PBRAnisotropicConfiguration;
  50027. /**
  50028. * Defines the BRDF parameters for the material.
  50029. */
  50030. readonly brdf: PBRBRDFConfiguration;
  50031. /**
  50032. * Defines the Sheen parameters for the material.
  50033. */
  50034. readonly sheen: PBRSheenConfiguration;
  50035. /**
  50036. * Defines the SubSurface parameters for the material.
  50037. */
  50038. readonly subSurface: PBRSubSurfaceConfiguration;
  50039. /**
  50040. * Custom callback helping to override the default shader used in the material.
  50041. */
  50042. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50043. protected _rebuildInParallel: boolean;
  50044. /**
  50045. * Instantiates a new PBRMaterial instance.
  50046. *
  50047. * @param name The material name
  50048. * @param scene The scene the material will be use in.
  50049. */
  50050. constructor(name: string, scene: Scene);
  50051. /**
  50052. * Gets a boolean indicating that current material needs to register RTT
  50053. */
  50054. readonly hasRenderTargetTextures: boolean;
  50055. /**
  50056. * Gets the name of the material class.
  50057. */
  50058. getClassName(): string;
  50059. /**
  50060. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50061. */
  50062. /**
  50063. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50064. */
  50065. useLogarithmicDepth: boolean;
  50066. /**
  50067. * Gets the current transparency mode.
  50068. */
  50069. /**
  50070. * Sets the transparency mode of the material.
  50071. *
  50072. * | Value | Type | Description |
  50073. * | ----- | ----------------------------------- | ----------- |
  50074. * | 0 | OPAQUE | |
  50075. * | 1 | ALPHATEST | |
  50076. * | 2 | ALPHABLEND | |
  50077. * | 3 | ALPHATESTANDBLEND | |
  50078. *
  50079. */
  50080. transparencyMode: Nullable<number>;
  50081. /**
  50082. * Returns true if alpha blending should be disabled.
  50083. */
  50084. private readonly _disableAlphaBlending;
  50085. /**
  50086. * Specifies whether or not this material should be rendered in alpha blend mode.
  50087. */
  50088. needAlphaBlending(): boolean;
  50089. /**
  50090. * Specifies if the mesh will require alpha blending.
  50091. * @param mesh - BJS mesh.
  50092. */
  50093. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50094. /**
  50095. * Specifies whether or not this material should be rendered in alpha test mode.
  50096. */
  50097. needAlphaTesting(): boolean;
  50098. /**
  50099. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50100. */
  50101. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50102. /**
  50103. * Gets the texture used for the alpha test.
  50104. */
  50105. getAlphaTestTexture(): Nullable<BaseTexture>;
  50106. /**
  50107. * Specifies that the submesh is ready to be used.
  50108. * @param mesh - BJS mesh.
  50109. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50110. * @param useInstances - Specifies that instances should be used.
  50111. * @returns - boolean indicating that the submesh is ready or not.
  50112. */
  50113. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50114. /**
  50115. * Specifies if the material uses metallic roughness workflow.
  50116. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50117. */
  50118. isMetallicWorkflow(): boolean;
  50119. private _prepareEffect;
  50120. private _prepareDefines;
  50121. /**
  50122. * Force shader compilation
  50123. */
  50124. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  50125. clipPlane: boolean;
  50126. }>): void;
  50127. /**
  50128. * Initializes the uniform buffer layout for the shader.
  50129. */
  50130. buildUniformLayout(): void;
  50131. /**
  50132. * Unbinds the material from the mesh
  50133. */
  50134. unbind(): void;
  50135. /**
  50136. * Binds the submesh data.
  50137. * @param world - The world matrix.
  50138. * @param mesh - The BJS mesh.
  50139. * @param subMesh - A submesh of the BJS mesh.
  50140. */
  50141. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50142. /**
  50143. * Returns the animatable textures.
  50144. * @returns - Array of animatable textures.
  50145. */
  50146. getAnimatables(): IAnimatable[];
  50147. /**
  50148. * Returns the texture used for reflections.
  50149. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50150. */
  50151. private _getReflectionTexture;
  50152. /**
  50153. * Returns an array of the actively used textures.
  50154. * @returns - Array of BaseTextures
  50155. */
  50156. getActiveTextures(): BaseTexture[];
  50157. /**
  50158. * Checks to see if a texture is used in the material.
  50159. * @param texture - Base texture to use.
  50160. * @returns - Boolean specifying if a texture is used in the material.
  50161. */
  50162. hasTexture(texture: BaseTexture): boolean;
  50163. /**
  50164. * Disposes the resources of the material.
  50165. * @param forceDisposeEffect - Forces the disposal of effects.
  50166. * @param forceDisposeTextures - Forces the disposal of all textures.
  50167. */
  50168. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50169. }
  50170. }
  50171. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50172. import { Nullable } from "babylonjs/types";
  50173. import { Scene } from "babylonjs/scene";
  50174. import { Color3 } from "babylonjs/Maths/math.color";
  50175. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50176. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50177. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50178. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50179. /**
  50180. * The Physically based material of BJS.
  50181. *
  50182. * This offers the main features of a standard PBR material.
  50183. * For more information, please refer to the documentation :
  50184. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50185. */
  50186. export class PBRMaterial extends PBRBaseMaterial {
  50187. /**
  50188. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50189. */
  50190. static readonly PBRMATERIAL_OPAQUE: number;
  50191. /**
  50192. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50193. */
  50194. static readonly PBRMATERIAL_ALPHATEST: number;
  50195. /**
  50196. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50197. */
  50198. static readonly PBRMATERIAL_ALPHABLEND: number;
  50199. /**
  50200. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50201. * They are also discarded below the alpha cutoff threshold to improve performances.
  50202. */
  50203. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50204. /**
  50205. * Defines the default value of how much AO map is occluding the analytical lights
  50206. * (point spot...).
  50207. */
  50208. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50209. /**
  50210. * Intensity of the direct lights e.g. the four lights available in your scene.
  50211. * This impacts both the direct diffuse and specular highlights.
  50212. */
  50213. directIntensity: number;
  50214. /**
  50215. * Intensity of the emissive part of the material.
  50216. * This helps controlling the emissive effect without modifying the emissive color.
  50217. */
  50218. emissiveIntensity: number;
  50219. /**
  50220. * Intensity of the environment e.g. how much the environment will light the object
  50221. * either through harmonics for rough material or through the refelction for shiny ones.
  50222. */
  50223. environmentIntensity: number;
  50224. /**
  50225. * This is a special control allowing the reduction of the specular highlights coming from the
  50226. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50227. */
  50228. specularIntensity: number;
  50229. /**
  50230. * Debug Control allowing disabling the bump map on this material.
  50231. */
  50232. disableBumpMap: boolean;
  50233. /**
  50234. * AKA Diffuse Texture in standard nomenclature.
  50235. */
  50236. albedoTexture: BaseTexture;
  50237. /**
  50238. * AKA Occlusion Texture in other nomenclature.
  50239. */
  50240. ambientTexture: BaseTexture;
  50241. /**
  50242. * AKA Occlusion Texture Intensity in other nomenclature.
  50243. */
  50244. ambientTextureStrength: number;
  50245. /**
  50246. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50247. * 1 means it completely occludes it
  50248. * 0 mean it has no impact
  50249. */
  50250. ambientTextureImpactOnAnalyticalLights: number;
  50251. /**
  50252. * Stores the alpha values in a texture.
  50253. */
  50254. opacityTexture: BaseTexture;
  50255. /**
  50256. * Stores the reflection values in a texture.
  50257. */
  50258. reflectionTexture: Nullable<BaseTexture>;
  50259. /**
  50260. * Stores the emissive values in a texture.
  50261. */
  50262. emissiveTexture: BaseTexture;
  50263. /**
  50264. * AKA Specular texture in other nomenclature.
  50265. */
  50266. reflectivityTexture: BaseTexture;
  50267. /**
  50268. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50269. */
  50270. metallicTexture: BaseTexture;
  50271. /**
  50272. * Specifies the metallic scalar of the metallic/roughness workflow.
  50273. * Can also be used to scale the metalness values of the metallic texture.
  50274. */
  50275. metallic: Nullable<number>;
  50276. /**
  50277. * Specifies the roughness scalar of the metallic/roughness workflow.
  50278. * Can also be used to scale the roughness values of the metallic texture.
  50279. */
  50280. roughness: Nullable<number>;
  50281. /**
  50282. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50283. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50284. */
  50285. microSurfaceTexture: BaseTexture;
  50286. /**
  50287. * Stores surface normal data used to displace a mesh in a texture.
  50288. */
  50289. bumpTexture: BaseTexture;
  50290. /**
  50291. * Stores the pre-calculated light information of a mesh in a texture.
  50292. */
  50293. lightmapTexture: BaseTexture;
  50294. /**
  50295. * Stores the refracted light information in a texture.
  50296. */
  50297. refractionTexture: Nullable<BaseTexture>;
  50298. /**
  50299. * The color of a material in ambient lighting.
  50300. */
  50301. ambientColor: Color3;
  50302. /**
  50303. * AKA Diffuse Color in other nomenclature.
  50304. */
  50305. albedoColor: Color3;
  50306. /**
  50307. * AKA Specular Color in other nomenclature.
  50308. */
  50309. reflectivityColor: Color3;
  50310. /**
  50311. * The color reflected from the material.
  50312. */
  50313. reflectionColor: Color3;
  50314. /**
  50315. * The color emitted from the material.
  50316. */
  50317. emissiveColor: Color3;
  50318. /**
  50319. * AKA Glossiness in other nomenclature.
  50320. */
  50321. microSurface: number;
  50322. /**
  50323. * source material index of refraction (IOR)' / 'destination material IOR.
  50324. */
  50325. indexOfRefraction: number;
  50326. /**
  50327. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50328. */
  50329. invertRefractionY: boolean;
  50330. /**
  50331. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50332. * Materials half opaque for instance using refraction could benefit from this control.
  50333. */
  50334. linkRefractionWithTransparency: boolean;
  50335. /**
  50336. * If true, the light map contains occlusion information instead of lighting info.
  50337. */
  50338. useLightmapAsShadowmap: boolean;
  50339. /**
  50340. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50341. */
  50342. useAlphaFromAlbedoTexture: boolean;
  50343. /**
  50344. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50345. */
  50346. forceAlphaTest: boolean;
  50347. /**
  50348. * Defines the alpha limits in alpha test mode.
  50349. */
  50350. alphaCutOff: number;
  50351. /**
  50352. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50353. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50354. */
  50355. useSpecularOverAlpha: boolean;
  50356. /**
  50357. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50358. */
  50359. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50360. /**
  50361. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50362. */
  50363. useRoughnessFromMetallicTextureAlpha: boolean;
  50364. /**
  50365. * Specifies if the metallic texture contains the roughness information in its green channel.
  50366. */
  50367. useRoughnessFromMetallicTextureGreen: boolean;
  50368. /**
  50369. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50370. */
  50371. useMetallnessFromMetallicTextureBlue: boolean;
  50372. /**
  50373. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50374. */
  50375. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50376. /**
  50377. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50378. */
  50379. useAmbientInGrayScale: boolean;
  50380. /**
  50381. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50382. * The material will try to infer what glossiness each pixel should be.
  50383. */
  50384. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50385. /**
  50386. * BJS is using an harcoded light falloff based on a manually sets up range.
  50387. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50388. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50389. */
  50390. /**
  50391. * BJS is using an harcoded light falloff based on a manually sets up range.
  50392. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50393. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50394. */
  50395. usePhysicalLightFalloff: boolean;
  50396. /**
  50397. * In order to support the falloff compatibility with gltf, a special mode has been added
  50398. * to reproduce the gltf light falloff.
  50399. */
  50400. /**
  50401. * In order to support the falloff compatibility with gltf, a special mode has been added
  50402. * to reproduce the gltf light falloff.
  50403. */
  50404. useGLTFLightFalloff: boolean;
  50405. /**
  50406. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50407. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50408. */
  50409. useRadianceOverAlpha: boolean;
  50410. /**
  50411. * Allows using an object space normal map (instead of tangent space).
  50412. */
  50413. useObjectSpaceNormalMap: boolean;
  50414. /**
  50415. * Allows using the bump map in parallax mode.
  50416. */
  50417. useParallax: boolean;
  50418. /**
  50419. * Allows using the bump map in parallax occlusion mode.
  50420. */
  50421. useParallaxOcclusion: boolean;
  50422. /**
  50423. * Controls the scale bias of the parallax mode.
  50424. */
  50425. parallaxScaleBias: number;
  50426. /**
  50427. * If sets to true, disables all the lights affecting the material.
  50428. */
  50429. disableLighting: boolean;
  50430. /**
  50431. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50432. */
  50433. forceIrradianceInFragment: boolean;
  50434. /**
  50435. * Number of Simultaneous lights allowed on the material.
  50436. */
  50437. maxSimultaneousLights: number;
  50438. /**
  50439. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50440. */
  50441. invertNormalMapX: boolean;
  50442. /**
  50443. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50444. */
  50445. invertNormalMapY: boolean;
  50446. /**
  50447. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50448. */
  50449. twoSidedLighting: boolean;
  50450. /**
  50451. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50452. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50453. */
  50454. useAlphaFresnel: boolean;
  50455. /**
  50456. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50457. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50458. */
  50459. useLinearAlphaFresnel: boolean;
  50460. /**
  50461. * Let user defines the brdf lookup texture used for IBL.
  50462. * A default 8bit version is embedded but you could point at :
  50463. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50464. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50465. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50466. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50467. */
  50468. environmentBRDFTexture: Nullable<BaseTexture>;
  50469. /**
  50470. * Force normal to face away from face.
  50471. */
  50472. forceNormalForward: boolean;
  50473. /**
  50474. * Enables specular anti aliasing in the PBR shader.
  50475. * It will both interacts on the Geometry for analytical and IBL lighting.
  50476. * It also prefilter the roughness map based on the bump values.
  50477. */
  50478. enableSpecularAntiAliasing: boolean;
  50479. /**
  50480. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50481. * makes the reflect vector face the model (under horizon).
  50482. */
  50483. useHorizonOcclusion: boolean;
  50484. /**
  50485. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50486. * too much the area relying on ambient texture to define their ambient occlusion.
  50487. */
  50488. useRadianceOcclusion: boolean;
  50489. /**
  50490. * If set to true, no lighting calculations will be applied.
  50491. */
  50492. unlit: boolean;
  50493. /**
  50494. * Gets the image processing configuration used either in this material.
  50495. */
  50496. /**
  50497. * Sets the Default image processing configuration used either in the this material.
  50498. *
  50499. * If sets to null, the scene one is in use.
  50500. */
  50501. imageProcessingConfiguration: ImageProcessingConfiguration;
  50502. /**
  50503. * Gets wether the color curves effect is enabled.
  50504. */
  50505. /**
  50506. * Sets wether the color curves effect is enabled.
  50507. */
  50508. cameraColorCurvesEnabled: boolean;
  50509. /**
  50510. * Gets wether the color grading effect is enabled.
  50511. */
  50512. /**
  50513. * Gets wether the color grading effect is enabled.
  50514. */
  50515. cameraColorGradingEnabled: boolean;
  50516. /**
  50517. * Gets wether tonemapping is enabled or not.
  50518. */
  50519. /**
  50520. * Sets wether tonemapping is enabled or not
  50521. */
  50522. cameraToneMappingEnabled: boolean;
  50523. /**
  50524. * The camera exposure used on this material.
  50525. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50526. * This corresponds to a photographic exposure.
  50527. */
  50528. /**
  50529. * The camera exposure used on this material.
  50530. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50531. * This corresponds to a photographic exposure.
  50532. */
  50533. cameraExposure: number;
  50534. /**
  50535. * Gets The camera contrast used on this material.
  50536. */
  50537. /**
  50538. * Sets The camera contrast used on this material.
  50539. */
  50540. cameraContrast: number;
  50541. /**
  50542. * Gets the Color Grading 2D Lookup Texture.
  50543. */
  50544. /**
  50545. * Sets the Color Grading 2D Lookup Texture.
  50546. */
  50547. cameraColorGradingTexture: Nullable<BaseTexture>;
  50548. /**
  50549. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50550. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50551. * 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;
  50552. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50553. */
  50554. /**
  50555. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50556. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50557. * 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;
  50558. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50559. */
  50560. cameraColorCurves: Nullable<ColorCurves>;
  50561. /**
  50562. * Instantiates a new PBRMaterial instance.
  50563. *
  50564. * @param name The material name
  50565. * @param scene The scene the material will be use in.
  50566. */
  50567. constructor(name: string, scene: Scene);
  50568. /**
  50569. * Returns the name of this material class.
  50570. */
  50571. getClassName(): string;
  50572. /**
  50573. * Makes a duplicate of the current material.
  50574. * @param name - name to use for the new material.
  50575. */
  50576. clone(name: string): PBRMaterial;
  50577. /**
  50578. * Serializes this PBR Material.
  50579. * @returns - An object with the serialized material.
  50580. */
  50581. serialize(): any;
  50582. /**
  50583. * Parses a PBR Material from a serialized object.
  50584. * @param source - Serialized object.
  50585. * @param scene - BJS scene instance.
  50586. * @param rootUrl - url for the scene object
  50587. * @returns - PBRMaterial
  50588. */
  50589. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50590. }
  50591. }
  50592. declare module "babylonjs/Misc/dds" {
  50593. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50594. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50595. import { Nullable } from "babylonjs/types";
  50596. import { Scene } from "babylonjs/scene";
  50597. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50598. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50599. /**
  50600. * Direct draw surface info
  50601. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50602. */
  50603. export interface DDSInfo {
  50604. /**
  50605. * Width of the texture
  50606. */
  50607. width: number;
  50608. /**
  50609. * Width of the texture
  50610. */
  50611. height: number;
  50612. /**
  50613. * Number of Mipmaps for the texture
  50614. * @see https://en.wikipedia.org/wiki/Mipmap
  50615. */
  50616. mipmapCount: number;
  50617. /**
  50618. * If the textures format is a known fourCC format
  50619. * @see https://www.fourcc.org/
  50620. */
  50621. isFourCC: boolean;
  50622. /**
  50623. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50624. */
  50625. isRGB: boolean;
  50626. /**
  50627. * If the texture is a lumincance format
  50628. */
  50629. isLuminance: boolean;
  50630. /**
  50631. * If this is a cube texture
  50632. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50633. */
  50634. isCube: boolean;
  50635. /**
  50636. * If the texture is a compressed format eg. FOURCC_DXT1
  50637. */
  50638. isCompressed: boolean;
  50639. /**
  50640. * The dxgiFormat of the texture
  50641. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50642. */
  50643. dxgiFormat: number;
  50644. /**
  50645. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50646. */
  50647. textureType: number;
  50648. /**
  50649. * Sphericle polynomial created for the dds texture
  50650. */
  50651. sphericalPolynomial?: SphericalPolynomial;
  50652. }
  50653. /**
  50654. * Class used to provide DDS decompression tools
  50655. */
  50656. export class DDSTools {
  50657. /**
  50658. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50659. */
  50660. static StoreLODInAlphaChannel: boolean;
  50661. /**
  50662. * Gets DDS information from an array buffer
  50663. * @param arrayBuffer defines the array buffer to read data from
  50664. * @returns the DDS information
  50665. */
  50666. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50667. private static _FloatView;
  50668. private static _Int32View;
  50669. private static _ToHalfFloat;
  50670. private static _FromHalfFloat;
  50671. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50672. private static _GetHalfFloatRGBAArrayBuffer;
  50673. private static _GetFloatRGBAArrayBuffer;
  50674. private static _GetFloatAsUIntRGBAArrayBuffer;
  50675. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50676. private static _GetRGBAArrayBuffer;
  50677. private static _ExtractLongWordOrder;
  50678. private static _GetRGBArrayBuffer;
  50679. private static _GetLuminanceArrayBuffer;
  50680. /**
  50681. * Uploads DDS Levels to a Babylon Texture
  50682. * @hidden
  50683. */
  50684. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50685. }
  50686. module "babylonjs/Engines/thinEngine" {
  50687. interface ThinEngine {
  50688. /**
  50689. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50690. * @param rootUrl defines the url where the file to load is located
  50691. * @param scene defines the current scene
  50692. * @param lodScale defines scale to apply to the mip map selection
  50693. * @param lodOffset defines offset to apply to the mip map selection
  50694. * @param onLoad defines an optional callback raised when the texture is loaded
  50695. * @param onError defines an optional callback raised if there is an issue to load the texture
  50696. * @param format defines the format of the data
  50697. * @param forcedExtension defines the extension to use to pick the right loader
  50698. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50699. * @returns the cube texture as an InternalTexture
  50700. */
  50701. 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;
  50702. }
  50703. }
  50704. }
  50705. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50706. import { Nullable } from "babylonjs/types";
  50707. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50708. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50709. /**
  50710. * Implementation of the DDS Texture Loader.
  50711. * @hidden
  50712. */
  50713. export class _DDSTextureLoader implements IInternalTextureLoader {
  50714. /**
  50715. * Defines wether the loader supports cascade loading the different faces.
  50716. */
  50717. readonly supportCascades: boolean;
  50718. /**
  50719. * This returns if the loader support the current file information.
  50720. * @param extension defines the file extension of the file being loaded
  50721. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50722. * @param fallback defines the fallback internal texture if any
  50723. * @param isBase64 defines whether the texture is encoded as a base64
  50724. * @param isBuffer defines whether the texture data are stored as a buffer
  50725. * @returns true if the loader can load the specified file
  50726. */
  50727. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50728. /**
  50729. * Transform the url before loading if required.
  50730. * @param rootUrl the url of the texture
  50731. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50732. * @returns the transformed texture
  50733. */
  50734. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50735. /**
  50736. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50737. * @param rootUrl the url of the texture
  50738. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50739. * @returns the fallback texture
  50740. */
  50741. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50742. /**
  50743. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50744. * @param data contains the texture data
  50745. * @param texture defines the BabylonJS internal texture
  50746. * @param createPolynomials will be true if polynomials have been requested
  50747. * @param onLoad defines the callback to trigger once the texture is ready
  50748. * @param onError defines the callback to trigger in case of error
  50749. */
  50750. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50751. /**
  50752. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50753. * @param data contains the texture data
  50754. * @param texture defines the BabylonJS internal texture
  50755. * @param callback defines the method to call once ready to upload
  50756. */
  50757. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50758. }
  50759. }
  50760. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50761. import { Nullable } from "babylonjs/types";
  50762. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50763. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50764. /**
  50765. * Implementation of the ENV Texture Loader.
  50766. * @hidden
  50767. */
  50768. export class _ENVTextureLoader implements IInternalTextureLoader {
  50769. /**
  50770. * Defines wether the loader supports cascade loading the different faces.
  50771. */
  50772. readonly supportCascades: boolean;
  50773. /**
  50774. * This returns if the loader support the current file information.
  50775. * @param extension defines the file extension of the file being loaded
  50776. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50777. * @param fallback defines the fallback internal texture if any
  50778. * @param isBase64 defines whether the texture is encoded as a base64
  50779. * @param isBuffer defines whether the texture data are stored as a buffer
  50780. * @returns true if the loader can load the specified file
  50781. */
  50782. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50783. /**
  50784. * Transform the url before loading if required.
  50785. * @param rootUrl the url of the texture
  50786. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50787. * @returns the transformed texture
  50788. */
  50789. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50790. /**
  50791. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50792. * @param rootUrl the url of the texture
  50793. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50794. * @returns the fallback texture
  50795. */
  50796. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50797. /**
  50798. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50799. * @param data contains the texture data
  50800. * @param texture defines the BabylonJS internal texture
  50801. * @param createPolynomials will be true if polynomials have been requested
  50802. * @param onLoad defines the callback to trigger once the texture is ready
  50803. * @param onError defines the callback to trigger in case of error
  50804. */
  50805. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50806. /**
  50807. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50808. * @param data contains the texture data
  50809. * @param texture defines the BabylonJS internal texture
  50810. * @param callback defines the method to call once ready to upload
  50811. */
  50812. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50813. }
  50814. }
  50815. declare module "babylonjs/Misc/khronosTextureContainer" {
  50816. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50817. /**
  50818. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50819. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50820. */
  50821. export class KhronosTextureContainer {
  50822. /** contents of the KTX container file */
  50823. arrayBuffer: any;
  50824. private static HEADER_LEN;
  50825. private static COMPRESSED_2D;
  50826. private static COMPRESSED_3D;
  50827. private static TEX_2D;
  50828. private static TEX_3D;
  50829. /**
  50830. * Gets the openGL type
  50831. */
  50832. glType: number;
  50833. /**
  50834. * Gets the openGL type size
  50835. */
  50836. glTypeSize: number;
  50837. /**
  50838. * Gets the openGL format
  50839. */
  50840. glFormat: number;
  50841. /**
  50842. * Gets the openGL internal format
  50843. */
  50844. glInternalFormat: number;
  50845. /**
  50846. * Gets the base internal format
  50847. */
  50848. glBaseInternalFormat: number;
  50849. /**
  50850. * Gets image width in pixel
  50851. */
  50852. pixelWidth: number;
  50853. /**
  50854. * Gets image height in pixel
  50855. */
  50856. pixelHeight: number;
  50857. /**
  50858. * Gets image depth in pixels
  50859. */
  50860. pixelDepth: number;
  50861. /**
  50862. * Gets the number of array elements
  50863. */
  50864. numberOfArrayElements: number;
  50865. /**
  50866. * Gets the number of faces
  50867. */
  50868. numberOfFaces: number;
  50869. /**
  50870. * Gets the number of mipmap levels
  50871. */
  50872. numberOfMipmapLevels: number;
  50873. /**
  50874. * Gets the bytes of key value data
  50875. */
  50876. bytesOfKeyValueData: number;
  50877. /**
  50878. * Gets the load type
  50879. */
  50880. loadType: number;
  50881. /**
  50882. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50883. */
  50884. isInvalid: boolean;
  50885. /**
  50886. * Creates a new KhronosTextureContainer
  50887. * @param arrayBuffer contents of the KTX container file
  50888. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50889. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50890. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50891. */
  50892. constructor(
  50893. /** contents of the KTX container file */
  50894. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50895. /**
  50896. * Uploads KTX content to a Babylon Texture.
  50897. * It is assumed that the texture has already been created & is currently bound
  50898. * @hidden
  50899. */
  50900. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50901. private _upload2DCompressedLevels;
  50902. }
  50903. }
  50904. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50905. import { Nullable } from "babylonjs/types";
  50906. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50907. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50908. /**
  50909. * Implementation of the KTX Texture Loader.
  50910. * @hidden
  50911. */
  50912. export class _KTXTextureLoader implements IInternalTextureLoader {
  50913. /**
  50914. * Defines wether the loader supports cascade loading the different faces.
  50915. */
  50916. readonly supportCascades: boolean;
  50917. /**
  50918. * This returns if the loader support the current file information.
  50919. * @param extension defines the file extension of the file being loaded
  50920. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50921. * @param fallback defines the fallback internal texture if any
  50922. * @param isBase64 defines whether the texture is encoded as a base64
  50923. * @param isBuffer defines whether the texture data are stored as a buffer
  50924. * @returns true if the loader can load the specified file
  50925. */
  50926. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50927. /**
  50928. * Transform the url before loading if required.
  50929. * @param rootUrl the url of the texture
  50930. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50931. * @returns the transformed texture
  50932. */
  50933. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50934. /**
  50935. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50936. * @param rootUrl the url of the texture
  50937. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50938. * @returns the fallback texture
  50939. */
  50940. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50941. /**
  50942. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50943. * @param data contains the texture data
  50944. * @param texture defines the BabylonJS internal texture
  50945. * @param createPolynomials will be true if polynomials have been requested
  50946. * @param onLoad defines the callback to trigger once the texture is ready
  50947. * @param onError defines the callback to trigger in case of error
  50948. */
  50949. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50950. /**
  50951. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50952. * @param data contains the texture data
  50953. * @param texture defines the BabylonJS internal texture
  50954. * @param callback defines the method to call once ready to upload
  50955. */
  50956. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50957. }
  50958. }
  50959. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50960. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50961. import { Scene } from "babylonjs/scene";
  50962. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50963. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50964. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50965. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50966. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50967. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50969. /**
  50970. * Options for the default xr helper
  50971. */
  50972. export class WebXRDefaultExperienceOptions {
  50973. /**
  50974. * Floor meshes that should be used for teleporting
  50975. */
  50976. floorMeshes: Array<AbstractMesh>;
  50977. }
  50978. /**
  50979. * Default experience which provides a similar setup to the previous webVRExperience
  50980. */
  50981. export class WebXRDefaultExperience {
  50982. /**
  50983. * Base experience
  50984. */
  50985. baseExperience: WebXRExperienceHelper;
  50986. /**
  50987. * Input experience extension
  50988. */
  50989. input: WebXRInput;
  50990. /**
  50991. * Loads the controller models
  50992. */
  50993. controllerModelLoader: WebXRControllerModelLoader;
  50994. /**
  50995. * Enables laser pointer and selection
  50996. */
  50997. pointerSelection: WebXRControllerPointerSelection;
  50998. /**
  50999. * Enables teleportation
  51000. */
  51001. teleportation: WebXRControllerTeleportation;
  51002. /**
  51003. * Enables ui for enetering/exiting xr
  51004. */
  51005. enterExitUI: WebXREnterExitUI;
  51006. /**
  51007. * Default output canvas xr should render to
  51008. */
  51009. outputCanvas: WebXRManagedOutputCanvas;
  51010. /**
  51011. * Creates the default xr experience
  51012. * @param scene scene
  51013. * @param options options for basic configuration
  51014. * @returns resulting WebXRDefaultExperience
  51015. */
  51016. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51017. private constructor();
  51018. /**
  51019. * DIsposes of the experience helper
  51020. */
  51021. dispose(): void;
  51022. }
  51023. }
  51024. declare module "babylonjs/Helpers/sceneHelpers" {
  51025. import { Nullable } from "babylonjs/types";
  51026. import { Mesh } from "babylonjs/Meshes/mesh";
  51027. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51028. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51029. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51030. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51031. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51032. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51033. import "babylonjs/Meshes/Builders/boxBuilder";
  51034. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51035. /** @hidden */
  51036. export var _forceSceneHelpersToBundle: boolean;
  51037. module "babylonjs/scene" {
  51038. interface Scene {
  51039. /**
  51040. * Creates a default light for the scene.
  51041. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51042. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51043. */
  51044. createDefaultLight(replace?: boolean): void;
  51045. /**
  51046. * Creates a default camera for the scene.
  51047. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51048. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51049. * @param replace has default false, when true replaces the active camera in the scene
  51050. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51051. */
  51052. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51053. /**
  51054. * Creates a default camera and a default light.
  51055. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51056. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51057. * @param replace has the default false, when true replaces the active camera/light in the scene
  51058. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51059. */
  51060. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51061. /**
  51062. * Creates a new sky box
  51063. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51064. * @param environmentTexture defines the texture to use as environment texture
  51065. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51066. * @param scale defines the overall scale of the skybox
  51067. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51068. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51069. * @returns a new mesh holding the sky box
  51070. */
  51071. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51072. /**
  51073. * Creates a new environment
  51074. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51075. * @param options defines the options you can use to configure the environment
  51076. * @returns the new EnvironmentHelper
  51077. */
  51078. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51079. /**
  51080. * Creates a new VREXperienceHelper
  51081. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51082. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51083. * @returns a new VREXperienceHelper
  51084. */
  51085. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51086. /**
  51087. * Creates a new WebXRDefaultExperience
  51088. * @see http://doc.babylonjs.com/how_to/webxr
  51089. * @param options experience options
  51090. * @returns a promise for a new WebXRDefaultExperience
  51091. */
  51092. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51093. }
  51094. }
  51095. }
  51096. declare module "babylonjs/Helpers/videoDome" {
  51097. import { Scene } from "babylonjs/scene";
  51098. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51099. import { Mesh } from "babylonjs/Meshes/mesh";
  51100. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51101. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51102. import "babylonjs/Meshes/Builders/sphereBuilder";
  51103. /**
  51104. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51105. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51106. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51107. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51108. */
  51109. export class VideoDome extends TransformNode {
  51110. /**
  51111. * Define the video source as a Monoscopic panoramic 360 video.
  51112. */
  51113. static readonly MODE_MONOSCOPIC: number;
  51114. /**
  51115. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51116. */
  51117. static readonly MODE_TOPBOTTOM: number;
  51118. /**
  51119. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51120. */
  51121. static readonly MODE_SIDEBYSIDE: number;
  51122. private _halfDome;
  51123. private _useDirectMapping;
  51124. /**
  51125. * The video texture being displayed on the sphere
  51126. */
  51127. protected _videoTexture: VideoTexture;
  51128. /**
  51129. * Gets the video texture being displayed on the sphere
  51130. */
  51131. readonly videoTexture: VideoTexture;
  51132. /**
  51133. * The skybox material
  51134. */
  51135. protected _material: BackgroundMaterial;
  51136. /**
  51137. * The surface used for the skybox
  51138. */
  51139. protected _mesh: Mesh;
  51140. /**
  51141. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51142. */
  51143. private _halfDomeMask;
  51144. /**
  51145. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51146. * Also see the options.resolution property.
  51147. */
  51148. fovMultiplier: number;
  51149. private _videoMode;
  51150. /**
  51151. * Gets or set the current video mode for the video. It can be:
  51152. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51153. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51154. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51155. */
  51156. videoMode: number;
  51157. /**
  51158. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51159. *
  51160. */
  51161. /**
  51162. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51163. */
  51164. halfDome: boolean;
  51165. /**
  51166. * Oberserver used in Stereoscopic VR Mode.
  51167. */
  51168. private _onBeforeCameraRenderObserver;
  51169. /**
  51170. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51171. * @param name Element's name, child elements will append suffixes for their own names.
  51172. * @param urlsOrVideo defines the url(s) or the video element to use
  51173. * @param options An object containing optional or exposed sub element properties
  51174. */
  51175. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51176. resolution?: number;
  51177. clickToPlay?: boolean;
  51178. autoPlay?: boolean;
  51179. loop?: boolean;
  51180. size?: number;
  51181. poster?: string;
  51182. faceForward?: boolean;
  51183. useDirectMapping?: boolean;
  51184. halfDomeMode?: boolean;
  51185. }, scene: Scene);
  51186. private _changeVideoMode;
  51187. /**
  51188. * Releases resources associated with this node.
  51189. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51190. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51191. */
  51192. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51193. }
  51194. }
  51195. declare module "babylonjs/Helpers/index" {
  51196. export * from "babylonjs/Helpers/environmentHelper";
  51197. export * from "babylonjs/Helpers/photoDome";
  51198. export * from "babylonjs/Helpers/sceneHelpers";
  51199. export * from "babylonjs/Helpers/videoDome";
  51200. }
  51201. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51202. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51203. import { IDisposable } from "babylonjs/scene";
  51204. import { Engine } from "babylonjs/Engines/engine";
  51205. /**
  51206. * This class can be used to get instrumentation data from a Babylon engine
  51207. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51208. */
  51209. export class EngineInstrumentation implements IDisposable {
  51210. /**
  51211. * Define the instrumented engine.
  51212. */
  51213. engine: Engine;
  51214. private _captureGPUFrameTime;
  51215. private _gpuFrameTimeToken;
  51216. private _gpuFrameTime;
  51217. private _captureShaderCompilationTime;
  51218. private _shaderCompilationTime;
  51219. private _onBeginFrameObserver;
  51220. private _onEndFrameObserver;
  51221. private _onBeforeShaderCompilationObserver;
  51222. private _onAfterShaderCompilationObserver;
  51223. /**
  51224. * Gets the perf counter used for GPU frame time
  51225. */
  51226. readonly gpuFrameTimeCounter: PerfCounter;
  51227. /**
  51228. * Gets the GPU frame time capture status
  51229. */
  51230. /**
  51231. * Enable or disable the GPU frame time capture
  51232. */
  51233. captureGPUFrameTime: boolean;
  51234. /**
  51235. * Gets the perf counter used for shader compilation time
  51236. */
  51237. readonly shaderCompilationTimeCounter: PerfCounter;
  51238. /**
  51239. * Gets the shader compilation time capture status
  51240. */
  51241. /**
  51242. * Enable or disable the shader compilation time capture
  51243. */
  51244. captureShaderCompilationTime: boolean;
  51245. /**
  51246. * Instantiates a new engine instrumentation.
  51247. * This class can be used to get instrumentation data from a Babylon engine
  51248. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51249. * @param engine Defines the engine to instrument
  51250. */
  51251. constructor(
  51252. /**
  51253. * Define the instrumented engine.
  51254. */
  51255. engine: Engine);
  51256. /**
  51257. * Dispose and release associated resources.
  51258. */
  51259. dispose(): void;
  51260. }
  51261. }
  51262. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51263. import { Scene, IDisposable } from "babylonjs/scene";
  51264. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51265. /**
  51266. * This class can be used to get instrumentation data from a Babylon engine
  51267. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51268. */
  51269. export class SceneInstrumentation implements IDisposable {
  51270. /**
  51271. * Defines the scene to instrument
  51272. */
  51273. scene: Scene;
  51274. private _captureActiveMeshesEvaluationTime;
  51275. private _activeMeshesEvaluationTime;
  51276. private _captureRenderTargetsRenderTime;
  51277. private _renderTargetsRenderTime;
  51278. private _captureFrameTime;
  51279. private _frameTime;
  51280. private _captureRenderTime;
  51281. private _renderTime;
  51282. private _captureInterFrameTime;
  51283. private _interFrameTime;
  51284. private _captureParticlesRenderTime;
  51285. private _particlesRenderTime;
  51286. private _captureSpritesRenderTime;
  51287. private _spritesRenderTime;
  51288. private _capturePhysicsTime;
  51289. private _physicsTime;
  51290. private _captureAnimationsTime;
  51291. private _animationsTime;
  51292. private _captureCameraRenderTime;
  51293. private _cameraRenderTime;
  51294. private _onBeforeActiveMeshesEvaluationObserver;
  51295. private _onAfterActiveMeshesEvaluationObserver;
  51296. private _onBeforeRenderTargetsRenderObserver;
  51297. private _onAfterRenderTargetsRenderObserver;
  51298. private _onAfterRenderObserver;
  51299. private _onBeforeDrawPhaseObserver;
  51300. private _onAfterDrawPhaseObserver;
  51301. private _onBeforeAnimationsObserver;
  51302. private _onBeforeParticlesRenderingObserver;
  51303. private _onAfterParticlesRenderingObserver;
  51304. private _onBeforeSpritesRenderingObserver;
  51305. private _onAfterSpritesRenderingObserver;
  51306. private _onBeforePhysicsObserver;
  51307. private _onAfterPhysicsObserver;
  51308. private _onAfterAnimationsObserver;
  51309. private _onBeforeCameraRenderObserver;
  51310. private _onAfterCameraRenderObserver;
  51311. /**
  51312. * Gets the perf counter used for active meshes evaluation time
  51313. */
  51314. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51315. /**
  51316. * Gets the active meshes evaluation time capture status
  51317. */
  51318. /**
  51319. * Enable or disable the active meshes evaluation time capture
  51320. */
  51321. captureActiveMeshesEvaluationTime: boolean;
  51322. /**
  51323. * Gets the perf counter used for render targets render time
  51324. */
  51325. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51326. /**
  51327. * Gets the render targets render time capture status
  51328. */
  51329. /**
  51330. * Enable or disable the render targets render time capture
  51331. */
  51332. captureRenderTargetsRenderTime: boolean;
  51333. /**
  51334. * Gets the perf counter used for particles render time
  51335. */
  51336. readonly particlesRenderTimeCounter: PerfCounter;
  51337. /**
  51338. * Gets the particles render time capture status
  51339. */
  51340. /**
  51341. * Enable or disable the particles render time capture
  51342. */
  51343. captureParticlesRenderTime: boolean;
  51344. /**
  51345. * Gets the perf counter used for sprites render time
  51346. */
  51347. readonly spritesRenderTimeCounter: PerfCounter;
  51348. /**
  51349. * Gets the sprites render time capture status
  51350. */
  51351. /**
  51352. * Enable or disable the sprites render time capture
  51353. */
  51354. captureSpritesRenderTime: boolean;
  51355. /**
  51356. * Gets the perf counter used for physics time
  51357. */
  51358. readonly physicsTimeCounter: PerfCounter;
  51359. /**
  51360. * Gets the physics time capture status
  51361. */
  51362. /**
  51363. * Enable or disable the physics time capture
  51364. */
  51365. capturePhysicsTime: boolean;
  51366. /**
  51367. * Gets the perf counter used for animations time
  51368. */
  51369. readonly animationsTimeCounter: PerfCounter;
  51370. /**
  51371. * Gets the animations time capture status
  51372. */
  51373. /**
  51374. * Enable or disable the animations time capture
  51375. */
  51376. captureAnimationsTime: boolean;
  51377. /**
  51378. * Gets the perf counter used for frame time capture
  51379. */
  51380. readonly frameTimeCounter: PerfCounter;
  51381. /**
  51382. * Gets the frame time capture status
  51383. */
  51384. /**
  51385. * Enable or disable the frame time capture
  51386. */
  51387. captureFrameTime: boolean;
  51388. /**
  51389. * Gets the perf counter used for inter-frames time capture
  51390. */
  51391. readonly interFrameTimeCounter: PerfCounter;
  51392. /**
  51393. * Gets the inter-frames time capture status
  51394. */
  51395. /**
  51396. * Enable or disable the inter-frames time capture
  51397. */
  51398. captureInterFrameTime: boolean;
  51399. /**
  51400. * Gets the perf counter used for render time capture
  51401. */
  51402. readonly renderTimeCounter: PerfCounter;
  51403. /**
  51404. * Gets the render time capture status
  51405. */
  51406. /**
  51407. * Enable or disable the render time capture
  51408. */
  51409. captureRenderTime: boolean;
  51410. /**
  51411. * Gets the perf counter used for camera render time capture
  51412. */
  51413. readonly cameraRenderTimeCounter: PerfCounter;
  51414. /**
  51415. * Gets the camera render time capture status
  51416. */
  51417. /**
  51418. * Enable or disable the camera render time capture
  51419. */
  51420. captureCameraRenderTime: boolean;
  51421. /**
  51422. * Gets the perf counter used for draw calls
  51423. */
  51424. readonly drawCallsCounter: PerfCounter;
  51425. /**
  51426. * Instantiates a new scene instrumentation.
  51427. * This class can be used to get instrumentation data from a Babylon engine
  51428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51429. * @param scene Defines the scene to instrument
  51430. */
  51431. constructor(
  51432. /**
  51433. * Defines the scene to instrument
  51434. */
  51435. scene: Scene);
  51436. /**
  51437. * Dispose and release associated resources.
  51438. */
  51439. dispose(): void;
  51440. }
  51441. }
  51442. declare module "babylonjs/Instrumentation/index" {
  51443. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51444. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51445. export * from "babylonjs/Instrumentation/timeToken";
  51446. }
  51447. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51448. /** @hidden */
  51449. export var glowMapGenerationPixelShader: {
  51450. name: string;
  51451. shader: string;
  51452. };
  51453. }
  51454. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51455. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51456. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51457. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51458. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51459. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51460. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51461. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51462. /** @hidden */
  51463. export var glowMapGenerationVertexShader: {
  51464. name: string;
  51465. shader: string;
  51466. };
  51467. }
  51468. declare module "babylonjs/Layers/effectLayer" {
  51469. import { Observable } from "babylonjs/Misc/observable";
  51470. import { Nullable } from "babylonjs/types";
  51471. import { Camera } from "babylonjs/Cameras/camera";
  51472. import { Scene } from "babylonjs/scene";
  51473. import { ISize } from "babylonjs/Maths/math.size";
  51474. import { Color4 } from "babylonjs/Maths/math.color";
  51475. import { Engine } from "babylonjs/Engines/engine";
  51476. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51478. import { Mesh } from "babylonjs/Meshes/mesh";
  51479. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51481. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51482. import { Effect } from "babylonjs/Materials/effect";
  51483. import { Material } from "babylonjs/Materials/material";
  51484. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51485. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51486. /**
  51487. * Effect layer options. This helps customizing the behaviour
  51488. * of the effect layer.
  51489. */
  51490. export interface IEffectLayerOptions {
  51491. /**
  51492. * Multiplication factor apply to the canvas size to compute the render target size
  51493. * used to generated the objects (the smaller the faster).
  51494. */
  51495. mainTextureRatio: number;
  51496. /**
  51497. * Enforces a fixed size texture to ensure effect stability across devices.
  51498. */
  51499. mainTextureFixedSize?: number;
  51500. /**
  51501. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51502. */
  51503. alphaBlendingMode: number;
  51504. /**
  51505. * The camera attached to the layer.
  51506. */
  51507. camera: Nullable<Camera>;
  51508. /**
  51509. * The rendering group to draw the layer in.
  51510. */
  51511. renderingGroupId: number;
  51512. }
  51513. /**
  51514. * The effect layer Helps adding post process effect blended with the main pass.
  51515. *
  51516. * This can be for instance use to generate glow or higlight effects on the scene.
  51517. *
  51518. * The effect layer class can not be used directly and is intented to inherited from to be
  51519. * customized per effects.
  51520. */
  51521. export abstract class EffectLayer {
  51522. private _vertexBuffers;
  51523. private _indexBuffer;
  51524. private _cachedDefines;
  51525. private _effectLayerMapGenerationEffect;
  51526. private _effectLayerOptions;
  51527. private _mergeEffect;
  51528. protected _scene: Scene;
  51529. protected _engine: Engine;
  51530. protected _maxSize: number;
  51531. protected _mainTextureDesiredSize: ISize;
  51532. protected _mainTexture: RenderTargetTexture;
  51533. protected _shouldRender: boolean;
  51534. protected _postProcesses: PostProcess[];
  51535. protected _textures: BaseTexture[];
  51536. protected _emissiveTextureAndColor: {
  51537. texture: Nullable<BaseTexture>;
  51538. color: Color4;
  51539. };
  51540. /**
  51541. * The name of the layer
  51542. */
  51543. name: string;
  51544. /**
  51545. * The clear color of the texture used to generate the glow map.
  51546. */
  51547. neutralColor: Color4;
  51548. /**
  51549. * Specifies wether the highlight layer is enabled or not.
  51550. */
  51551. isEnabled: boolean;
  51552. /**
  51553. * Gets the camera attached to the layer.
  51554. */
  51555. readonly camera: Nullable<Camera>;
  51556. /**
  51557. * Gets the rendering group id the layer should render in.
  51558. */
  51559. renderingGroupId: number;
  51560. /**
  51561. * An event triggered when the effect layer has been disposed.
  51562. */
  51563. onDisposeObservable: Observable<EffectLayer>;
  51564. /**
  51565. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51566. */
  51567. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51568. /**
  51569. * An event triggered when the generated texture is being merged in the scene.
  51570. */
  51571. onBeforeComposeObservable: Observable<EffectLayer>;
  51572. /**
  51573. * An event triggered when the generated texture has been merged in the scene.
  51574. */
  51575. onAfterComposeObservable: Observable<EffectLayer>;
  51576. /**
  51577. * An event triggered when the efffect layer changes its size.
  51578. */
  51579. onSizeChangedObservable: Observable<EffectLayer>;
  51580. /** @hidden */
  51581. static _SceneComponentInitialization: (scene: Scene) => void;
  51582. /**
  51583. * Instantiates a new effect Layer and references it in the scene.
  51584. * @param name The name of the layer
  51585. * @param scene The scene to use the layer in
  51586. */
  51587. constructor(
  51588. /** The Friendly of the effect in the scene */
  51589. name: string, scene: Scene);
  51590. /**
  51591. * Get the effect name of the layer.
  51592. * @return The effect name
  51593. */
  51594. abstract getEffectName(): string;
  51595. /**
  51596. * Checks for the readiness of the element composing the layer.
  51597. * @param subMesh the mesh to check for
  51598. * @param useInstances specify wether or not to use instances to render the mesh
  51599. * @return true if ready otherwise, false
  51600. */
  51601. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51602. /**
  51603. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51604. * @returns true if the effect requires stencil during the main canvas render pass.
  51605. */
  51606. abstract needStencil(): boolean;
  51607. /**
  51608. * Create the merge effect. This is the shader use to blit the information back
  51609. * to the main canvas at the end of the scene rendering.
  51610. * @returns The effect containing the shader used to merge the effect on the main canvas
  51611. */
  51612. protected abstract _createMergeEffect(): Effect;
  51613. /**
  51614. * Creates the render target textures and post processes used in the effect layer.
  51615. */
  51616. protected abstract _createTextureAndPostProcesses(): void;
  51617. /**
  51618. * Implementation specific of rendering the generating effect on the main canvas.
  51619. * @param effect The effect used to render through
  51620. */
  51621. protected abstract _internalRender(effect: Effect): void;
  51622. /**
  51623. * Sets the required values for both the emissive texture and and the main color.
  51624. */
  51625. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51626. /**
  51627. * Free any resources and references associated to a mesh.
  51628. * Internal use
  51629. * @param mesh The mesh to free.
  51630. */
  51631. abstract _disposeMesh(mesh: Mesh): void;
  51632. /**
  51633. * Serializes this layer (Glow or Highlight for example)
  51634. * @returns a serialized layer object
  51635. */
  51636. abstract serialize?(): any;
  51637. /**
  51638. * Initializes the effect layer with the required options.
  51639. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51640. */
  51641. protected _init(options: Partial<IEffectLayerOptions>): void;
  51642. /**
  51643. * Generates the index buffer of the full screen quad blending to the main canvas.
  51644. */
  51645. private _generateIndexBuffer;
  51646. /**
  51647. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51648. */
  51649. private _generateVertexBuffer;
  51650. /**
  51651. * Sets the main texture desired size which is the closest power of two
  51652. * of the engine canvas size.
  51653. */
  51654. private _setMainTextureSize;
  51655. /**
  51656. * Creates the main texture for the effect layer.
  51657. */
  51658. protected _createMainTexture(): void;
  51659. /**
  51660. * Adds specific effects defines.
  51661. * @param defines The defines to add specifics to.
  51662. */
  51663. protected _addCustomEffectDefines(defines: string[]): void;
  51664. /**
  51665. * Checks for the readiness of the element composing the layer.
  51666. * @param subMesh the mesh to check for
  51667. * @param useInstances specify wether or not to use instances to render the mesh
  51668. * @param emissiveTexture the associated emissive texture used to generate the glow
  51669. * @return true if ready otherwise, false
  51670. */
  51671. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51672. /**
  51673. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51674. */
  51675. render(): void;
  51676. /**
  51677. * Determine if a given mesh will be used in the current effect.
  51678. * @param mesh mesh to test
  51679. * @returns true if the mesh will be used
  51680. */
  51681. hasMesh(mesh: AbstractMesh): boolean;
  51682. /**
  51683. * Returns true if the layer contains information to display, otherwise false.
  51684. * @returns true if the glow layer should be rendered
  51685. */
  51686. shouldRender(): boolean;
  51687. /**
  51688. * Returns true if the mesh should render, otherwise false.
  51689. * @param mesh The mesh to render
  51690. * @returns true if it should render otherwise false
  51691. */
  51692. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51693. /**
  51694. * Returns true if the mesh can be rendered, otherwise false.
  51695. * @param mesh The mesh to render
  51696. * @param material The material used on the mesh
  51697. * @returns true if it can be rendered otherwise false
  51698. */
  51699. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51700. /**
  51701. * Returns true if the mesh should render, otherwise false.
  51702. * @param mesh The mesh to render
  51703. * @returns true if it should render otherwise false
  51704. */
  51705. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51706. /**
  51707. * Renders the submesh passed in parameter to the generation map.
  51708. */
  51709. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51710. /**
  51711. * Rebuild the required buffers.
  51712. * @hidden Internal use only.
  51713. */
  51714. _rebuild(): void;
  51715. /**
  51716. * Dispose only the render target textures and post process.
  51717. */
  51718. private _disposeTextureAndPostProcesses;
  51719. /**
  51720. * Dispose the highlight layer and free resources.
  51721. */
  51722. dispose(): void;
  51723. /**
  51724. * Gets the class name of the effect layer
  51725. * @returns the string with the class name of the effect layer
  51726. */
  51727. getClassName(): string;
  51728. /**
  51729. * Creates an effect layer from parsed effect layer data
  51730. * @param parsedEffectLayer defines effect layer data
  51731. * @param scene defines the current scene
  51732. * @param rootUrl defines the root URL containing the effect layer information
  51733. * @returns a parsed effect Layer
  51734. */
  51735. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51736. }
  51737. }
  51738. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51739. import { Scene } from "babylonjs/scene";
  51740. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51741. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51742. import { AbstractScene } from "babylonjs/abstractScene";
  51743. module "babylonjs/abstractScene" {
  51744. interface AbstractScene {
  51745. /**
  51746. * The list of effect layers (highlights/glow) added to the scene
  51747. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51748. * @see http://doc.babylonjs.com/how_to/glow_layer
  51749. */
  51750. effectLayers: Array<EffectLayer>;
  51751. /**
  51752. * Removes the given effect layer from this scene.
  51753. * @param toRemove defines the effect layer to remove
  51754. * @returns the index of the removed effect layer
  51755. */
  51756. removeEffectLayer(toRemove: EffectLayer): number;
  51757. /**
  51758. * Adds the given effect layer to this scene
  51759. * @param newEffectLayer defines the effect layer to add
  51760. */
  51761. addEffectLayer(newEffectLayer: EffectLayer): void;
  51762. }
  51763. }
  51764. /**
  51765. * Defines the layer scene component responsible to manage any effect layers
  51766. * in a given scene.
  51767. */
  51768. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51769. /**
  51770. * The component name helpfull to identify the component in the list of scene components.
  51771. */
  51772. readonly name: string;
  51773. /**
  51774. * The scene the component belongs to.
  51775. */
  51776. scene: Scene;
  51777. private _engine;
  51778. private _renderEffects;
  51779. private _needStencil;
  51780. private _previousStencilState;
  51781. /**
  51782. * Creates a new instance of the component for the given scene
  51783. * @param scene Defines the scene to register the component in
  51784. */
  51785. constructor(scene: Scene);
  51786. /**
  51787. * Registers the component in a given scene
  51788. */
  51789. register(): void;
  51790. /**
  51791. * Rebuilds the elements related to this component in case of
  51792. * context lost for instance.
  51793. */
  51794. rebuild(): void;
  51795. /**
  51796. * Serializes the component data to the specified json object
  51797. * @param serializationObject The object to serialize to
  51798. */
  51799. serialize(serializationObject: any): void;
  51800. /**
  51801. * Adds all the elements from the container to the scene
  51802. * @param container the container holding the elements
  51803. */
  51804. addFromContainer(container: AbstractScene): void;
  51805. /**
  51806. * Removes all the elements in the container from the scene
  51807. * @param container contains the elements to remove
  51808. * @param dispose if the removed element should be disposed (default: false)
  51809. */
  51810. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51811. /**
  51812. * Disposes the component and the associated ressources.
  51813. */
  51814. dispose(): void;
  51815. private _isReadyForMesh;
  51816. private _renderMainTexture;
  51817. private _setStencil;
  51818. private _setStencilBack;
  51819. private _draw;
  51820. private _drawCamera;
  51821. private _drawRenderingGroup;
  51822. }
  51823. }
  51824. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51825. /** @hidden */
  51826. export var glowMapMergePixelShader: {
  51827. name: string;
  51828. shader: string;
  51829. };
  51830. }
  51831. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51832. /** @hidden */
  51833. export var glowMapMergeVertexShader: {
  51834. name: string;
  51835. shader: string;
  51836. };
  51837. }
  51838. declare module "babylonjs/Layers/glowLayer" {
  51839. import { Nullable } from "babylonjs/types";
  51840. import { Camera } from "babylonjs/Cameras/camera";
  51841. import { Scene } from "babylonjs/scene";
  51842. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51844. import { Mesh } from "babylonjs/Meshes/mesh";
  51845. import { Texture } from "babylonjs/Materials/Textures/texture";
  51846. import { Effect } from "babylonjs/Materials/effect";
  51847. import { Material } from "babylonjs/Materials/material";
  51848. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51849. import { Color4 } from "babylonjs/Maths/math.color";
  51850. import "babylonjs/Shaders/glowMapMerge.fragment";
  51851. import "babylonjs/Shaders/glowMapMerge.vertex";
  51852. import "babylonjs/Layers/effectLayerSceneComponent";
  51853. module "babylonjs/abstractScene" {
  51854. interface AbstractScene {
  51855. /**
  51856. * Return a the first highlight layer of the scene with a given name.
  51857. * @param name The name of the highlight layer to look for.
  51858. * @return The highlight layer if found otherwise null.
  51859. */
  51860. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51861. }
  51862. }
  51863. /**
  51864. * Glow layer options. This helps customizing the behaviour
  51865. * of the glow layer.
  51866. */
  51867. export interface IGlowLayerOptions {
  51868. /**
  51869. * Multiplication factor apply to the canvas size to compute the render target size
  51870. * used to generated the glowing objects (the smaller the faster).
  51871. */
  51872. mainTextureRatio: number;
  51873. /**
  51874. * Enforces a fixed size texture to ensure resize independant blur.
  51875. */
  51876. mainTextureFixedSize?: number;
  51877. /**
  51878. * How big is the kernel of the blur texture.
  51879. */
  51880. blurKernelSize: number;
  51881. /**
  51882. * The camera attached to the layer.
  51883. */
  51884. camera: Nullable<Camera>;
  51885. /**
  51886. * Enable MSAA by chosing the number of samples.
  51887. */
  51888. mainTextureSamples?: number;
  51889. /**
  51890. * The rendering group to draw the layer in.
  51891. */
  51892. renderingGroupId: number;
  51893. }
  51894. /**
  51895. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51896. *
  51897. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51898. * glowy meshes to your scene.
  51899. *
  51900. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51901. */
  51902. export class GlowLayer extends EffectLayer {
  51903. /**
  51904. * Effect Name of the layer.
  51905. */
  51906. static readonly EffectName: string;
  51907. /**
  51908. * The default blur kernel size used for the glow.
  51909. */
  51910. static DefaultBlurKernelSize: number;
  51911. /**
  51912. * The default texture size ratio used for the glow.
  51913. */
  51914. static DefaultTextureRatio: number;
  51915. /**
  51916. * Sets the kernel size of the blur.
  51917. */
  51918. /**
  51919. * Gets the kernel size of the blur.
  51920. */
  51921. blurKernelSize: number;
  51922. /**
  51923. * Sets the glow intensity.
  51924. */
  51925. /**
  51926. * Gets the glow intensity.
  51927. */
  51928. intensity: number;
  51929. private _options;
  51930. private _intensity;
  51931. private _horizontalBlurPostprocess1;
  51932. private _verticalBlurPostprocess1;
  51933. private _horizontalBlurPostprocess2;
  51934. private _verticalBlurPostprocess2;
  51935. private _blurTexture1;
  51936. private _blurTexture2;
  51937. private _postProcesses1;
  51938. private _postProcesses2;
  51939. private _includedOnlyMeshes;
  51940. private _excludedMeshes;
  51941. /**
  51942. * Callback used to let the user override the color selection on a per mesh basis
  51943. */
  51944. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51945. /**
  51946. * Callback used to let the user override the texture selection on a per mesh basis
  51947. */
  51948. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51949. /**
  51950. * Instantiates a new glow Layer and references it to the scene.
  51951. * @param name The name of the layer
  51952. * @param scene The scene to use the layer in
  51953. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51954. */
  51955. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51956. /**
  51957. * Get the effect name of the layer.
  51958. * @return The effect name
  51959. */
  51960. getEffectName(): string;
  51961. /**
  51962. * Create the merge effect. This is the shader use to blit the information back
  51963. * to the main canvas at the end of the scene rendering.
  51964. */
  51965. protected _createMergeEffect(): Effect;
  51966. /**
  51967. * Creates the render target textures and post processes used in the glow layer.
  51968. */
  51969. protected _createTextureAndPostProcesses(): void;
  51970. /**
  51971. * Checks for the readiness of the element composing the layer.
  51972. * @param subMesh the mesh to check for
  51973. * @param useInstances specify wether or not to use instances to render the mesh
  51974. * @param emissiveTexture the associated emissive texture used to generate the glow
  51975. * @return true if ready otherwise, false
  51976. */
  51977. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51978. /**
  51979. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51980. */
  51981. needStencil(): boolean;
  51982. /**
  51983. * Returns true if the mesh can be rendered, otherwise false.
  51984. * @param mesh The mesh to render
  51985. * @param material The material used on the mesh
  51986. * @returns true if it can be rendered otherwise false
  51987. */
  51988. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51989. /**
  51990. * Implementation specific of rendering the generating effect on the main canvas.
  51991. * @param effect The effect used to render through
  51992. */
  51993. protected _internalRender(effect: Effect): void;
  51994. /**
  51995. * Sets the required values for both the emissive texture and and the main color.
  51996. */
  51997. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51998. /**
  51999. * Returns true if the mesh should render, otherwise false.
  52000. * @param mesh The mesh to render
  52001. * @returns true if it should render otherwise false
  52002. */
  52003. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52004. /**
  52005. * Adds specific effects defines.
  52006. * @param defines The defines to add specifics to.
  52007. */
  52008. protected _addCustomEffectDefines(defines: string[]): void;
  52009. /**
  52010. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52011. * @param mesh The mesh to exclude from the glow layer
  52012. */
  52013. addExcludedMesh(mesh: Mesh): void;
  52014. /**
  52015. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52016. * @param mesh The mesh to remove
  52017. */
  52018. removeExcludedMesh(mesh: Mesh): void;
  52019. /**
  52020. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52021. * @param mesh The mesh to include in the glow layer
  52022. */
  52023. addIncludedOnlyMesh(mesh: Mesh): void;
  52024. /**
  52025. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52026. * @param mesh The mesh to remove
  52027. */
  52028. removeIncludedOnlyMesh(mesh: Mesh): void;
  52029. /**
  52030. * Determine if a given mesh will be used in the glow layer
  52031. * @param mesh The mesh to test
  52032. * @returns true if the mesh will be highlighted by the current glow layer
  52033. */
  52034. hasMesh(mesh: AbstractMesh): boolean;
  52035. /**
  52036. * Free any resources and references associated to a mesh.
  52037. * Internal use
  52038. * @param mesh The mesh to free.
  52039. * @hidden
  52040. */
  52041. _disposeMesh(mesh: Mesh): void;
  52042. /**
  52043. * Gets the class name of the effect layer
  52044. * @returns the string with the class name of the effect layer
  52045. */
  52046. getClassName(): string;
  52047. /**
  52048. * Serializes this glow layer
  52049. * @returns a serialized glow layer object
  52050. */
  52051. serialize(): any;
  52052. /**
  52053. * Creates a Glow Layer from parsed glow layer data
  52054. * @param parsedGlowLayer defines glow layer data
  52055. * @param scene defines the current scene
  52056. * @param rootUrl defines the root URL containing the glow layer information
  52057. * @returns a parsed Glow Layer
  52058. */
  52059. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52060. }
  52061. }
  52062. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52063. /** @hidden */
  52064. export var glowBlurPostProcessPixelShader: {
  52065. name: string;
  52066. shader: string;
  52067. };
  52068. }
  52069. declare module "babylonjs/Layers/highlightLayer" {
  52070. import { Observable } from "babylonjs/Misc/observable";
  52071. import { Nullable } from "babylonjs/types";
  52072. import { Camera } from "babylonjs/Cameras/camera";
  52073. import { Scene } from "babylonjs/scene";
  52074. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52076. import { Mesh } from "babylonjs/Meshes/mesh";
  52077. import { Effect } from "babylonjs/Materials/effect";
  52078. import { Material } from "babylonjs/Materials/material";
  52079. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52080. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52081. import "babylonjs/Shaders/glowMapMerge.fragment";
  52082. import "babylonjs/Shaders/glowMapMerge.vertex";
  52083. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52084. module "babylonjs/abstractScene" {
  52085. interface AbstractScene {
  52086. /**
  52087. * Return a the first highlight layer of the scene with a given name.
  52088. * @param name The name of the highlight layer to look for.
  52089. * @return The highlight layer if found otherwise null.
  52090. */
  52091. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52092. }
  52093. }
  52094. /**
  52095. * Highlight layer options. This helps customizing the behaviour
  52096. * of the highlight layer.
  52097. */
  52098. export interface IHighlightLayerOptions {
  52099. /**
  52100. * Multiplication factor apply to the canvas size to compute the render target size
  52101. * used to generated the glowing objects (the smaller the faster).
  52102. */
  52103. mainTextureRatio: number;
  52104. /**
  52105. * Enforces a fixed size texture to ensure resize independant blur.
  52106. */
  52107. mainTextureFixedSize?: number;
  52108. /**
  52109. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52110. * of the picture to blur (the smaller the faster).
  52111. */
  52112. blurTextureSizeRatio: number;
  52113. /**
  52114. * How big in texel of the blur texture is the vertical blur.
  52115. */
  52116. blurVerticalSize: number;
  52117. /**
  52118. * How big in texel of the blur texture is the horizontal blur.
  52119. */
  52120. blurHorizontalSize: number;
  52121. /**
  52122. * Alpha blending mode used to apply the blur. Default is combine.
  52123. */
  52124. alphaBlendingMode: number;
  52125. /**
  52126. * The camera attached to the layer.
  52127. */
  52128. camera: Nullable<Camera>;
  52129. /**
  52130. * Should we display highlight as a solid stroke?
  52131. */
  52132. isStroke?: boolean;
  52133. /**
  52134. * The rendering group to draw the layer in.
  52135. */
  52136. renderingGroupId: number;
  52137. }
  52138. /**
  52139. * The highlight layer Helps adding a glow effect around a mesh.
  52140. *
  52141. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52142. * glowy meshes to your scene.
  52143. *
  52144. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52145. */
  52146. export class HighlightLayer extends EffectLayer {
  52147. name: string;
  52148. /**
  52149. * Effect Name of the highlight layer.
  52150. */
  52151. static readonly EffectName: string;
  52152. /**
  52153. * The neutral color used during the preparation of the glow effect.
  52154. * This is black by default as the blend operation is a blend operation.
  52155. */
  52156. static NeutralColor: Color4;
  52157. /**
  52158. * Stencil value used for glowing meshes.
  52159. */
  52160. static GlowingMeshStencilReference: number;
  52161. /**
  52162. * Stencil value used for the other meshes in the scene.
  52163. */
  52164. static NormalMeshStencilReference: number;
  52165. /**
  52166. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52167. */
  52168. innerGlow: boolean;
  52169. /**
  52170. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52171. */
  52172. outerGlow: boolean;
  52173. /**
  52174. * Specifies the horizontal size of the blur.
  52175. */
  52176. /**
  52177. * Gets the horizontal size of the blur.
  52178. */
  52179. blurHorizontalSize: number;
  52180. /**
  52181. * Specifies the vertical size of the blur.
  52182. */
  52183. /**
  52184. * Gets the vertical size of the blur.
  52185. */
  52186. blurVerticalSize: number;
  52187. /**
  52188. * An event triggered when the highlight layer is being blurred.
  52189. */
  52190. onBeforeBlurObservable: Observable<HighlightLayer>;
  52191. /**
  52192. * An event triggered when the highlight layer has been blurred.
  52193. */
  52194. onAfterBlurObservable: Observable<HighlightLayer>;
  52195. private _instanceGlowingMeshStencilReference;
  52196. private _options;
  52197. private _downSamplePostprocess;
  52198. private _horizontalBlurPostprocess;
  52199. private _verticalBlurPostprocess;
  52200. private _blurTexture;
  52201. private _meshes;
  52202. private _excludedMeshes;
  52203. /**
  52204. * Instantiates a new highlight Layer and references it to the scene..
  52205. * @param name The name of the layer
  52206. * @param scene The scene to use the layer in
  52207. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52208. */
  52209. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52210. /**
  52211. * Get the effect name of the layer.
  52212. * @return The effect name
  52213. */
  52214. getEffectName(): string;
  52215. /**
  52216. * Create the merge effect. This is the shader use to blit the information back
  52217. * to the main canvas at the end of the scene rendering.
  52218. */
  52219. protected _createMergeEffect(): Effect;
  52220. /**
  52221. * Creates the render target textures and post processes used in the highlight layer.
  52222. */
  52223. protected _createTextureAndPostProcesses(): void;
  52224. /**
  52225. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52226. */
  52227. needStencil(): boolean;
  52228. /**
  52229. * Checks for the readiness of the element composing the layer.
  52230. * @param subMesh the mesh to check for
  52231. * @param useInstances specify wether or not to use instances to render the mesh
  52232. * @param emissiveTexture the associated emissive texture used to generate the glow
  52233. * @return true if ready otherwise, false
  52234. */
  52235. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52236. /**
  52237. * Implementation specific of rendering the generating effect on the main canvas.
  52238. * @param effect The effect used to render through
  52239. */
  52240. protected _internalRender(effect: Effect): void;
  52241. /**
  52242. * Returns true if the layer contains information to display, otherwise false.
  52243. */
  52244. shouldRender(): boolean;
  52245. /**
  52246. * Returns true if the mesh should render, otherwise false.
  52247. * @param mesh The mesh to render
  52248. * @returns true if it should render otherwise false
  52249. */
  52250. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52251. /**
  52252. * Sets the required values for both the emissive texture and and the main color.
  52253. */
  52254. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52255. /**
  52256. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52257. * @param mesh The mesh to exclude from the highlight layer
  52258. */
  52259. addExcludedMesh(mesh: Mesh): void;
  52260. /**
  52261. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52262. * @param mesh The mesh to highlight
  52263. */
  52264. removeExcludedMesh(mesh: Mesh): void;
  52265. /**
  52266. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52267. * @param mesh mesh to test
  52268. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52269. */
  52270. hasMesh(mesh: AbstractMesh): boolean;
  52271. /**
  52272. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52273. * @param mesh The mesh to highlight
  52274. * @param color The color of the highlight
  52275. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52276. */
  52277. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52278. /**
  52279. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52280. * @param mesh The mesh to highlight
  52281. */
  52282. removeMesh(mesh: Mesh): void;
  52283. /**
  52284. * Force the stencil to the normal expected value for none glowing parts
  52285. */
  52286. private _defaultStencilReference;
  52287. /**
  52288. * Free any resources and references associated to a mesh.
  52289. * Internal use
  52290. * @param mesh The mesh to free.
  52291. * @hidden
  52292. */
  52293. _disposeMesh(mesh: Mesh): void;
  52294. /**
  52295. * Dispose the highlight layer and free resources.
  52296. */
  52297. dispose(): void;
  52298. /**
  52299. * Gets the class name of the effect layer
  52300. * @returns the string with the class name of the effect layer
  52301. */
  52302. getClassName(): string;
  52303. /**
  52304. * Serializes this Highlight layer
  52305. * @returns a serialized Highlight layer object
  52306. */
  52307. serialize(): any;
  52308. /**
  52309. * Creates a Highlight layer from parsed Highlight layer data
  52310. * @param parsedHightlightLayer defines the Highlight layer data
  52311. * @param scene defines the current scene
  52312. * @param rootUrl defines the root URL containing the Highlight layer information
  52313. * @returns a parsed Highlight layer
  52314. */
  52315. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52316. }
  52317. }
  52318. declare module "babylonjs/Layers/layerSceneComponent" {
  52319. import { Scene } from "babylonjs/scene";
  52320. import { ISceneComponent } from "babylonjs/sceneComponent";
  52321. import { Layer } from "babylonjs/Layers/layer";
  52322. import { AbstractScene } from "babylonjs/abstractScene";
  52323. module "babylonjs/abstractScene" {
  52324. interface AbstractScene {
  52325. /**
  52326. * The list of layers (background and foreground) of the scene
  52327. */
  52328. layers: Array<Layer>;
  52329. }
  52330. }
  52331. /**
  52332. * Defines the layer scene component responsible to manage any layers
  52333. * in a given scene.
  52334. */
  52335. export class LayerSceneComponent implements ISceneComponent {
  52336. /**
  52337. * The component name helpfull to identify the component in the list of scene components.
  52338. */
  52339. readonly name: string;
  52340. /**
  52341. * The scene the component belongs to.
  52342. */
  52343. scene: Scene;
  52344. private _engine;
  52345. /**
  52346. * Creates a new instance of the component for the given scene
  52347. * @param scene Defines the scene to register the component in
  52348. */
  52349. constructor(scene: Scene);
  52350. /**
  52351. * Registers the component in a given scene
  52352. */
  52353. register(): void;
  52354. /**
  52355. * Rebuilds the elements related to this component in case of
  52356. * context lost for instance.
  52357. */
  52358. rebuild(): void;
  52359. /**
  52360. * Disposes the component and the associated ressources.
  52361. */
  52362. dispose(): void;
  52363. private _draw;
  52364. private _drawCameraPredicate;
  52365. private _drawCameraBackground;
  52366. private _drawCameraForeground;
  52367. private _drawRenderTargetPredicate;
  52368. private _drawRenderTargetBackground;
  52369. private _drawRenderTargetForeground;
  52370. /**
  52371. * Adds all the elements from the container to the scene
  52372. * @param container the container holding the elements
  52373. */
  52374. addFromContainer(container: AbstractScene): void;
  52375. /**
  52376. * Removes all the elements in the container from the scene
  52377. * @param container contains the elements to remove
  52378. * @param dispose if the removed element should be disposed (default: false)
  52379. */
  52380. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52381. }
  52382. }
  52383. declare module "babylonjs/Shaders/layer.fragment" {
  52384. /** @hidden */
  52385. export var layerPixelShader: {
  52386. name: string;
  52387. shader: string;
  52388. };
  52389. }
  52390. declare module "babylonjs/Shaders/layer.vertex" {
  52391. /** @hidden */
  52392. export var layerVertexShader: {
  52393. name: string;
  52394. shader: string;
  52395. };
  52396. }
  52397. declare module "babylonjs/Layers/layer" {
  52398. import { Observable } from "babylonjs/Misc/observable";
  52399. import { Nullable } from "babylonjs/types";
  52400. import { Scene } from "babylonjs/scene";
  52401. import { Vector2 } from "babylonjs/Maths/math.vector";
  52402. import { Color4 } from "babylonjs/Maths/math.color";
  52403. import { Texture } from "babylonjs/Materials/Textures/texture";
  52404. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52405. import "babylonjs/Shaders/layer.fragment";
  52406. import "babylonjs/Shaders/layer.vertex";
  52407. /**
  52408. * This represents a full screen 2d layer.
  52409. * This can be useful to display a picture in the background of your scene for instance.
  52410. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52411. */
  52412. export class Layer {
  52413. /**
  52414. * Define the name of the layer.
  52415. */
  52416. name: string;
  52417. /**
  52418. * Define the texture the layer should display.
  52419. */
  52420. texture: Nullable<Texture>;
  52421. /**
  52422. * Is the layer in background or foreground.
  52423. */
  52424. isBackground: boolean;
  52425. /**
  52426. * Define the color of the layer (instead of texture).
  52427. */
  52428. color: Color4;
  52429. /**
  52430. * Define the scale of the layer in order to zoom in out of the texture.
  52431. */
  52432. scale: Vector2;
  52433. /**
  52434. * Define an offset for the layer in order to shift the texture.
  52435. */
  52436. offset: Vector2;
  52437. /**
  52438. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52439. */
  52440. alphaBlendingMode: number;
  52441. /**
  52442. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52443. * Alpha test will not mix with the background color in case of transparency.
  52444. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52445. */
  52446. alphaTest: boolean;
  52447. /**
  52448. * Define a mask to restrict the layer to only some of the scene cameras.
  52449. */
  52450. layerMask: number;
  52451. /**
  52452. * Define the list of render target the layer is visible into.
  52453. */
  52454. renderTargetTextures: RenderTargetTexture[];
  52455. /**
  52456. * Define if the layer is only used in renderTarget or if it also
  52457. * renders in the main frame buffer of the canvas.
  52458. */
  52459. renderOnlyInRenderTargetTextures: boolean;
  52460. private _scene;
  52461. private _vertexBuffers;
  52462. private _indexBuffer;
  52463. private _effect;
  52464. private _alphaTestEffect;
  52465. /**
  52466. * An event triggered when the layer is disposed.
  52467. */
  52468. onDisposeObservable: Observable<Layer>;
  52469. private _onDisposeObserver;
  52470. /**
  52471. * Back compatibility with callback before the onDisposeObservable existed.
  52472. * The set callback will be triggered when the layer has been disposed.
  52473. */
  52474. onDispose: () => void;
  52475. /**
  52476. * An event triggered before rendering the scene
  52477. */
  52478. onBeforeRenderObservable: Observable<Layer>;
  52479. private _onBeforeRenderObserver;
  52480. /**
  52481. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52482. * The set callback will be triggered just before rendering the layer.
  52483. */
  52484. onBeforeRender: () => void;
  52485. /**
  52486. * An event triggered after rendering the scene
  52487. */
  52488. onAfterRenderObservable: Observable<Layer>;
  52489. private _onAfterRenderObserver;
  52490. /**
  52491. * Back compatibility with callback before the onAfterRenderObservable existed.
  52492. * The set callback will be triggered just after rendering the layer.
  52493. */
  52494. onAfterRender: () => void;
  52495. /**
  52496. * Instantiates a new layer.
  52497. * This represents a full screen 2d layer.
  52498. * This can be useful to display a picture in the background of your scene for instance.
  52499. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52500. * @param name Define the name of the layer in the scene
  52501. * @param imgUrl Define the url of the texture to display in the layer
  52502. * @param scene Define the scene the layer belongs to
  52503. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52504. * @param color Defines a color for the layer
  52505. */
  52506. constructor(
  52507. /**
  52508. * Define the name of the layer.
  52509. */
  52510. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52511. private _createIndexBuffer;
  52512. /** @hidden */
  52513. _rebuild(): void;
  52514. /**
  52515. * Renders the layer in the scene.
  52516. */
  52517. render(): void;
  52518. /**
  52519. * Disposes and releases the associated ressources.
  52520. */
  52521. dispose(): void;
  52522. }
  52523. }
  52524. declare module "babylonjs/Layers/index" {
  52525. export * from "babylonjs/Layers/effectLayer";
  52526. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52527. export * from "babylonjs/Layers/glowLayer";
  52528. export * from "babylonjs/Layers/highlightLayer";
  52529. export * from "babylonjs/Layers/layer";
  52530. export * from "babylonjs/Layers/layerSceneComponent";
  52531. }
  52532. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52533. /** @hidden */
  52534. export var lensFlarePixelShader: {
  52535. name: string;
  52536. shader: string;
  52537. };
  52538. }
  52539. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52540. /** @hidden */
  52541. export var lensFlareVertexShader: {
  52542. name: string;
  52543. shader: string;
  52544. };
  52545. }
  52546. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52547. import { Scene } from "babylonjs/scene";
  52548. import { Vector3 } from "babylonjs/Maths/math.vector";
  52549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52550. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52551. import "babylonjs/Shaders/lensFlare.fragment";
  52552. import "babylonjs/Shaders/lensFlare.vertex";
  52553. import { Viewport } from "babylonjs/Maths/math.viewport";
  52554. /**
  52555. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52556. * It is usually composed of several `lensFlare`.
  52557. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52558. */
  52559. export class LensFlareSystem {
  52560. /**
  52561. * Define the name of the lens flare system
  52562. */
  52563. name: string;
  52564. /**
  52565. * List of lens flares used in this system.
  52566. */
  52567. lensFlares: LensFlare[];
  52568. /**
  52569. * Define a limit from the border the lens flare can be visible.
  52570. */
  52571. borderLimit: number;
  52572. /**
  52573. * Define a viewport border we do not want to see the lens flare in.
  52574. */
  52575. viewportBorder: number;
  52576. /**
  52577. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52578. */
  52579. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52580. /**
  52581. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52582. */
  52583. layerMask: number;
  52584. /**
  52585. * Define the id of the lens flare system in the scene.
  52586. * (equal to name by default)
  52587. */
  52588. id: string;
  52589. private _scene;
  52590. private _emitter;
  52591. private _vertexBuffers;
  52592. private _indexBuffer;
  52593. private _effect;
  52594. private _positionX;
  52595. private _positionY;
  52596. private _isEnabled;
  52597. /** @hidden */
  52598. static _SceneComponentInitialization: (scene: Scene) => void;
  52599. /**
  52600. * Instantiates a lens flare system.
  52601. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52602. * It is usually composed of several `lensFlare`.
  52603. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52604. * @param name Define the name of the lens flare system in the scene
  52605. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52606. * @param scene Define the scene the lens flare system belongs to
  52607. */
  52608. constructor(
  52609. /**
  52610. * Define the name of the lens flare system
  52611. */
  52612. name: string, emitter: any, scene: Scene);
  52613. /**
  52614. * Define if the lens flare system is enabled.
  52615. */
  52616. isEnabled: boolean;
  52617. /**
  52618. * Get the scene the effects belongs to.
  52619. * @returns the scene holding the lens flare system
  52620. */
  52621. getScene(): Scene;
  52622. /**
  52623. * Get the emitter of the lens flare system.
  52624. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52625. * @returns the emitter of the lens flare system
  52626. */
  52627. getEmitter(): any;
  52628. /**
  52629. * Set the emitter of the lens flare system.
  52630. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52631. * @param newEmitter Define the new emitter of the system
  52632. */
  52633. setEmitter(newEmitter: any): void;
  52634. /**
  52635. * Get the lens flare system emitter position.
  52636. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52637. * @returns the position
  52638. */
  52639. getEmitterPosition(): Vector3;
  52640. /**
  52641. * @hidden
  52642. */
  52643. computeEffectivePosition(globalViewport: Viewport): boolean;
  52644. /** @hidden */
  52645. _isVisible(): boolean;
  52646. /**
  52647. * @hidden
  52648. */
  52649. render(): boolean;
  52650. /**
  52651. * Dispose and release the lens flare with its associated resources.
  52652. */
  52653. dispose(): void;
  52654. /**
  52655. * Parse a lens flare system from a JSON repressentation
  52656. * @param parsedLensFlareSystem Define the JSON to parse
  52657. * @param scene Define the scene the parsed system should be instantiated in
  52658. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52659. * @returns the parsed system
  52660. */
  52661. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52662. /**
  52663. * Serialize the current Lens Flare System into a JSON representation.
  52664. * @returns the serialized JSON
  52665. */
  52666. serialize(): any;
  52667. }
  52668. }
  52669. declare module "babylonjs/LensFlares/lensFlare" {
  52670. import { Nullable } from "babylonjs/types";
  52671. import { Color3 } from "babylonjs/Maths/math.color";
  52672. import { Texture } from "babylonjs/Materials/Textures/texture";
  52673. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52674. /**
  52675. * This represents one of the lens effect in a `lensFlareSystem`.
  52676. * It controls one of the indiviual texture used in the effect.
  52677. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52678. */
  52679. export class LensFlare {
  52680. /**
  52681. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52682. */
  52683. size: number;
  52684. /**
  52685. * 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.
  52686. */
  52687. position: number;
  52688. /**
  52689. * Define the lens color.
  52690. */
  52691. color: Color3;
  52692. /**
  52693. * Define the lens texture.
  52694. */
  52695. texture: Nullable<Texture>;
  52696. /**
  52697. * Define the alpha mode to render this particular lens.
  52698. */
  52699. alphaMode: number;
  52700. private _system;
  52701. /**
  52702. * Creates a new Lens Flare.
  52703. * This represents one of the lens effect in a `lensFlareSystem`.
  52704. * It controls one of the indiviual texture used in the effect.
  52705. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52706. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52707. * @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.
  52708. * @param color Define the lens color
  52709. * @param imgUrl Define the lens texture url
  52710. * @param system Define the `lensFlareSystem` this flare is part of
  52711. * @returns The newly created Lens Flare
  52712. */
  52713. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52714. /**
  52715. * Instantiates a new Lens Flare.
  52716. * This represents one of the lens effect in a `lensFlareSystem`.
  52717. * It controls one of the indiviual texture used in the effect.
  52718. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52719. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52720. * @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.
  52721. * @param color Define the lens color
  52722. * @param imgUrl Define the lens texture url
  52723. * @param system Define the `lensFlareSystem` this flare is part of
  52724. */
  52725. constructor(
  52726. /**
  52727. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52728. */
  52729. size: number,
  52730. /**
  52731. * 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.
  52732. */
  52733. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52734. /**
  52735. * Dispose and release the lens flare with its associated resources.
  52736. */
  52737. dispose(): void;
  52738. }
  52739. }
  52740. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52741. import { Nullable } from "babylonjs/types";
  52742. import { Scene } from "babylonjs/scene";
  52743. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52744. import { AbstractScene } from "babylonjs/abstractScene";
  52745. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52746. module "babylonjs/abstractScene" {
  52747. interface AbstractScene {
  52748. /**
  52749. * The list of lens flare system added to the scene
  52750. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52751. */
  52752. lensFlareSystems: Array<LensFlareSystem>;
  52753. /**
  52754. * Removes the given lens flare system from this scene.
  52755. * @param toRemove The lens flare system to remove
  52756. * @returns The index of the removed lens flare system
  52757. */
  52758. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52759. /**
  52760. * Adds the given lens flare system to this scene
  52761. * @param newLensFlareSystem The lens flare system to add
  52762. */
  52763. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52764. /**
  52765. * Gets a lens flare system using its name
  52766. * @param name defines the name to look for
  52767. * @returns the lens flare system or null if not found
  52768. */
  52769. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52770. /**
  52771. * Gets a lens flare system using its id
  52772. * @param id defines the id to look for
  52773. * @returns the lens flare system or null if not found
  52774. */
  52775. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52776. }
  52777. }
  52778. /**
  52779. * Defines the lens flare scene component responsible to manage any lens flares
  52780. * in a given scene.
  52781. */
  52782. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52783. /**
  52784. * The component name helpfull to identify the component in the list of scene components.
  52785. */
  52786. readonly name: string;
  52787. /**
  52788. * The scene the component belongs to.
  52789. */
  52790. scene: Scene;
  52791. /**
  52792. * Creates a new instance of the component for the given scene
  52793. * @param scene Defines the scene to register the component in
  52794. */
  52795. constructor(scene: Scene);
  52796. /**
  52797. * Registers the component in a given scene
  52798. */
  52799. register(): void;
  52800. /**
  52801. * Rebuilds the elements related to this component in case of
  52802. * context lost for instance.
  52803. */
  52804. rebuild(): void;
  52805. /**
  52806. * Adds all the elements from the container to the scene
  52807. * @param container the container holding the elements
  52808. */
  52809. addFromContainer(container: AbstractScene): void;
  52810. /**
  52811. * Removes all the elements in the container from the scene
  52812. * @param container contains the elements to remove
  52813. * @param dispose if the removed element should be disposed (default: false)
  52814. */
  52815. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52816. /**
  52817. * Serializes the component data to the specified json object
  52818. * @param serializationObject The object to serialize to
  52819. */
  52820. serialize(serializationObject: any): void;
  52821. /**
  52822. * Disposes the component and the associated ressources.
  52823. */
  52824. dispose(): void;
  52825. private _draw;
  52826. }
  52827. }
  52828. declare module "babylonjs/LensFlares/index" {
  52829. export * from "babylonjs/LensFlares/lensFlare";
  52830. export * from "babylonjs/LensFlares/lensFlareSystem";
  52831. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52832. }
  52833. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52834. import { Scene } from "babylonjs/scene";
  52835. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52836. import { AbstractScene } from "babylonjs/abstractScene";
  52837. /**
  52838. * Defines the shadow generator component responsible to manage any shadow generators
  52839. * in a given scene.
  52840. */
  52841. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52842. /**
  52843. * The component name helpfull to identify the component in the list of scene components.
  52844. */
  52845. readonly name: string;
  52846. /**
  52847. * The scene the component belongs to.
  52848. */
  52849. scene: Scene;
  52850. /**
  52851. * Creates a new instance of the component for the given scene
  52852. * @param scene Defines the scene to register the component in
  52853. */
  52854. constructor(scene: Scene);
  52855. /**
  52856. * Registers the component in a given scene
  52857. */
  52858. register(): void;
  52859. /**
  52860. * Rebuilds the elements related to this component in case of
  52861. * context lost for instance.
  52862. */
  52863. rebuild(): void;
  52864. /**
  52865. * Serializes the component data to the specified json object
  52866. * @param serializationObject The object to serialize to
  52867. */
  52868. serialize(serializationObject: any): void;
  52869. /**
  52870. * Adds all the elements from the container to the scene
  52871. * @param container the container holding the elements
  52872. */
  52873. addFromContainer(container: AbstractScene): void;
  52874. /**
  52875. * Removes all the elements in the container from the scene
  52876. * @param container contains the elements to remove
  52877. * @param dispose if the removed element should be disposed (default: false)
  52878. */
  52879. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52880. /**
  52881. * Rebuilds the elements related to this component in case of
  52882. * context lost for instance.
  52883. */
  52884. dispose(): void;
  52885. private _gatherRenderTargets;
  52886. }
  52887. }
  52888. declare module "babylonjs/Lights/Shadows/index" {
  52889. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52890. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52891. }
  52892. declare module "babylonjs/Lights/pointLight" {
  52893. import { Scene } from "babylonjs/scene";
  52894. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52896. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52897. import { Effect } from "babylonjs/Materials/effect";
  52898. /**
  52899. * A point light is a light defined by an unique point in world space.
  52900. * The light is emitted in every direction from this point.
  52901. * A good example of a point light is a standard light bulb.
  52902. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52903. */
  52904. export class PointLight extends ShadowLight {
  52905. private _shadowAngle;
  52906. /**
  52907. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52908. * This specifies what angle the shadow will use to be created.
  52909. *
  52910. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52911. */
  52912. /**
  52913. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52914. * This specifies what angle the shadow will use to be created.
  52915. *
  52916. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52917. */
  52918. shadowAngle: number;
  52919. /**
  52920. * Gets the direction if it has been set.
  52921. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52922. */
  52923. /**
  52924. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52925. */
  52926. direction: Vector3;
  52927. /**
  52928. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52929. * A PointLight emits the light in every direction.
  52930. * It can cast shadows.
  52931. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52932. * ```javascript
  52933. * var pointLight = new PointLight("pl", camera.position, scene);
  52934. * ```
  52935. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52936. * @param name The light friendly name
  52937. * @param position The position of the point light in the scene
  52938. * @param scene The scene the lights belongs to
  52939. */
  52940. constructor(name: string, position: Vector3, scene: Scene);
  52941. /**
  52942. * Returns the string "PointLight"
  52943. * @returns the class name
  52944. */
  52945. getClassName(): string;
  52946. /**
  52947. * Returns the integer 0.
  52948. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52949. */
  52950. getTypeID(): number;
  52951. /**
  52952. * Specifies wether or not the shadowmap should be a cube texture.
  52953. * @returns true if the shadowmap needs to be a cube texture.
  52954. */
  52955. needCube(): boolean;
  52956. /**
  52957. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52958. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52959. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52960. */
  52961. getShadowDirection(faceIndex?: number): Vector3;
  52962. /**
  52963. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52964. * - fov = PI / 2
  52965. * - aspect ratio : 1.0
  52966. * - z-near and far equal to the active camera minZ and maxZ.
  52967. * Returns the PointLight.
  52968. */
  52969. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52970. protected _buildUniformLayout(): void;
  52971. /**
  52972. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52973. * @param effect The effect to update
  52974. * @param lightIndex The index of the light in the effect to update
  52975. * @returns The point light
  52976. */
  52977. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52978. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52979. /**
  52980. * Prepares the list of defines specific to the light type.
  52981. * @param defines the list of defines
  52982. * @param lightIndex defines the index of the light for the effect
  52983. */
  52984. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52985. }
  52986. }
  52987. declare module "babylonjs/Lights/index" {
  52988. export * from "babylonjs/Lights/light";
  52989. export * from "babylonjs/Lights/shadowLight";
  52990. export * from "babylonjs/Lights/Shadows/index";
  52991. export * from "babylonjs/Lights/directionalLight";
  52992. export * from "babylonjs/Lights/hemisphericLight";
  52993. export * from "babylonjs/Lights/pointLight";
  52994. export * from "babylonjs/Lights/spotLight";
  52995. }
  52996. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52997. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52998. /**
  52999. * Header information of HDR texture files.
  53000. */
  53001. export interface HDRInfo {
  53002. /**
  53003. * The height of the texture in pixels.
  53004. */
  53005. height: number;
  53006. /**
  53007. * The width of the texture in pixels.
  53008. */
  53009. width: number;
  53010. /**
  53011. * The index of the beginning of the data in the binary file.
  53012. */
  53013. dataPosition: number;
  53014. }
  53015. /**
  53016. * This groups tools to convert HDR texture to native colors array.
  53017. */
  53018. export class HDRTools {
  53019. private static Ldexp;
  53020. private static Rgbe2float;
  53021. private static readStringLine;
  53022. /**
  53023. * Reads header information from an RGBE texture stored in a native array.
  53024. * More information on this format are available here:
  53025. * https://en.wikipedia.org/wiki/RGBE_image_format
  53026. *
  53027. * @param uint8array The binary file stored in native array.
  53028. * @return The header information.
  53029. */
  53030. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53031. /**
  53032. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53033. * This RGBE texture needs to store the information as a panorama.
  53034. *
  53035. * More information on this format are available here:
  53036. * https://en.wikipedia.org/wiki/RGBE_image_format
  53037. *
  53038. * @param buffer The binary file stored in an array buffer.
  53039. * @param size The expected size of the extracted cubemap.
  53040. * @return The Cube Map information.
  53041. */
  53042. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53043. /**
  53044. * Returns the pixels data extracted from an RGBE texture.
  53045. * This pixels will be stored left to right up to down in the R G B order in one array.
  53046. *
  53047. * More information on this format are available here:
  53048. * https://en.wikipedia.org/wiki/RGBE_image_format
  53049. *
  53050. * @param uint8array The binary file stored in an array buffer.
  53051. * @param hdrInfo The header information of the file.
  53052. * @return The pixels data in RGB right to left up to down order.
  53053. */
  53054. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53055. private static RGBE_ReadPixels_RLE;
  53056. }
  53057. }
  53058. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53059. import { Nullable } from "babylonjs/types";
  53060. import { Scene } from "babylonjs/scene";
  53061. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53062. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53063. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53064. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53065. /**
  53066. * This represents a texture coming from an HDR input.
  53067. *
  53068. * The only supported format is currently panorama picture stored in RGBE format.
  53069. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53070. */
  53071. export class HDRCubeTexture extends BaseTexture {
  53072. private static _facesMapping;
  53073. private _generateHarmonics;
  53074. private _noMipmap;
  53075. private _textureMatrix;
  53076. private _size;
  53077. private _onLoad;
  53078. private _onError;
  53079. /**
  53080. * The texture URL.
  53081. */
  53082. url: string;
  53083. /**
  53084. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53085. */
  53086. coordinatesMode: number;
  53087. protected _isBlocking: boolean;
  53088. /**
  53089. * Sets wether or not the texture is blocking during loading.
  53090. */
  53091. /**
  53092. * Gets wether or not the texture is blocking during loading.
  53093. */
  53094. isBlocking: boolean;
  53095. protected _rotationY: number;
  53096. /**
  53097. * Sets texture matrix rotation angle around Y axis in radians.
  53098. */
  53099. /**
  53100. * Gets texture matrix rotation angle around Y axis radians.
  53101. */
  53102. rotationY: number;
  53103. /**
  53104. * Gets or sets the center of the bounding box associated with the cube texture
  53105. * It must define where the camera used to render the texture was set
  53106. */
  53107. boundingBoxPosition: Vector3;
  53108. private _boundingBoxSize;
  53109. /**
  53110. * Gets or sets the size of the bounding box associated with the cube texture
  53111. * When defined, the cubemap will switch to local mode
  53112. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53113. * @example https://www.babylonjs-playground.com/#RNASML
  53114. */
  53115. boundingBoxSize: Vector3;
  53116. /**
  53117. * Instantiates an HDRTexture from the following parameters.
  53118. *
  53119. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53120. * @param scene The scene the texture will be used in
  53121. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53122. * @param noMipmap Forces to not generate the mipmap if true
  53123. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53124. * @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)
  53125. * @param reserved Reserved flag for internal use.
  53126. */
  53127. 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>);
  53128. /**
  53129. * Get the current class name of the texture useful for serialization or dynamic coding.
  53130. * @returns "HDRCubeTexture"
  53131. */
  53132. getClassName(): string;
  53133. /**
  53134. * Occurs when the file is raw .hdr file.
  53135. */
  53136. private loadTexture;
  53137. clone(): HDRCubeTexture;
  53138. delayLoad(): void;
  53139. /**
  53140. * Get the texture reflection matrix used to rotate/transform the reflection.
  53141. * @returns the reflection matrix
  53142. */
  53143. getReflectionTextureMatrix(): Matrix;
  53144. /**
  53145. * Set the texture reflection matrix used to rotate/transform the reflection.
  53146. * @param value Define the reflection matrix to set
  53147. */
  53148. setReflectionTextureMatrix(value: Matrix): void;
  53149. /**
  53150. * Parses a JSON representation of an HDR Texture in order to create the texture
  53151. * @param parsedTexture Define the JSON representation
  53152. * @param scene Define the scene the texture should be created in
  53153. * @param rootUrl Define the root url in case we need to load relative dependencies
  53154. * @returns the newly created texture after parsing
  53155. */
  53156. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53157. serialize(): any;
  53158. }
  53159. }
  53160. declare module "babylonjs/Physics/physicsEngine" {
  53161. import { Nullable } from "babylonjs/types";
  53162. import { Vector3 } from "babylonjs/Maths/math.vector";
  53163. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53164. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53165. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53166. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53167. /**
  53168. * Class used to control physics engine
  53169. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53170. */
  53171. export class PhysicsEngine implements IPhysicsEngine {
  53172. private _physicsPlugin;
  53173. /**
  53174. * Global value used to control the smallest number supported by the simulation
  53175. */
  53176. static Epsilon: number;
  53177. private _impostors;
  53178. private _joints;
  53179. /**
  53180. * Gets the gravity vector used by the simulation
  53181. */
  53182. gravity: Vector3;
  53183. /**
  53184. * Factory used to create the default physics plugin.
  53185. * @returns The default physics plugin
  53186. */
  53187. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53188. /**
  53189. * Creates a new Physics Engine
  53190. * @param gravity defines the gravity vector used by the simulation
  53191. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53192. */
  53193. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53194. /**
  53195. * Sets the gravity vector used by the simulation
  53196. * @param gravity defines the gravity vector to use
  53197. */
  53198. setGravity(gravity: Vector3): void;
  53199. /**
  53200. * Set the time step of the physics engine.
  53201. * Default is 1/60.
  53202. * To slow it down, enter 1/600 for example.
  53203. * To speed it up, 1/30
  53204. * @param newTimeStep defines the new timestep to apply to this world.
  53205. */
  53206. setTimeStep(newTimeStep?: number): void;
  53207. /**
  53208. * Get the time step of the physics engine.
  53209. * @returns the current time step
  53210. */
  53211. getTimeStep(): number;
  53212. /**
  53213. * Release all resources
  53214. */
  53215. dispose(): void;
  53216. /**
  53217. * Gets the name of the current physics plugin
  53218. * @returns the name of the plugin
  53219. */
  53220. getPhysicsPluginName(): string;
  53221. /**
  53222. * Adding a new impostor for the impostor tracking.
  53223. * This will be done by the impostor itself.
  53224. * @param impostor the impostor to add
  53225. */
  53226. addImpostor(impostor: PhysicsImpostor): void;
  53227. /**
  53228. * Remove an impostor from the engine.
  53229. * This impostor and its mesh will not longer be updated by the physics engine.
  53230. * @param impostor the impostor to remove
  53231. */
  53232. removeImpostor(impostor: PhysicsImpostor): void;
  53233. /**
  53234. * Add a joint to the physics engine
  53235. * @param mainImpostor defines the main impostor to which the joint is added.
  53236. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53237. * @param joint defines the joint that will connect both impostors.
  53238. */
  53239. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53240. /**
  53241. * Removes a joint from the simulation
  53242. * @param mainImpostor defines the impostor used with the joint
  53243. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53244. * @param joint defines the joint to remove
  53245. */
  53246. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53247. /**
  53248. * Called by the scene. No need to call it.
  53249. * @param delta defines the timespam between frames
  53250. */
  53251. _step(delta: number): void;
  53252. /**
  53253. * Gets the current plugin used to run the simulation
  53254. * @returns current plugin
  53255. */
  53256. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53257. /**
  53258. * Gets the list of physic impostors
  53259. * @returns an array of PhysicsImpostor
  53260. */
  53261. getImpostors(): Array<PhysicsImpostor>;
  53262. /**
  53263. * Gets the impostor for a physics enabled object
  53264. * @param object defines the object impersonated by the impostor
  53265. * @returns the PhysicsImpostor or null if not found
  53266. */
  53267. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53268. /**
  53269. * Gets the impostor for a physics body object
  53270. * @param body defines physics body used by the impostor
  53271. * @returns the PhysicsImpostor or null if not found
  53272. */
  53273. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53274. /**
  53275. * Does a raycast in the physics world
  53276. * @param from when should the ray start?
  53277. * @param to when should the ray end?
  53278. * @returns PhysicsRaycastResult
  53279. */
  53280. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53281. }
  53282. }
  53283. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53284. import { Nullable } from "babylonjs/types";
  53285. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53287. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53288. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53289. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53290. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53291. /** @hidden */
  53292. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53293. private _useDeltaForWorldStep;
  53294. world: any;
  53295. name: string;
  53296. private _physicsMaterials;
  53297. private _fixedTimeStep;
  53298. private _cannonRaycastResult;
  53299. private _raycastResult;
  53300. private _physicsBodysToRemoveAfterStep;
  53301. BJSCANNON: any;
  53302. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53303. setGravity(gravity: Vector3): void;
  53304. setTimeStep(timeStep: number): void;
  53305. getTimeStep(): number;
  53306. executeStep(delta: number): void;
  53307. private _removeMarkedPhysicsBodiesFromWorld;
  53308. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53309. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53310. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53311. private _processChildMeshes;
  53312. removePhysicsBody(impostor: PhysicsImpostor): void;
  53313. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53314. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53315. private _addMaterial;
  53316. private _checkWithEpsilon;
  53317. private _createShape;
  53318. private _createHeightmap;
  53319. private _minus90X;
  53320. private _plus90X;
  53321. private _tmpPosition;
  53322. private _tmpDeltaPosition;
  53323. private _tmpUnityRotation;
  53324. private _updatePhysicsBodyTransformation;
  53325. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53326. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53327. isSupported(): boolean;
  53328. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53329. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53330. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53331. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53332. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53333. getBodyMass(impostor: PhysicsImpostor): number;
  53334. getBodyFriction(impostor: PhysicsImpostor): number;
  53335. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53336. getBodyRestitution(impostor: PhysicsImpostor): number;
  53337. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53338. sleepBody(impostor: PhysicsImpostor): void;
  53339. wakeUpBody(impostor: PhysicsImpostor): void;
  53340. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53341. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53342. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53343. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53344. getRadius(impostor: PhysicsImpostor): number;
  53345. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53346. dispose(): void;
  53347. private _extendNamespace;
  53348. /**
  53349. * Does a raycast in the physics world
  53350. * @param from when should the ray start?
  53351. * @param to when should the ray end?
  53352. * @returns PhysicsRaycastResult
  53353. */
  53354. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53355. }
  53356. }
  53357. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53358. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53359. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53360. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53362. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53363. import { Nullable } from "babylonjs/types";
  53364. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53365. /** @hidden */
  53366. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53367. world: any;
  53368. name: string;
  53369. BJSOIMO: any;
  53370. private _raycastResult;
  53371. constructor(iterations?: number, oimoInjection?: any);
  53372. setGravity(gravity: Vector3): void;
  53373. setTimeStep(timeStep: number): void;
  53374. getTimeStep(): number;
  53375. private _tmpImpostorsArray;
  53376. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53377. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53378. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53379. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53380. private _tmpPositionVector;
  53381. removePhysicsBody(impostor: PhysicsImpostor): void;
  53382. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53383. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53384. isSupported(): boolean;
  53385. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53386. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53387. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53388. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53389. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53390. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53391. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53392. getBodyMass(impostor: PhysicsImpostor): number;
  53393. getBodyFriction(impostor: PhysicsImpostor): number;
  53394. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53395. getBodyRestitution(impostor: PhysicsImpostor): number;
  53396. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53397. sleepBody(impostor: PhysicsImpostor): void;
  53398. wakeUpBody(impostor: PhysicsImpostor): void;
  53399. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53400. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53401. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53402. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53403. getRadius(impostor: PhysicsImpostor): number;
  53404. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53405. dispose(): void;
  53406. /**
  53407. * Does a raycast in the physics world
  53408. * @param from when should the ray start?
  53409. * @param to when should the ray end?
  53410. * @returns PhysicsRaycastResult
  53411. */
  53412. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53413. }
  53414. }
  53415. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53416. import { Nullable } from "babylonjs/types";
  53417. import { Scene } from "babylonjs/scene";
  53418. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53419. import { Color4 } from "babylonjs/Maths/math.color";
  53420. import { Mesh } from "babylonjs/Meshes/mesh";
  53421. /**
  53422. * Class containing static functions to help procedurally build meshes
  53423. */
  53424. export class RibbonBuilder {
  53425. /**
  53426. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53427. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53428. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53429. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53430. * * 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
  53431. * * 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
  53432. * * 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
  53433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53434. * * 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
  53435. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53436. * * 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
  53437. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53438. * * 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
  53439. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53441. * @param name defines the name of the mesh
  53442. * @param options defines the options used to create the mesh
  53443. * @param scene defines the hosting scene
  53444. * @returns the ribbon mesh
  53445. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53446. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53447. */
  53448. static CreateRibbon(name: string, options: {
  53449. pathArray: Vector3[][];
  53450. closeArray?: boolean;
  53451. closePath?: boolean;
  53452. offset?: number;
  53453. updatable?: boolean;
  53454. sideOrientation?: number;
  53455. frontUVs?: Vector4;
  53456. backUVs?: Vector4;
  53457. instance?: Mesh;
  53458. invertUV?: boolean;
  53459. uvs?: Vector2[];
  53460. colors?: Color4[];
  53461. }, scene?: Nullable<Scene>): Mesh;
  53462. }
  53463. }
  53464. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53465. import { Nullable } from "babylonjs/types";
  53466. import { Scene } from "babylonjs/scene";
  53467. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53468. import { Mesh } from "babylonjs/Meshes/mesh";
  53469. /**
  53470. * Class containing static functions to help procedurally build meshes
  53471. */
  53472. export class ShapeBuilder {
  53473. /**
  53474. * 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.
  53475. * * 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.
  53476. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53477. * * 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.
  53478. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53479. * * 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
  53480. * * 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
  53481. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53483. * * 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
  53484. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53486. * @param name defines the name of the mesh
  53487. * @param options defines the options used to create the mesh
  53488. * @param scene defines the hosting scene
  53489. * @returns the extruded shape mesh
  53490. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53491. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53492. */
  53493. static ExtrudeShape(name: string, options: {
  53494. shape: Vector3[];
  53495. path: Vector3[];
  53496. scale?: number;
  53497. rotation?: number;
  53498. cap?: number;
  53499. updatable?: boolean;
  53500. sideOrientation?: number;
  53501. frontUVs?: Vector4;
  53502. backUVs?: Vector4;
  53503. instance?: Mesh;
  53504. invertUV?: boolean;
  53505. }, scene?: Nullable<Scene>): Mesh;
  53506. /**
  53507. * Creates an custom extruded shape mesh.
  53508. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53509. * * 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.
  53510. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53511. * * 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
  53512. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53513. * * 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
  53514. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53515. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53516. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53517. * * 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
  53518. * * 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
  53519. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53520. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53521. * * 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
  53522. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53524. * @param name defines the name of the mesh
  53525. * @param options defines the options used to create the mesh
  53526. * @param scene defines the hosting scene
  53527. * @returns the custom extruded shape mesh
  53528. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53529. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53530. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53531. */
  53532. static ExtrudeShapeCustom(name: string, options: {
  53533. shape: Vector3[];
  53534. path: Vector3[];
  53535. scaleFunction?: any;
  53536. rotationFunction?: any;
  53537. ribbonCloseArray?: boolean;
  53538. ribbonClosePath?: boolean;
  53539. cap?: number;
  53540. updatable?: boolean;
  53541. sideOrientation?: number;
  53542. frontUVs?: Vector4;
  53543. backUVs?: Vector4;
  53544. instance?: Mesh;
  53545. invertUV?: boolean;
  53546. }, scene?: Nullable<Scene>): Mesh;
  53547. private static _ExtrudeShapeGeneric;
  53548. }
  53549. }
  53550. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53551. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53552. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53553. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53554. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53555. import { Nullable } from "babylonjs/types";
  53556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53557. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53558. /**
  53559. * AmmoJS Physics plugin
  53560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53561. * @see https://github.com/kripken/ammo.js/
  53562. */
  53563. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53564. private _useDeltaForWorldStep;
  53565. /**
  53566. * Reference to the Ammo library
  53567. */
  53568. bjsAMMO: any;
  53569. /**
  53570. * Created ammoJS world which physics bodies are added to
  53571. */
  53572. world: any;
  53573. /**
  53574. * Name of the plugin
  53575. */
  53576. name: string;
  53577. private _timeStep;
  53578. private _fixedTimeStep;
  53579. private _maxSteps;
  53580. private _tmpQuaternion;
  53581. private _tmpAmmoTransform;
  53582. private _tmpAmmoQuaternion;
  53583. private _tmpAmmoConcreteContactResultCallback;
  53584. private _collisionConfiguration;
  53585. private _dispatcher;
  53586. private _overlappingPairCache;
  53587. private _solver;
  53588. private _softBodySolver;
  53589. private _tmpAmmoVectorA;
  53590. private _tmpAmmoVectorB;
  53591. private _tmpAmmoVectorC;
  53592. private _tmpAmmoVectorD;
  53593. private _tmpContactCallbackResult;
  53594. private _tmpAmmoVectorRCA;
  53595. private _tmpAmmoVectorRCB;
  53596. private _raycastResult;
  53597. private static readonly DISABLE_COLLISION_FLAG;
  53598. private static readonly KINEMATIC_FLAG;
  53599. private static readonly DISABLE_DEACTIVATION_FLAG;
  53600. /**
  53601. * Initializes the ammoJS plugin
  53602. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53603. * @param ammoInjection can be used to inject your own ammo reference
  53604. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53605. */
  53606. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53607. /**
  53608. * Sets the gravity of the physics world (m/(s^2))
  53609. * @param gravity Gravity to set
  53610. */
  53611. setGravity(gravity: Vector3): void;
  53612. /**
  53613. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53614. * @param timeStep timestep to use in seconds
  53615. */
  53616. setTimeStep(timeStep: number): void;
  53617. /**
  53618. * 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)
  53619. * @param fixedTimeStep fixedTimeStep to use in seconds
  53620. */
  53621. setFixedTimeStep(fixedTimeStep: number): void;
  53622. /**
  53623. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53624. * @param maxSteps the maximum number of steps by the physics engine per frame
  53625. */
  53626. setMaxSteps(maxSteps: number): void;
  53627. /**
  53628. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53629. * @returns the current timestep in seconds
  53630. */
  53631. getTimeStep(): number;
  53632. private _isImpostorInContact;
  53633. private _isImpostorPairInContact;
  53634. private _stepSimulation;
  53635. /**
  53636. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53637. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53638. * After the step the babylon meshes are set to the position of the physics imposters
  53639. * @param delta amount of time to step forward
  53640. * @param impostors array of imposters to update before/after the step
  53641. */
  53642. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53643. /**
  53644. * Update babylon mesh to match physics world object
  53645. * @param impostor imposter to match
  53646. */
  53647. private _afterSoftStep;
  53648. /**
  53649. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53650. * @param impostor imposter to match
  53651. */
  53652. private _ropeStep;
  53653. /**
  53654. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53655. * @param impostor imposter to match
  53656. */
  53657. private _softbodyOrClothStep;
  53658. private _tmpVector;
  53659. private _tmpMatrix;
  53660. /**
  53661. * Applies an impulse on the imposter
  53662. * @param impostor imposter to apply impulse to
  53663. * @param force amount of force to be applied to the imposter
  53664. * @param contactPoint the location to apply the impulse on the imposter
  53665. */
  53666. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53667. /**
  53668. * Applies a force on the imposter
  53669. * @param impostor imposter to apply force
  53670. * @param force amount of force to be applied to the imposter
  53671. * @param contactPoint the location to apply the force on the imposter
  53672. */
  53673. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53674. /**
  53675. * Creates a physics body using the plugin
  53676. * @param impostor the imposter to create the physics body on
  53677. */
  53678. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53679. /**
  53680. * Removes the physics body from the imposter and disposes of the body's memory
  53681. * @param impostor imposter to remove the physics body from
  53682. */
  53683. removePhysicsBody(impostor: PhysicsImpostor): void;
  53684. /**
  53685. * Generates a joint
  53686. * @param impostorJoint the imposter joint to create the joint with
  53687. */
  53688. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53689. /**
  53690. * Removes a joint
  53691. * @param impostorJoint the imposter joint to remove the joint from
  53692. */
  53693. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53694. private _addMeshVerts;
  53695. /**
  53696. * Initialise the soft body vertices to match its object's (mesh) vertices
  53697. * Softbody vertices (nodes) are in world space and to match this
  53698. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53699. * @param impostor to create the softbody for
  53700. */
  53701. private _softVertexData;
  53702. /**
  53703. * Create an impostor's soft body
  53704. * @param impostor to create the softbody for
  53705. */
  53706. private _createSoftbody;
  53707. /**
  53708. * Create cloth for an impostor
  53709. * @param impostor to create the softbody for
  53710. */
  53711. private _createCloth;
  53712. /**
  53713. * Create rope for an impostor
  53714. * @param impostor to create the softbody for
  53715. */
  53716. private _createRope;
  53717. private _addHullVerts;
  53718. private _createShape;
  53719. /**
  53720. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53721. * @param impostor imposter containing the physics body and babylon object
  53722. */
  53723. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53724. /**
  53725. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53726. * @param impostor imposter containing the physics body and babylon object
  53727. * @param newPosition new position
  53728. * @param newRotation new rotation
  53729. */
  53730. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53731. /**
  53732. * If this plugin is supported
  53733. * @returns true if its supported
  53734. */
  53735. isSupported(): boolean;
  53736. /**
  53737. * Sets the linear velocity of the physics body
  53738. * @param impostor imposter to set the velocity on
  53739. * @param velocity velocity to set
  53740. */
  53741. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53742. /**
  53743. * Sets the angular velocity of the physics body
  53744. * @param impostor imposter to set the velocity on
  53745. * @param velocity velocity to set
  53746. */
  53747. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53748. /**
  53749. * gets the linear velocity
  53750. * @param impostor imposter to get linear velocity from
  53751. * @returns linear velocity
  53752. */
  53753. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53754. /**
  53755. * gets the angular velocity
  53756. * @param impostor imposter to get angular velocity from
  53757. * @returns angular velocity
  53758. */
  53759. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53760. /**
  53761. * Sets the mass of physics body
  53762. * @param impostor imposter to set the mass on
  53763. * @param mass mass to set
  53764. */
  53765. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53766. /**
  53767. * Gets the mass of the physics body
  53768. * @param impostor imposter to get the mass from
  53769. * @returns mass
  53770. */
  53771. getBodyMass(impostor: PhysicsImpostor): number;
  53772. /**
  53773. * Gets friction of the impostor
  53774. * @param impostor impostor to get friction from
  53775. * @returns friction value
  53776. */
  53777. getBodyFriction(impostor: PhysicsImpostor): number;
  53778. /**
  53779. * Sets friction of the impostor
  53780. * @param impostor impostor to set friction on
  53781. * @param friction friction value
  53782. */
  53783. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53784. /**
  53785. * Gets restitution of the impostor
  53786. * @param impostor impostor to get restitution from
  53787. * @returns restitution value
  53788. */
  53789. getBodyRestitution(impostor: PhysicsImpostor): number;
  53790. /**
  53791. * Sets resitution of the impostor
  53792. * @param impostor impostor to set resitution on
  53793. * @param restitution resitution value
  53794. */
  53795. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53796. /**
  53797. * Gets pressure inside the impostor
  53798. * @param impostor impostor to get pressure from
  53799. * @returns pressure value
  53800. */
  53801. getBodyPressure(impostor: PhysicsImpostor): number;
  53802. /**
  53803. * Sets pressure inside a soft body impostor
  53804. * Cloth and rope must remain 0 pressure
  53805. * @param impostor impostor to set pressure on
  53806. * @param pressure pressure value
  53807. */
  53808. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53809. /**
  53810. * Gets stiffness of the impostor
  53811. * @param impostor impostor to get stiffness from
  53812. * @returns pressure value
  53813. */
  53814. getBodyStiffness(impostor: PhysicsImpostor): number;
  53815. /**
  53816. * Sets stiffness of the impostor
  53817. * @param impostor impostor to set stiffness on
  53818. * @param stiffness stiffness value from 0 to 1
  53819. */
  53820. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53821. /**
  53822. * Gets velocityIterations of the impostor
  53823. * @param impostor impostor to get velocity iterations from
  53824. * @returns velocityIterations value
  53825. */
  53826. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53827. /**
  53828. * Sets velocityIterations of the impostor
  53829. * @param impostor impostor to set velocity iterations on
  53830. * @param velocityIterations velocityIterations value
  53831. */
  53832. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53833. /**
  53834. * Gets positionIterations of the impostor
  53835. * @param impostor impostor to get position iterations from
  53836. * @returns positionIterations value
  53837. */
  53838. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53839. /**
  53840. * Sets positionIterations of the impostor
  53841. * @param impostor impostor to set position on
  53842. * @param positionIterations positionIterations value
  53843. */
  53844. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53845. /**
  53846. * Append an anchor to a cloth object
  53847. * @param impostor is the cloth impostor to add anchor to
  53848. * @param otherImpostor is the rigid impostor to anchor to
  53849. * @param width ratio across width from 0 to 1
  53850. * @param height ratio up height from 0 to 1
  53851. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53852. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53853. */
  53854. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53855. /**
  53856. * Append an hook to a rope object
  53857. * @param impostor is the rope impostor to add hook to
  53858. * @param otherImpostor is the rigid impostor to hook to
  53859. * @param length ratio along the rope from 0 to 1
  53860. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53861. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53862. */
  53863. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53864. /**
  53865. * Sleeps the physics body and stops it from being active
  53866. * @param impostor impostor to sleep
  53867. */
  53868. sleepBody(impostor: PhysicsImpostor): void;
  53869. /**
  53870. * Activates the physics body
  53871. * @param impostor impostor to activate
  53872. */
  53873. wakeUpBody(impostor: PhysicsImpostor): void;
  53874. /**
  53875. * Updates the distance parameters of the joint
  53876. * @param joint joint to update
  53877. * @param maxDistance maximum distance of the joint
  53878. * @param minDistance minimum distance of the joint
  53879. */
  53880. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53881. /**
  53882. * Sets a motor on the joint
  53883. * @param joint joint to set motor on
  53884. * @param speed speed of the motor
  53885. * @param maxForce maximum force of the motor
  53886. * @param motorIndex index of the motor
  53887. */
  53888. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53889. /**
  53890. * Sets the motors limit
  53891. * @param joint joint to set limit on
  53892. * @param upperLimit upper limit
  53893. * @param lowerLimit lower limit
  53894. */
  53895. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53896. /**
  53897. * Syncs the position and rotation of a mesh with the impostor
  53898. * @param mesh mesh to sync
  53899. * @param impostor impostor to update the mesh with
  53900. */
  53901. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53902. /**
  53903. * Gets the radius of the impostor
  53904. * @param impostor impostor to get radius from
  53905. * @returns the radius
  53906. */
  53907. getRadius(impostor: PhysicsImpostor): number;
  53908. /**
  53909. * Gets the box size of the impostor
  53910. * @param impostor impostor to get box size from
  53911. * @param result the resulting box size
  53912. */
  53913. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53914. /**
  53915. * Disposes of the impostor
  53916. */
  53917. dispose(): void;
  53918. /**
  53919. * Does a raycast in the physics world
  53920. * @param from when should the ray start?
  53921. * @param to when should the ray end?
  53922. * @returns PhysicsRaycastResult
  53923. */
  53924. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53925. }
  53926. }
  53927. declare module "babylonjs/Probes/reflectionProbe" {
  53928. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53929. import { Vector3 } from "babylonjs/Maths/math.vector";
  53930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53931. import { Nullable } from "babylonjs/types";
  53932. import { Scene } from "babylonjs/scene";
  53933. module "babylonjs/abstractScene" {
  53934. interface AbstractScene {
  53935. /**
  53936. * The list of reflection probes added to the scene
  53937. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53938. */
  53939. reflectionProbes: Array<ReflectionProbe>;
  53940. /**
  53941. * Removes the given reflection probe from this scene.
  53942. * @param toRemove The reflection probe to remove
  53943. * @returns The index of the removed reflection probe
  53944. */
  53945. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53946. /**
  53947. * Adds the given reflection probe to this scene.
  53948. * @param newReflectionProbe The reflection probe to add
  53949. */
  53950. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53951. }
  53952. }
  53953. /**
  53954. * Class used to generate realtime reflection / refraction cube textures
  53955. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53956. */
  53957. export class ReflectionProbe {
  53958. /** defines the name of the probe */
  53959. name: string;
  53960. private _scene;
  53961. private _renderTargetTexture;
  53962. private _projectionMatrix;
  53963. private _viewMatrix;
  53964. private _target;
  53965. private _add;
  53966. private _attachedMesh;
  53967. private _invertYAxis;
  53968. /** Gets or sets probe position (center of the cube map) */
  53969. position: Vector3;
  53970. /**
  53971. * Creates a new reflection probe
  53972. * @param name defines the name of the probe
  53973. * @param size defines the texture resolution (for each face)
  53974. * @param scene defines the hosting scene
  53975. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53976. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53977. */
  53978. constructor(
  53979. /** defines the name of the probe */
  53980. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53981. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53982. samples: number;
  53983. /** Gets or sets the refresh rate to use (on every frame by default) */
  53984. refreshRate: number;
  53985. /**
  53986. * Gets the hosting scene
  53987. * @returns a Scene
  53988. */
  53989. getScene(): Scene;
  53990. /** Gets the internal CubeTexture used to render to */
  53991. readonly cubeTexture: RenderTargetTexture;
  53992. /** Gets the list of meshes to render */
  53993. readonly renderList: Nullable<AbstractMesh[]>;
  53994. /**
  53995. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53996. * @param mesh defines the mesh to attach to
  53997. */
  53998. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53999. /**
  54000. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54001. * @param renderingGroupId The rendering group id corresponding to its index
  54002. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54003. */
  54004. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54005. /**
  54006. * Clean all associated resources
  54007. */
  54008. dispose(): void;
  54009. /**
  54010. * Converts the reflection probe information to a readable string for debug purpose.
  54011. * @param fullDetails Supports for multiple levels of logging within scene loading
  54012. * @returns the human readable reflection probe info
  54013. */
  54014. toString(fullDetails?: boolean): string;
  54015. /**
  54016. * Get the class name of the relfection probe.
  54017. * @returns "ReflectionProbe"
  54018. */
  54019. getClassName(): string;
  54020. /**
  54021. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54022. * @returns The JSON representation of the texture
  54023. */
  54024. serialize(): any;
  54025. /**
  54026. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54027. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54028. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54029. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54030. * @returns The parsed reflection probe if successful
  54031. */
  54032. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54033. }
  54034. }
  54035. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54036. /** @hidden */
  54037. export var _BabylonLoaderRegistered: boolean;
  54038. }
  54039. declare module "babylonjs/Loading/Plugins/index" {
  54040. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54041. }
  54042. declare module "babylonjs/Loading/index" {
  54043. export * from "babylonjs/Loading/loadingScreen";
  54044. export * from "babylonjs/Loading/Plugins/index";
  54045. export * from "babylonjs/Loading/sceneLoader";
  54046. export * from "babylonjs/Loading/sceneLoaderFlags";
  54047. }
  54048. declare module "babylonjs/Materials/Background/index" {
  54049. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54050. }
  54051. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54052. import { Scene } from "babylonjs/scene";
  54053. import { Color3 } from "babylonjs/Maths/math.color";
  54054. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54055. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54056. /**
  54057. * The Physically based simple base material of BJS.
  54058. *
  54059. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54060. * It is used as the base class for both the specGloss and metalRough conventions.
  54061. */
  54062. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54063. /**
  54064. * Number of Simultaneous lights allowed on the material.
  54065. */
  54066. maxSimultaneousLights: number;
  54067. /**
  54068. * If sets to true, disables all the lights affecting the material.
  54069. */
  54070. disableLighting: boolean;
  54071. /**
  54072. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54073. */
  54074. environmentTexture: BaseTexture;
  54075. /**
  54076. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54077. */
  54078. invertNormalMapX: boolean;
  54079. /**
  54080. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54081. */
  54082. invertNormalMapY: boolean;
  54083. /**
  54084. * Normal map used in the model.
  54085. */
  54086. normalTexture: BaseTexture;
  54087. /**
  54088. * Emissivie color used to self-illuminate the model.
  54089. */
  54090. emissiveColor: Color3;
  54091. /**
  54092. * Emissivie texture used to self-illuminate the model.
  54093. */
  54094. emissiveTexture: BaseTexture;
  54095. /**
  54096. * Occlusion Channel Strenght.
  54097. */
  54098. occlusionStrength: number;
  54099. /**
  54100. * Occlusion Texture of the material (adding extra occlusion effects).
  54101. */
  54102. occlusionTexture: BaseTexture;
  54103. /**
  54104. * Defines the alpha limits in alpha test mode.
  54105. */
  54106. alphaCutOff: number;
  54107. /**
  54108. * Gets the current double sided mode.
  54109. */
  54110. /**
  54111. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54112. */
  54113. doubleSided: boolean;
  54114. /**
  54115. * Stores the pre-calculated light information of a mesh in a texture.
  54116. */
  54117. lightmapTexture: BaseTexture;
  54118. /**
  54119. * If true, the light map contains occlusion information instead of lighting info.
  54120. */
  54121. useLightmapAsShadowmap: boolean;
  54122. /**
  54123. * Instantiates a new PBRMaterial instance.
  54124. *
  54125. * @param name The material name
  54126. * @param scene The scene the material will be use in.
  54127. */
  54128. constructor(name: string, scene: Scene);
  54129. getClassName(): string;
  54130. }
  54131. }
  54132. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54133. import { Scene } from "babylonjs/scene";
  54134. import { Color3 } from "babylonjs/Maths/math.color";
  54135. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54136. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54137. /**
  54138. * The PBR material of BJS following the metal roughness convention.
  54139. *
  54140. * This fits to the PBR convention in the GLTF definition:
  54141. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54142. */
  54143. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54144. /**
  54145. * The base color has two different interpretations depending on the value of metalness.
  54146. * When the material is a metal, the base color is the specific measured reflectance value
  54147. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54148. * of the material.
  54149. */
  54150. baseColor: Color3;
  54151. /**
  54152. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54153. * well as opacity information in the alpha channel.
  54154. */
  54155. baseTexture: BaseTexture;
  54156. /**
  54157. * Specifies the metallic scalar value of the material.
  54158. * Can also be used to scale the metalness values of the metallic texture.
  54159. */
  54160. metallic: number;
  54161. /**
  54162. * Specifies the roughness scalar value of the material.
  54163. * Can also be used to scale the roughness values of the metallic texture.
  54164. */
  54165. roughness: number;
  54166. /**
  54167. * Texture containing both the metallic value in the B channel and the
  54168. * roughness value in the G channel to keep better precision.
  54169. */
  54170. metallicRoughnessTexture: BaseTexture;
  54171. /**
  54172. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54173. *
  54174. * @param name The material name
  54175. * @param scene The scene the material will be use in.
  54176. */
  54177. constructor(name: string, scene: Scene);
  54178. /**
  54179. * Return the currrent class name of the material.
  54180. */
  54181. getClassName(): string;
  54182. /**
  54183. * Makes a duplicate of the current material.
  54184. * @param name - name to use for the new material.
  54185. */
  54186. clone(name: string): PBRMetallicRoughnessMaterial;
  54187. /**
  54188. * Serialize the material to a parsable JSON object.
  54189. */
  54190. serialize(): any;
  54191. /**
  54192. * Parses a JSON object correponding to the serialize function.
  54193. */
  54194. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54195. }
  54196. }
  54197. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54198. import { Scene } from "babylonjs/scene";
  54199. import { Color3 } from "babylonjs/Maths/math.color";
  54200. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54201. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54202. /**
  54203. * The PBR material of BJS following the specular glossiness convention.
  54204. *
  54205. * This fits to the PBR convention in the GLTF definition:
  54206. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54207. */
  54208. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54209. /**
  54210. * Specifies the diffuse color of the material.
  54211. */
  54212. diffuseColor: Color3;
  54213. /**
  54214. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54215. * channel.
  54216. */
  54217. diffuseTexture: BaseTexture;
  54218. /**
  54219. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54220. */
  54221. specularColor: Color3;
  54222. /**
  54223. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54224. */
  54225. glossiness: number;
  54226. /**
  54227. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54228. */
  54229. specularGlossinessTexture: BaseTexture;
  54230. /**
  54231. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54232. *
  54233. * @param name The material name
  54234. * @param scene The scene the material will be use in.
  54235. */
  54236. constructor(name: string, scene: Scene);
  54237. /**
  54238. * Return the currrent class name of the material.
  54239. */
  54240. getClassName(): string;
  54241. /**
  54242. * Makes a duplicate of the current material.
  54243. * @param name - name to use for the new material.
  54244. */
  54245. clone(name: string): PBRSpecularGlossinessMaterial;
  54246. /**
  54247. * Serialize the material to a parsable JSON object.
  54248. */
  54249. serialize(): any;
  54250. /**
  54251. * Parses a JSON object correponding to the serialize function.
  54252. */
  54253. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54254. }
  54255. }
  54256. declare module "babylonjs/Materials/PBR/index" {
  54257. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54258. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54259. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54260. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54261. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54262. }
  54263. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54264. import { Nullable } from "babylonjs/types";
  54265. import { Scene } from "babylonjs/scene";
  54266. import { Matrix } from "babylonjs/Maths/math.vector";
  54267. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54268. /**
  54269. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54270. * It can help converting any input color in a desired output one. This can then be used to create effects
  54271. * from sepia, black and white to sixties or futuristic rendering...
  54272. *
  54273. * The only supported format is currently 3dl.
  54274. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54275. */
  54276. export class ColorGradingTexture extends BaseTexture {
  54277. /**
  54278. * The current texture matrix. (will always be identity in color grading texture)
  54279. */
  54280. private _textureMatrix;
  54281. /**
  54282. * The texture URL.
  54283. */
  54284. url: string;
  54285. /**
  54286. * Empty line regex stored for GC.
  54287. */
  54288. private static _noneEmptyLineRegex;
  54289. private _engine;
  54290. /**
  54291. * Instantiates a ColorGradingTexture from the following parameters.
  54292. *
  54293. * @param url The location of the color gradind data (currently only supporting 3dl)
  54294. * @param scene The scene the texture will be used in
  54295. */
  54296. constructor(url: string, scene: Scene);
  54297. /**
  54298. * Returns the texture matrix used in most of the material.
  54299. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54300. */
  54301. getTextureMatrix(): Matrix;
  54302. /**
  54303. * Occurs when the file being loaded is a .3dl LUT file.
  54304. */
  54305. private load3dlTexture;
  54306. /**
  54307. * Starts the loading process of the texture.
  54308. */
  54309. private loadTexture;
  54310. /**
  54311. * Clones the color gradind texture.
  54312. */
  54313. clone(): ColorGradingTexture;
  54314. /**
  54315. * Called during delayed load for textures.
  54316. */
  54317. delayLoad(): void;
  54318. /**
  54319. * Parses a color grading texture serialized by Babylon.
  54320. * @param parsedTexture The texture information being parsedTexture
  54321. * @param scene The scene to load the texture in
  54322. * @param rootUrl The root url of the data assets to load
  54323. * @return A color gradind texture
  54324. */
  54325. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54326. /**
  54327. * Serializes the LUT texture to json format.
  54328. */
  54329. serialize(): any;
  54330. }
  54331. }
  54332. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54333. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54334. import { Scene } from "babylonjs/scene";
  54335. import { Nullable } from "babylonjs/types";
  54336. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54337. /**
  54338. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54339. */
  54340. export class EquiRectangularCubeTexture extends BaseTexture {
  54341. /** The six faces of the cube. */
  54342. private static _FacesMapping;
  54343. private _noMipmap;
  54344. private _onLoad;
  54345. private _onError;
  54346. /** The size of the cubemap. */
  54347. private _size;
  54348. /** The buffer of the image. */
  54349. private _buffer;
  54350. /** The width of the input image. */
  54351. private _width;
  54352. /** The height of the input image. */
  54353. private _height;
  54354. /** The URL to the image. */
  54355. url: string;
  54356. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54357. coordinatesMode: number;
  54358. /**
  54359. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54360. * @param url The location of the image
  54361. * @param scene The scene the texture will be used in
  54362. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54363. * @param noMipmap Forces to not generate the mipmap if true
  54364. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54365. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54366. * @param onLoad — defines a callback called when texture is loaded
  54367. * @param onError — defines a callback called if there is an error
  54368. */
  54369. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54370. /**
  54371. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54372. */
  54373. private loadImage;
  54374. /**
  54375. * Convert the image buffer into a cubemap and create a CubeTexture.
  54376. */
  54377. private loadTexture;
  54378. /**
  54379. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54380. * @param buffer The ArrayBuffer that should be converted.
  54381. * @returns The buffer as Float32Array.
  54382. */
  54383. private getFloat32ArrayFromArrayBuffer;
  54384. /**
  54385. * Get the current class name of the texture useful for serialization or dynamic coding.
  54386. * @returns "EquiRectangularCubeTexture"
  54387. */
  54388. getClassName(): string;
  54389. /**
  54390. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54391. * @returns A clone of the current EquiRectangularCubeTexture.
  54392. */
  54393. clone(): EquiRectangularCubeTexture;
  54394. }
  54395. }
  54396. declare module "babylonjs/Misc/tga" {
  54397. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54398. /**
  54399. * Based on jsTGALoader - Javascript loader for TGA file
  54400. * By Vincent Thibault
  54401. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54402. */
  54403. export class TGATools {
  54404. private static _TYPE_INDEXED;
  54405. private static _TYPE_RGB;
  54406. private static _TYPE_GREY;
  54407. private static _TYPE_RLE_INDEXED;
  54408. private static _TYPE_RLE_RGB;
  54409. private static _TYPE_RLE_GREY;
  54410. private static _ORIGIN_MASK;
  54411. private static _ORIGIN_SHIFT;
  54412. private static _ORIGIN_BL;
  54413. private static _ORIGIN_BR;
  54414. private static _ORIGIN_UL;
  54415. private static _ORIGIN_UR;
  54416. /**
  54417. * Gets the header of a TGA file
  54418. * @param data defines the TGA data
  54419. * @returns the header
  54420. */
  54421. static GetTGAHeader(data: Uint8Array): any;
  54422. /**
  54423. * Uploads TGA content to a Babylon Texture
  54424. * @hidden
  54425. */
  54426. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54427. /** @hidden */
  54428. 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;
  54429. /** @hidden */
  54430. 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;
  54431. /** @hidden */
  54432. 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;
  54433. /** @hidden */
  54434. 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;
  54435. /** @hidden */
  54436. 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;
  54437. /** @hidden */
  54438. 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;
  54439. }
  54440. }
  54441. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54442. import { Nullable } from "babylonjs/types";
  54443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54444. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54445. /**
  54446. * Implementation of the TGA Texture Loader.
  54447. * @hidden
  54448. */
  54449. export class _TGATextureLoader implements IInternalTextureLoader {
  54450. /**
  54451. * Defines wether the loader supports cascade loading the different faces.
  54452. */
  54453. readonly supportCascades: boolean;
  54454. /**
  54455. * This returns if the loader support the current file information.
  54456. * @param extension defines the file extension of the file being loaded
  54457. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54458. * @param fallback defines the fallback internal texture if any
  54459. * @param isBase64 defines whether the texture is encoded as a base64
  54460. * @param isBuffer defines whether the texture data are stored as a buffer
  54461. * @returns true if the loader can load the specified file
  54462. */
  54463. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54464. /**
  54465. * Transform the url before loading if required.
  54466. * @param rootUrl the url of the texture
  54467. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54468. * @returns the transformed texture
  54469. */
  54470. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54471. /**
  54472. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54473. * @param rootUrl the url of the texture
  54474. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54475. * @returns the fallback texture
  54476. */
  54477. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54478. /**
  54479. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54480. * @param data contains the texture data
  54481. * @param texture defines the BabylonJS internal texture
  54482. * @param createPolynomials will be true if polynomials have been requested
  54483. * @param onLoad defines the callback to trigger once the texture is ready
  54484. * @param onError defines the callback to trigger in case of error
  54485. */
  54486. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54487. /**
  54488. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54489. * @param data contains the texture data
  54490. * @param texture defines the BabylonJS internal texture
  54491. * @param callback defines the method to call once ready to upload
  54492. */
  54493. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54494. }
  54495. }
  54496. declare module "babylonjs/Misc/basis" {
  54497. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54498. /**
  54499. * Info about the .basis files
  54500. */
  54501. class BasisFileInfo {
  54502. /**
  54503. * If the file has alpha
  54504. */
  54505. hasAlpha: boolean;
  54506. /**
  54507. * Info about each image of the basis file
  54508. */
  54509. images: Array<{
  54510. levels: Array<{
  54511. width: number;
  54512. height: number;
  54513. transcodedPixels: ArrayBufferView;
  54514. }>;
  54515. }>;
  54516. }
  54517. /**
  54518. * Result of transcoding a basis file
  54519. */
  54520. class TranscodeResult {
  54521. /**
  54522. * Info about the .basis file
  54523. */
  54524. fileInfo: BasisFileInfo;
  54525. /**
  54526. * Format to use when loading the file
  54527. */
  54528. format: number;
  54529. }
  54530. /**
  54531. * Configuration options for the Basis transcoder
  54532. */
  54533. export class BasisTranscodeConfiguration {
  54534. /**
  54535. * Supported compression formats used to determine the supported output format of the transcoder
  54536. */
  54537. supportedCompressionFormats?: {
  54538. /**
  54539. * etc1 compression format
  54540. */
  54541. etc1?: boolean;
  54542. /**
  54543. * s3tc compression format
  54544. */
  54545. s3tc?: boolean;
  54546. /**
  54547. * pvrtc compression format
  54548. */
  54549. pvrtc?: boolean;
  54550. /**
  54551. * etc2 compression format
  54552. */
  54553. etc2?: boolean;
  54554. };
  54555. /**
  54556. * If mipmap levels should be loaded for transcoded images (Default: true)
  54557. */
  54558. loadMipmapLevels?: boolean;
  54559. /**
  54560. * Index of a single image to load (Default: all images)
  54561. */
  54562. loadSingleImage?: number;
  54563. }
  54564. /**
  54565. * Used to load .Basis files
  54566. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54567. */
  54568. export class BasisTools {
  54569. private static _IgnoreSupportedFormats;
  54570. /**
  54571. * URL to use when loading the basis transcoder
  54572. */
  54573. static JSModuleURL: string;
  54574. /**
  54575. * URL to use when loading the wasm module for the transcoder
  54576. */
  54577. static WasmModuleURL: string;
  54578. /**
  54579. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54580. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54581. * @returns internal format corresponding to the Basis format
  54582. */
  54583. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54584. private static _WorkerPromise;
  54585. private static _Worker;
  54586. private static _actionId;
  54587. private static _CreateWorkerAsync;
  54588. /**
  54589. * Transcodes a loaded image file to compressed pixel data
  54590. * @param imageData image data to transcode
  54591. * @param config configuration options for the transcoding
  54592. * @returns a promise resulting in the transcoded image
  54593. */
  54594. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54595. /**
  54596. * Loads a texture from the transcode result
  54597. * @param texture texture load to
  54598. * @param transcodeResult the result of transcoding the basis file to load from
  54599. */
  54600. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54601. }
  54602. }
  54603. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54604. import { Nullable } from "babylonjs/types";
  54605. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54606. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54607. /**
  54608. * Loader for .basis file format
  54609. */
  54610. export class _BasisTextureLoader implements IInternalTextureLoader {
  54611. /**
  54612. * Defines whether the loader supports cascade loading the different faces.
  54613. */
  54614. readonly supportCascades: boolean;
  54615. /**
  54616. * This returns if the loader support the current file information.
  54617. * @param extension defines the file extension of the file being loaded
  54618. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54619. * @param fallback defines the fallback internal texture if any
  54620. * @param isBase64 defines whether the texture is encoded as a base64
  54621. * @param isBuffer defines whether the texture data are stored as a buffer
  54622. * @returns true if the loader can load the specified file
  54623. */
  54624. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54625. /**
  54626. * Transform the url before loading if required.
  54627. * @param rootUrl the url of the texture
  54628. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54629. * @returns the transformed texture
  54630. */
  54631. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54632. /**
  54633. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54634. * @param rootUrl the url of the texture
  54635. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54636. * @returns the fallback texture
  54637. */
  54638. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54639. /**
  54640. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54641. * @param data contains the texture data
  54642. * @param texture defines the BabylonJS internal texture
  54643. * @param createPolynomials will be true if polynomials have been requested
  54644. * @param onLoad defines the callback to trigger once the texture is ready
  54645. * @param onError defines the callback to trigger in case of error
  54646. */
  54647. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54648. /**
  54649. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54650. * @param data contains the texture data
  54651. * @param texture defines the BabylonJS internal texture
  54652. * @param callback defines the method to call once ready to upload
  54653. */
  54654. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54655. }
  54656. }
  54657. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54658. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54659. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54660. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54661. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54662. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54663. }
  54664. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54665. import { Scene } from "babylonjs/scene";
  54666. import { Texture } from "babylonjs/Materials/Textures/texture";
  54667. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54668. /**
  54669. * 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.
  54670. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54671. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54672. */
  54673. export class CustomProceduralTexture extends ProceduralTexture {
  54674. private _animate;
  54675. private _time;
  54676. private _config;
  54677. private _texturePath;
  54678. /**
  54679. * Instantiates a new Custom Procedural Texture.
  54680. * 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.
  54681. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54682. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54683. * @param name Define the name of the texture
  54684. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54685. * @param size Define the size of the texture to create
  54686. * @param scene Define the scene the texture belongs to
  54687. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54688. * @param generateMipMaps Define if the texture should creates mip maps or not
  54689. */
  54690. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54691. private _loadJson;
  54692. /**
  54693. * Is the texture ready to be used ? (rendered at least once)
  54694. * @returns true if ready, otherwise, false.
  54695. */
  54696. isReady(): boolean;
  54697. /**
  54698. * Render the texture to its associated render target.
  54699. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54700. */
  54701. render(useCameraPostProcess?: boolean): void;
  54702. /**
  54703. * Update the list of dependant textures samplers in the shader.
  54704. */
  54705. updateTextures(): void;
  54706. /**
  54707. * Update the uniform values of the procedural texture in the shader.
  54708. */
  54709. updateShaderUniforms(): void;
  54710. /**
  54711. * Define if the texture animates or not.
  54712. */
  54713. animate: boolean;
  54714. }
  54715. }
  54716. declare module "babylonjs/Shaders/noise.fragment" {
  54717. /** @hidden */
  54718. export var noisePixelShader: {
  54719. name: string;
  54720. shader: string;
  54721. };
  54722. }
  54723. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54724. import { Nullable } from "babylonjs/types";
  54725. import { Scene } from "babylonjs/scene";
  54726. import { Texture } from "babylonjs/Materials/Textures/texture";
  54727. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54728. import "babylonjs/Shaders/noise.fragment";
  54729. /**
  54730. * Class used to generate noise procedural textures
  54731. */
  54732. export class NoiseProceduralTexture extends ProceduralTexture {
  54733. private _time;
  54734. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54735. brightness: number;
  54736. /** Defines the number of octaves to process */
  54737. octaves: number;
  54738. /** Defines the level of persistence (0.8 by default) */
  54739. persistence: number;
  54740. /** Gets or sets animation speed factor (default is 1) */
  54741. animationSpeedFactor: number;
  54742. /**
  54743. * Creates a new NoiseProceduralTexture
  54744. * @param name defines the name fo the texture
  54745. * @param size defines the size of the texture (default is 256)
  54746. * @param scene defines the hosting scene
  54747. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54748. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54749. */
  54750. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54751. private _updateShaderUniforms;
  54752. protected _getDefines(): string;
  54753. /** Generate the current state of the procedural texture */
  54754. render(useCameraPostProcess?: boolean): void;
  54755. /**
  54756. * Serializes this noise procedural texture
  54757. * @returns a serialized noise procedural texture object
  54758. */
  54759. serialize(): any;
  54760. /**
  54761. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54762. * @param parsedTexture defines parsed texture data
  54763. * @param scene defines the current scene
  54764. * @param rootUrl defines the root URL containing noise procedural texture information
  54765. * @returns a parsed NoiseProceduralTexture
  54766. */
  54767. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54768. }
  54769. }
  54770. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54771. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54772. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54773. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54774. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54775. }
  54776. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54777. import { Nullable } from "babylonjs/types";
  54778. import { Scene } from "babylonjs/scene";
  54779. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54780. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54781. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54782. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54783. /**
  54784. * Raw cube texture where the raw buffers are passed in
  54785. */
  54786. export class RawCubeTexture extends CubeTexture {
  54787. /**
  54788. * Creates a cube texture where the raw buffers are passed in.
  54789. * @param scene defines the scene the texture is attached to
  54790. * @param data defines the array of data to use to create each face
  54791. * @param size defines the size of the textures
  54792. * @param format defines the format of the data
  54793. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54794. * @param generateMipMaps defines if the engine should generate the mip levels
  54795. * @param invertY defines if data must be stored with Y axis inverted
  54796. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54797. * @param compression defines the compression used (null by default)
  54798. */
  54799. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54800. /**
  54801. * Updates the raw cube texture.
  54802. * @param data defines the data to store
  54803. * @param format defines the data format
  54804. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54805. * @param invertY defines if data must be stored with Y axis inverted
  54806. * @param compression defines the compression used (null by default)
  54807. * @param level defines which level of the texture to update
  54808. */
  54809. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54810. /**
  54811. * Updates a raw cube texture with RGBD encoded data.
  54812. * @param data defines the array of data [mipmap][face] to use to create each face
  54813. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54814. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54815. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54816. * @returns a promsie that resolves when the operation is complete
  54817. */
  54818. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54819. /**
  54820. * Clones the raw cube texture.
  54821. * @return a new cube texture
  54822. */
  54823. clone(): CubeTexture;
  54824. /** @hidden */
  54825. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54826. }
  54827. }
  54828. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54829. import { Scene } from "babylonjs/scene";
  54830. import { Texture } from "babylonjs/Materials/Textures/texture";
  54831. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54832. /**
  54833. * Class used to store 3D textures containing user data
  54834. */
  54835. export class RawTexture3D extends Texture {
  54836. /** Gets or sets the texture format to use */
  54837. format: number;
  54838. private _engine;
  54839. /**
  54840. * Create a new RawTexture3D
  54841. * @param data defines the data of the texture
  54842. * @param width defines the width of the texture
  54843. * @param height defines the height of the texture
  54844. * @param depth defines the depth of the texture
  54845. * @param format defines the texture format to use
  54846. * @param scene defines the hosting scene
  54847. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54848. * @param invertY defines if texture must be stored with Y axis inverted
  54849. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54850. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54851. */
  54852. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54853. /** Gets or sets the texture format to use */
  54854. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54855. /**
  54856. * Update the texture with new data
  54857. * @param data defines the data to store in the texture
  54858. */
  54859. update(data: ArrayBufferView): void;
  54860. }
  54861. }
  54862. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54863. import { Scene } from "babylonjs/scene";
  54864. import { Plane } from "babylonjs/Maths/math.plane";
  54865. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54866. /**
  54867. * Creates a refraction texture used by refraction channel of the standard material.
  54868. * It is like a mirror but to see through a material.
  54869. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54870. */
  54871. export class RefractionTexture extends RenderTargetTexture {
  54872. /**
  54873. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54874. * 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.
  54875. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54876. */
  54877. refractionPlane: Plane;
  54878. /**
  54879. * Define how deep under the surface we should see.
  54880. */
  54881. depth: number;
  54882. /**
  54883. * Creates a refraction texture used by refraction channel of the standard material.
  54884. * It is like a mirror but to see through a material.
  54885. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54886. * @param name Define the texture name
  54887. * @param size Define the size of the underlying texture
  54888. * @param scene Define the scene the refraction belongs to
  54889. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54890. */
  54891. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54892. /**
  54893. * Clone the refraction texture.
  54894. * @returns the cloned texture
  54895. */
  54896. clone(): RefractionTexture;
  54897. /**
  54898. * Serialize the texture to a JSON representation you could use in Parse later on
  54899. * @returns the serialized JSON representation
  54900. */
  54901. serialize(): any;
  54902. }
  54903. }
  54904. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54905. import { Nullable } from "babylonjs/types";
  54906. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54907. import { Matrix } from "babylonjs/Maths/math.vector";
  54908. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54909. import "babylonjs/Engines/Extensions/engine.videoTexture";
  54910. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54911. import { Scene } from "babylonjs/scene";
  54912. /**
  54913. * Defines the options related to the creation of an HtmlElementTexture
  54914. */
  54915. export interface IHtmlElementTextureOptions {
  54916. /**
  54917. * Defines wether mip maps should be created or not.
  54918. */
  54919. generateMipMaps?: boolean;
  54920. /**
  54921. * Defines the sampling mode of the texture.
  54922. */
  54923. samplingMode?: number;
  54924. /**
  54925. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54926. */
  54927. engine: Nullable<ThinEngine>;
  54928. /**
  54929. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54930. */
  54931. scene: Nullable<Scene>;
  54932. }
  54933. /**
  54934. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54935. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54936. * is automatically managed.
  54937. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54938. * in your application.
  54939. *
  54940. * As the update is not automatic, you need to call them manually.
  54941. */
  54942. export class HtmlElementTexture extends BaseTexture {
  54943. /**
  54944. * The texture URL.
  54945. */
  54946. element: HTMLVideoElement | HTMLCanvasElement;
  54947. private static readonly DefaultOptions;
  54948. private _textureMatrix;
  54949. private _engine;
  54950. private _isVideo;
  54951. private _generateMipMaps;
  54952. private _samplingMode;
  54953. /**
  54954. * Instantiates a HtmlElementTexture from the following parameters.
  54955. *
  54956. * @param name Defines the name of the texture
  54957. * @param element Defines the video or canvas the texture is filled with
  54958. * @param options Defines the other none mandatory texture creation options
  54959. */
  54960. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54961. private _createInternalTexture;
  54962. /**
  54963. * Returns the texture matrix used in most of the material.
  54964. */
  54965. getTextureMatrix(): Matrix;
  54966. /**
  54967. * Updates the content of the texture.
  54968. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54969. */
  54970. update(invertY?: Nullable<boolean>): void;
  54971. }
  54972. }
  54973. declare module "babylonjs/Materials/Textures/index" {
  54974. export * from "babylonjs/Materials/Textures/baseTexture";
  54975. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  54976. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54977. export * from "babylonjs/Materials/Textures/cubeTexture";
  54978. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54979. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54980. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54981. export * from "babylonjs/Materials/Textures/internalTexture";
  54982. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54983. export * from "babylonjs/Materials/Textures/Loaders/index";
  54984. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54985. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54986. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54987. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54988. export * from "babylonjs/Materials/Textures/rawTexture";
  54989. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54990. export * from "babylonjs/Materials/Textures/refractionTexture";
  54991. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54992. export * from "babylonjs/Materials/Textures/texture";
  54993. export * from "babylonjs/Materials/Textures/videoTexture";
  54994. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54995. }
  54996. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54997. /**
  54998. * Enum used to define the target of a block
  54999. */
  55000. export enum NodeMaterialBlockTargets {
  55001. /** Vertex shader */
  55002. Vertex = 1,
  55003. /** Fragment shader */
  55004. Fragment = 2,
  55005. /** Neutral */
  55006. Neutral = 4,
  55007. /** Vertex and Fragment */
  55008. VertexAndFragment = 3
  55009. }
  55010. }
  55011. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55012. /**
  55013. * Defines the kind of connection point for node based material
  55014. */
  55015. export enum NodeMaterialBlockConnectionPointTypes {
  55016. /** Float */
  55017. Float = 1,
  55018. /** Int */
  55019. Int = 2,
  55020. /** Vector2 */
  55021. Vector2 = 4,
  55022. /** Vector3 */
  55023. Vector3 = 8,
  55024. /** Vector4 */
  55025. Vector4 = 16,
  55026. /** Color3 */
  55027. Color3 = 32,
  55028. /** Color4 */
  55029. Color4 = 64,
  55030. /** Matrix */
  55031. Matrix = 128,
  55032. /** Detect type based on connection */
  55033. AutoDetect = 1024,
  55034. /** Output type that will be defined by input type */
  55035. BasedOnInput = 2048
  55036. }
  55037. }
  55038. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55039. /**
  55040. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55041. */
  55042. export enum NodeMaterialBlockConnectionPointMode {
  55043. /** Value is an uniform */
  55044. Uniform = 0,
  55045. /** Value is a mesh attribute */
  55046. Attribute = 1,
  55047. /** Value is a varying between vertex and fragment shaders */
  55048. Varying = 2,
  55049. /** Mode is undefined */
  55050. Undefined = 3
  55051. }
  55052. }
  55053. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55054. /**
  55055. * Enum used to define system values e.g. values automatically provided by the system
  55056. */
  55057. export enum NodeMaterialSystemValues {
  55058. /** World */
  55059. World = 1,
  55060. /** View */
  55061. View = 2,
  55062. /** Projection */
  55063. Projection = 3,
  55064. /** ViewProjection */
  55065. ViewProjection = 4,
  55066. /** WorldView */
  55067. WorldView = 5,
  55068. /** WorldViewProjection */
  55069. WorldViewProjection = 6,
  55070. /** CameraPosition */
  55071. CameraPosition = 7,
  55072. /** Fog Color */
  55073. FogColor = 8,
  55074. /** Delta time */
  55075. DeltaTime = 9
  55076. }
  55077. }
  55078. declare module "babylonjs/Materials/Node/Enums/index" {
  55079. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55080. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55081. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55082. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55083. }
  55084. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55085. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55086. /**
  55087. * Root class for all node material optimizers
  55088. */
  55089. export class NodeMaterialOptimizer {
  55090. /**
  55091. * Function used to optimize a NodeMaterial graph
  55092. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55093. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55094. */
  55095. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55096. }
  55097. }
  55098. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55102. import { Scene } from "babylonjs/scene";
  55103. /**
  55104. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55105. */
  55106. export class TransformBlock extends NodeMaterialBlock {
  55107. /**
  55108. * Defines the value to use to complement W value to transform it to a Vector4
  55109. */
  55110. complementW: number;
  55111. /**
  55112. * Defines the value to use to complement z value to transform it to a Vector4
  55113. */
  55114. complementZ: number;
  55115. /**
  55116. * Creates a new TransformBlock
  55117. * @param name defines the block name
  55118. */
  55119. constructor(name: string);
  55120. /**
  55121. * Gets the current class name
  55122. * @returns the class name
  55123. */
  55124. getClassName(): string;
  55125. /**
  55126. * Gets the vector input
  55127. */
  55128. readonly vector: NodeMaterialConnectionPoint;
  55129. /**
  55130. * Gets the output component
  55131. */
  55132. readonly output: NodeMaterialConnectionPoint;
  55133. /**
  55134. * Gets the matrix transform input
  55135. */
  55136. readonly transform: NodeMaterialConnectionPoint;
  55137. protected _buildBlock(state: NodeMaterialBuildState): this;
  55138. serialize(): any;
  55139. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55140. protected _dumpPropertiesCode(): string;
  55141. }
  55142. }
  55143. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55147. /**
  55148. * Block used to output the vertex position
  55149. */
  55150. export class VertexOutputBlock extends NodeMaterialBlock {
  55151. /**
  55152. * Creates a new VertexOutputBlock
  55153. * @param name defines the block name
  55154. */
  55155. constructor(name: string);
  55156. /**
  55157. * Gets the current class name
  55158. * @returns the class name
  55159. */
  55160. getClassName(): string;
  55161. /**
  55162. * Gets the vector input component
  55163. */
  55164. readonly vector: NodeMaterialConnectionPoint;
  55165. protected _buildBlock(state: NodeMaterialBuildState): this;
  55166. }
  55167. }
  55168. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55169. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55170. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55171. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55172. /**
  55173. * Block used to output the final color
  55174. */
  55175. export class FragmentOutputBlock extends NodeMaterialBlock {
  55176. /**
  55177. * Create a new FragmentOutputBlock
  55178. * @param name defines the block name
  55179. */
  55180. constructor(name: string);
  55181. /**
  55182. * Gets the current class name
  55183. * @returns the class name
  55184. */
  55185. getClassName(): string;
  55186. /**
  55187. * Gets the rgba input component
  55188. */
  55189. readonly rgba: NodeMaterialConnectionPoint;
  55190. /**
  55191. * Gets the rgb input component
  55192. */
  55193. readonly rgb: NodeMaterialConnectionPoint;
  55194. /**
  55195. * Gets the a input component
  55196. */
  55197. readonly a: NodeMaterialConnectionPoint;
  55198. protected _buildBlock(state: NodeMaterialBuildState): this;
  55199. }
  55200. }
  55201. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55202. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55203. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55204. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55205. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55207. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55208. import { Effect } from "babylonjs/Materials/effect";
  55209. import { Mesh } from "babylonjs/Meshes/mesh";
  55210. import { Nullable } from "babylonjs/types";
  55211. import { Scene } from "babylonjs/scene";
  55212. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55213. /**
  55214. * Block used to read a reflection texture from a sampler
  55215. */
  55216. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55217. private _define3DName;
  55218. private _defineCubicName;
  55219. private _defineExplicitName;
  55220. private _defineProjectionName;
  55221. private _defineLocalCubicName;
  55222. private _defineSphericalName;
  55223. private _definePlanarName;
  55224. private _defineEquirectangularName;
  55225. private _defineMirroredEquirectangularFixedName;
  55226. private _defineEquirectangularFixedName;
  55227. private _defineSkyboxName;
  55228. private _cubeSamplerName;
  55229. private _2DSamplerName;
  55230. private _positionUVWName;
  55231. private _directionWName;
  55232. private _reflectionCoordsName;
  55233. private _reflection2DCoordsName;
  55234. private _reflectionColorName;
  55235. private _reflectionMatrixName;
  55236. /**
  55237. * Gets or sets the texture associated with the node
  55238. */
  55239. texture: Nullable<BaseTexture>;
  55240. /**
  55241. * Create a new TextureBlock
  55242. * @param name defines the block name
  55243. */
  55244. constructor(name: string);
  55245. /**
  55246. * Gets the current class name
  55247. * @returns the class name
  55248. */
  55249. getClassName(): string;
  55250. /**
  55251. * Gets the world position input component
  55252. */
  55253. readonly position: NodeMaterialConnectionPoint;
  55254. /**
  55255. * Gets the world position input component
  55256. */
  55257. readonly worldPosition: NodeMaterialConnectionPoint;
  55258. /**
  55259. * Gets the world normal input component
  55260. */
  55261. readonly worldNormal: NodeMaterialConnectionPoint;
  55262. /**
  55263. * Gets the world input component
  55264. */
  55265. readonly world: NodeMaterialConnectionPoint;
  55266. /**
  55267. * Gets the camera (or eye) position component
  55268. */
  55269. readonly cameraPosition: NodeMaterialConnectionPoint;
  55270. /**
  55271. * Gets the view input component
  55272. */
  55273. readonly view: NodeMaterialConnectionPoint;
  55274. /**
  55275. * Gets the rgb output component
  55276. */
  55277. readonly rgb: NodeMaterialConnectionPoint;
  55278. /**
  55279. * Gets the r output component
  55280. */
  55281. readonly r: NodeMaterialConnectionPoint;
  55282. /**
  55283. * Gets the g output component
  55284. */
  55285. readonly g: NodeMaterialConnectionPoint;
  55286. /**
  55287. * Gets the b output component
  55288. */
  55289. readonly b: NodeMaterialConnectionPoint;
  55290. autoConfigure(material: NodeMaterial): void;
  55291. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55292. isReady(): boolean;
  55293. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55294. private _injectVertexCode;
  55295. private _writeOutput;
  55296. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55297. serialize(): any;
  55298. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55299. }
  55300. }
  55301. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55302. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55303. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55304. import { Scene } from "babylonjs/scene";
  55305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55306. import { Matrix } from "babylonjs/Maths/math.vector";
  55307. import { Mesh } from "babylonjs/Meshes/mesh";
  55308. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55309. import { Observable } from "babylonjs/Misc/observable";
  55310. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55311. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55312. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55313. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55314. import { Nullable } from "babylonjs/types";
  55315. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55316. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55317. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55318. /**
  55319. * Interface used to configure the node material editor
  55320. */
  55321. export interface INodeMaterialEditorOptions {
  55322. /** Define the URl to load node editor script */
  55323. editorURL?: string;
  55324. }
  55325. /** @hidden */
  55326. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55327. /** BONES */
  55328. NUM_BONE_INFLUENCERS: number;
  55329. BonesPerMesh: number;
  55330. BONETEXTURE: boolean;
  55331. /** MORPH TARGETS */
  55332. MORPHTARGETS: boolean;
  55333. MORPHTARGETS_NORMAL: boolean;
  55334. MORPHTARGETS_TANGENT: boolean;
  55335. MORPHTARGETS_UV: boolean;
  55336. NUM_MORPH_INFLUENCERS: number;
  55337. /** IMAGE PROCESSING */
  55338. IMAGEPROCESSING: boolean;
  55339. VIGNETTE: boolean;
  55340. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55341. VIGNETTEBLENDMODEOPAQUE: boolean;
  55342. TONEMAPPING: boolean;
  55343. TONEMAPPING_ACES: boolean;
  55344. CONTRAST: boolean;
  55345. EXPOSURE: boolean;
  55346. COLORCURVES: boolean;
  55347. COLORGRADING: boolean;
  55348. COLORGRADING3D: boolean;
  55349. SAMPLER3DGREENDEPTH: boolean;
  55350. SAMPLER3DBGRMAP: boolean;
  55351. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55352. /** MISC. */
  55353. BUMPDIRECTUV: number;
  55354. constructor();
  55355. setValue(name: string, value: boolean): void;
  55356. }
  55357. /**
  55358. * Class used to configure NodeMaterial
  55359. */
  55360. export interface INodeMaterialOptions {
  55361. /**
  55362. * Defines if blocks should emit comments
  55363. */
  55364. emitComments: boolean;
  55365. }
  55366. /**
  55367. * Class used to create a node based material built by assembling shader blocks
  55368. */
  55369. export class NodeMaterial extends PushMaterial {
  55370. private static _BuildIdGenerator;
  55371. private _options;
  55372. private _vertexCompilationState;
  55373. private _fragmentCompilationState;
  55374. private _sharedData;
  55375. private _buildId;
  55376. private _buildWasSuccessful;
  55377. private _cachedWorldViewMatrix;
  55378. private _cachedWorldViewProjectionMatrix;
  55379. private _optimizers;
  55380. private _animationFrame;
  55381. /** Define the URl to load node editor script */
  55382. static EditorURL: string;
  55383. private BJSNODEMATERIALEDITOR;
  55384. /** Get the inspector from bundle or global */
  55385. private _getGlobalNodeMaterialEditor;
  55386. /**
  55387. * 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)
  55388. */
  55389. ignoreAlpha: boolean;
  55390. /**
  55391. * Defines the maximum number of lights that can be used in the material
  55392. */
  55393. maxSimultaneousLights: number;
  55394. /**
  55395. * Observable raised when the material is built
  55396. */
  55397. onBuildObservable: Observable<NodeMaterial>;
  55398. /**
  55399. * Gets or sets the root nodes of the material vertex shader
  55400. */
  55401. _vertexOutputNodes: NodeMaterialBlock[];
  55402. /**
  55403. * Gets or sets the root nodes of the material fragment (pixel) shader
  55404. */
  55405. _fragmentOutputNodes: NodeMaterialBlock[];
  55406. /** Gets or sets options to control the node material overall behavior */
  55407. options: INodeMaterialOptions;
  55408. /**
  55409. * Default configuration related to image processing available in the standard Material.
  55410. */
  55411. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55412. /**
  55413. * Gets the image processing configuration used either in this material.
  55414. */
  55415. /**
  55416. * Sets the Default image processing configuration used either in the this material.
  55417. *
  55418. * If sets to null, the scene one is in use.
  55419. */
  55420. imageProcessingConfiguration: ImageProcessingConfiguration;
  55421. /**
  55422. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55423. */
  55424. attachedBlocks: NodeMaterialBlock[];
  55425. /**
  55426. * Create a new node based material
  55427. * @param name defines the material name
  55428. * @param scene defines the hosting scene
  55429. * @param options defines creation option
  55430. */
  55431. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55432. /**
  55433. * Gets the current class name of the material e.g. "NodeMaterial"
  55434. * @returns the class name
  55435. */
  55436. getClassName(): string;
  55437. /**
  55438. * Keep track of the image processing observer to allow dispose and replace.
  55439. */
  55440. private _imageProcessingObserver;
  55441. /**
  55442. * Attaches a new image processing configuration to the Standard Material.
  55443. * @param configuration
  55444. */
  55445. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55446. /**
  55447. * Get a block by its name
  55448. * @param name defines the name of the block to retrieve
  55449. * @returns the required block or null if not found
  55450. */
  55451. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55452. /**
  55453. * Get a block by its name
  55454. * @param predicate defines the predicate used to find the good candidate
  55455. * @returns the required block or null if not found
  55456. */
  55457. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55458. /**
  55459. * Get an input block by its name
  55460. * @param predicate defines the predicate used to find the good candidate
  55461. * @returns the required input block or null if not found
  55462. */
  55463. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55464. /**
  55465. * Gets the list of input blocks attached to this material
  55466. * @returns an array of InputBlocks
  55467. */
  55468. getInputBlocks(): InputBlock[];
  55469. /**
  55470. * Adds a new optimizer to the list of optimizers
  55471. * @param optimizer defines the optimizers to add
  55472. * @returns the current material
  55473. */
  55474. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55475. /**
  55476. * Remove an optimizer from the list of optimizers
  55477. * @param optimizer defines the optimizers to remove
  55478. * @returns the current material
  55479. */
  55480. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55481. /**
  55482. * Add a new block to the list of output nodes
  55483. * @param node defines the node to add
  55484. * @returns the current material
  55485. */
  55486. addOutputNode(node: NodeMaterialBlock): this;
  55487. /**
  55488. * Remove a block from the list of root nodes
  55489. * @param node defines the node to remove
  55490. * @returns the current material
  55491. */
  55492. removeOutputNode(node: NodeMaterialBlock): this;
  55493. private _addVertexOutputNode;
  55494. private _removeVertexOutputNode;
  55495. private _addFragmentOutputNode;
  55496. private _removeFragmentOutputNode;
  55497. /**
  55498. * Specifies if the material will require alpha blending
  55499. * @returns a boolean specifying if alpha blending is needed
  55500. */
  55501. needAlphaBlending(): boolean;
  55502. /**
  55503. * Specifies if this material should be rendered in alpha test mode
  55504. * @returns a boolean specifying if an alpha test is needed.
  55505. */
  55506. needAlphaTesting(): boolean;
  55507. private _initializeBlock;
  55508. private _resetDualBlocks;
  55509. /**
  55510. * Build the material and generates the inner effect
  55511. * @param verbose defines if the build should log activity
  55512. */
  55513. build(verbose?: boolean): void;
  55514. /**
  55515. * Runs an otpimization phase to try to improve the shader code
  55516. */
  55517. optimize(): void;
  55518. private _prepareDefinesForAttributes;
  55519. /**
  55520. * Get if the submesh is ready to be used and all its information available.
  55521. * Child classes can use it to update shaders
  55522. * @param mesh defines the mesh to check
  55523. * @param subMesh defines which submesh to check
  55524. * @param useInstances specifies that instances should be used
  55525. * @returns a boolean indicating that the submesh is ready or not
  55526. */
  55527. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55528. /**
  55529. * Get a string representing the shaders built by the current node graph
  55530. */
  55531. readonly compiledShaders: string;
  55532. /**
  55533. * Binds the world matrix to the material
  55534. * @param world defines the world transformation matrix
  55535. */
  55536. bindOnlyWorldMatrix(world: Matrix): void;
  55537. /**
  55538. * Binds the submesh to this material by preparing the effect and shader to draw
  55539. * @param world defines the world transformation matrix
  55540. * @param mesh defines the mesh containing the submesh
  55541. * @param subMesh defines the submesh to bind the material to
  55542. */
  55543. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55544. /**
  55545. * Gets the active textures from the material
  55546. * @returns an array of textures
  55547. */
  55548. getActiveTextures(): BaseTexture[];
  55549. /**
  55550. * Gets the list of texture blocks
  55551. * @returns an array of texture blocks
  55552. */
  55553. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55554. /**
  55555. * Specifies if the material uses a texture
  55556. * @param texture defines the texture to check against the material
  55557. * @returns a boolean specifying if the material uses the texture
  55558. */
  55559. hasTexture(texture: BaseTexture): boolean;
  55560. /**
  55561. * Disposes the material
  55562. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55563. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55564. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55565. */
  55566. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55567. /** Creates the node editor window. */
  55568. private _createNodeEditor;
  55569. /**
  55570. * Launch the node material editor
  55571. * @param config Define the configuration of the editor
  55572. * @return a promise fulfilled when the node editor is visible
  55573. */
  55574. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55575. /**
  55576. * Clear the current material
  55577. */
  55578. clear(): void;
  55579. /**
  55580. * Clear the current material and set it to a default state
  55581. */
  55582. setToDefault(): void;
  55583. /**
  55584. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55585. * @param url defines the url to load from
  55586. * @returns a promise that will fullfil when the material is fully loaded
  55587. */
  55588. loadAsync(url: string): Promise<unknown>;
  55589. private _gatherBlocks;
  55590. /**
  55591. * Generate a string containing the code declaration required to create an equivalent of this material
  55592. * @returns a string
  55593. */
  55594. generateCode(): string;
  55595. /**
  55596. * Serializes this material in a JSON representation
  55597. * @returns the serialized material object
  55598. */
  55599. serialize(): any;
  55600. private _restoreConnections;
  55601. /**
  55602. * Clear the current graph and load a new one from a serialization object
  55603. * @param source defines the JSON representation of the material
  55604. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55605. */
  55606. loadFromSerialization(source: any, rootUrl?: string): void;
  55607. /**
  55608. * Creates a node material from parsed material data
  55609. * @param source defines the JSON representation of the material
  55610. * @param scene defines the hosting scene
  55611. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55612. * @returns a new node material
  55613. */
  55614. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55615. /**
  55616. * Creates a new node material set to default basic configuration
  55617. * @param name defines the name of the material
  55618. * @param scene defines the hosting scene
  55619. * @returns a new NodeMaterial
  55620. */
  55621. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55622. }
  55623. }
  55624. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55625. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55626. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55627. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55628. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55630. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55631. import { Effect } from "babylonjs/Materials/effect";
  55632. import { Mesh } from "babylonjs/Meshes/mesh";
  55633. import { Nullable } from "babylonjs/types";
  55634. import { Texture } from "babylonjs/Materials/Textures/texture";
  55635. import { Scene } from "babylonjs/scene";
  55636. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55637. /**
  55638. * Block used to read a texture from a sampler
  55639. */
  55640. export class TextureBlock extends NodeMaterialBlock {
  55641. private _defineName;
  55642. private _linearDefineName;
  55643. private _samplerName;
  55644. private _transformedUVName;
  55645. private _textureTransformName;
  55646. private _textureInfoName;
  55647. private _mainUVName;
  55648. private _mainUVDefineName;
  55649. /**
  55650. * Gets or sets the texture associated with the node
  55651. */
  55652. texture: Nullable<Texture>;
  55653. /**
  55654. * Create a new TextureBlock
  55655. * @param name defines the block name
  55656. */
  55657. constructor(name: string);
  55658. /**
  55659. * Gets the current class name
  55660. * @returns the class name
  55661. */
  55662. getClassName(): string;
  55663. /**
  55664. * Gets the uv input component
  55665. */
  55666. readonly uv: NodeMaterialConnectionPoint;
  55667. /**
  55668. * Gets the rgba output component
  55669. */
  55670. readonly rgba: NodeMaterialConnectionPoint;
  55671. /**
  55672. * Gets the rgb output component
  55673. */
  55674. readonly rgb: NodeMaterialConnectionPoint;
  55675. /**
  55676. * Gets the r output component
  55677. */
  55678. readonly r: NodeMaterialConnectionPoint;
  55679. /**
  55680. * Gets the g output component
  55681. */
  55682. readonly g: NodeMaterialConnectionPoint;
  55683. /**
  55684. * Gets the b output component
  55685. */
  55686. readonly b: NodeMaterialConnectionPoint;
  55687. /**
  55688. * Gets the a output component
  55689. */
  55690. readonly a: NodeMaterialConnectionPoint;
  55691. readonly target: NodeMaterialBlockTargets;
  55692. autoConfigure(material: NodeMaterial): void;
  55693. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55694. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55695. isReady(): boolean;
  55696. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55697. private readonly _isMixed;
  55698. private _injectVertexCode;
  55699. private _writeOutput;
  55700. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55701. protected _dumpPropertiesCode(): string;
  55702. serialize(): any;
  55703. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55704. }
  55705. }
  55706. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55708. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55709. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55710. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55711. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55712. import { Scene } from "babylonjs/scene";
  55713. /**
  55714. * Class used to store shared data between 2 NodeMaterialBuildState
  55715. */
  55716. export class NodeMaterialBuildStateSharedData {
  55717. /**
  55718. * Gets the list of emitted varyings
  55719. */
  55720. temps: string[];
  55721. /**
  55722. * Gets the list of emitted varyings
  55723. */
  55724. varyings: string[];
  55725. /**
  55726. * Gets the varying declaration string
  55727. */
  55728. varyingDeclaration: string;
  55729. /**
  55730. * Input blocks
  55731. */
  55732. inputBlocks: InputBlock[];
  55733. /**
  55734. * Input blocks
  55735. */
  55736. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55737. /**
  55738. * Bindable blocks (Blocks that need to set data to the effect)
  55739. */
  55740. bindableBlocks: NodeMaterialBlock[];
  55741. /**
  55742. * List of blocks that can provide a compilation fallback
  55743. */
  55744. blocksWithFallbacks: NodeMaterialBlock[];
  55745. /**
  55746. * List of blocks that can provide a define update
  55747. */
  55748. blocksWithDefines: NodeMaterialBlock[];
  55749. /**
  55750. * List of blocks that can provide a repeatable content
  55751. */
  55752. repeatableContentBlocks: NodeMaterialBlock[];
  55753. /**
  55754. * List of blocks that can provide a dynamic list of uniforms
  55755. */
  55756. dynamicUniformBlocks: NodeMaterialBlock[];
  55757. /**
  55758. * List of blocks that can block the isReady function for the material
  55759. */
  55760. blockingBlocks: NodeMaterialBlock[];
  55761. /**
  55762. * Gets the list of animated inputs
  55763. */
  55764. animatedInputs: InputBlock[];
  55765. /**
  55766. * Build Id used to avoid multiple recompilations
  55767. */
  55768. buildId: number;
  55769. /** List of emitted variables */
  55770. variableNames: {
  55771. [key: string]: number;
  55772. };
  55773. /** List of emitted defines */
  55774. defineNames: {
  55775. [key: string]: number;
  55776. };
  55777. /** Should emit comments? */
  55778. emitComments: boolean;
  55779. /** Emit build activity */
  55780. verbose: boolean;
  55781. /** Gets or sets the hosting scene */
  55782. scene: Scene;
  55783. /**
  55784. * Gets the compilation hints emitted at compilation time
  55785. */
  55786. hints: {
  55787. needWorldViewMatrix: boolean;
  55788. needWorldViewProjectionMatrix: boolean;
  55789. needAlphaBlending: boolean;
  55790. needAlphaTesting: boolean;
  55791. };
  55792. /**
  55793. * List of compilation checks
  55794. */
  55795. checks: {
  55796. emitVertex: boolean;
  55797. emitFragment: boolean;
  55798. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55799. };
  55800. /** Creates a new shared data */
  55801. constructor();
  55802. /**
  55803. * Emits console errors and exceptions if there is a failing check
  55804. */
  55805. emitErrors(): void;
  55806. }
  55807. }
  55808. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55809. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55810. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55811. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55812. /**
  55813. * Class used to store node based material build state
  55814. */
  55815. export class NodeMaterialBuildState {
  55816. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55817. supportUniformBuffers: boolean;
  55818. /**
  55819. * Gets the list of emitted attributes
  55820. */
  55821. attributes: string[];
  55822. /**
  55823. * Gets the list of emitted uniforms
  55824. */
  55825. uniforms: string[];
  55826. /**
  55827. * Gets the list of emitted constants
  55828. */
  55829. constants: string[];
  55830. /**
  55831. * Gets the list of emitted uniform buffers
  55832. */
  55833. uniformBuffers: string[];
  55834. /**
  55835. * Gets the list of emitted samplers
  55836. */
  55837. samplers: string[];
  55838. /**
  55839. * Gets the list of emitted functions
  55840. */
  55841. functions: {
  55842. [key: string]: string;
  55843. };
  55844. /**
  55845. * Gets the list of emitted extensions
  55846. */
  55847. extensions: {
  55848. [key: string]: string;
  55849. };
  55850. /**
  55851. * Gets the target of the compilation state
  55852. */
  55853. target: NodeMaterialBlockTargets;
  55854. /**
  55855. * Gets the list of emitted counters
  55856. */
  55857. counters: {
  55858. [key: string]: number;
  55859. };
  55860. /**
  55861. * Shared data between multiple NodeMaterialBuildState instances
  55862. */
  55863. sharedData: NodeMaterialBuildStateSharedData;
  55864. /** @hidden */
  55865. _vertexState: NodeMaterialBuildState;
  55866. /** @hidden */
  55867. _attributeDeclaration: string;
  55868. /** @hidden */
  55869. _uniformDeclaration: string;
  55870. /** @hidden */
  55871. _constantDeclaration: string;
  55872. /** @hidden */
  55873. _samplerDeclaration: string;
  55874. /** @hidden */
  55875. _varyingTransfer: string;
  55876. private _repeatableContentAnchorIndex;
  55877. /** @hidden */
  55878. _builtCompilationString: string;
  55879. /**
  55880. * Gets the emitted compilation strings
  55881. */
  55882. compilationString: string;
  55883. /**
  55884. * Finalize the compilation strings
  55885. * @param state defines the current compilation state
  55886. */
  55887. finalize(state: NodeMaterialBuildState): void;
  55888. /** @hidden */
  55889. readonly _repeatableContentAnchor: string;
  55890. /** @hidden */
  55891. _getFreeVariableName(prefix: string): string;
  55892. /** @hidden */
  55893. _getFreeDefineName(prefix: string): string;
  55894. /** @hidden */
  55895. _excludeVariableName(name: string): void;
  55896. /** @hidden */
  55897. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55898. /** @hidden */
  55899. _emitExtension(name: string, extension: string): void;
  55900. /** @hidden */
  55901. _emitFunction(name: string, code: string, comments: string): void;
  55902. /** @hidden */
  55903. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55904. replaceStrings?: {
  55905. search: RegExp;
  55906. replace: string;
  55907. }[];
  55908. repeatKey?: string;
  55909. }): string;
  55910. /** @hidden */
  55911. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55912. repeatKey?: string;
  55913. removeAttributes?: boolean;
  55914. removeUniforms?: boolean;
  55915. removeVaryings?: boolean;
  55916. removeIfDef?: boolean;
  55917. replaceStrings?: {
  55918. search: RegExp;
  55919. replace: string;
  55920. }[];
  55921. }, storeKey?: string): void;
  55922. /** @hidden */
  55923. _registerTempVariable(name: string): boolean;
  55924. /** @hidden */
  55925. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55926. /** @hidden */
  55927. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55928. /** @hidden */
  55929. _emitFloat(value: number): string;
  55930. }
  55931. }
  55932. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55933. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55934. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55935. import { Nullable } from "babylonjs/types";
  55936. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55937. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55938. import { Effect } from "babylonjs/Materials/effect";
  55939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55940. import { Mesh } from "babylonjs/Meshes/mesh";
  55941. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55942. import { Scene } from "babylonjs/scene";
  55943. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55944. /**
  55945. * Defines a block that can be used inside a node based material
  55946. */
  55947. export class NodeMaterialBlock {
  55948. private _buildId;
  55949. private _buildTarget;
  55950. private _target;
  55951. private _isFinalMerger;
  55952. private _isInput;
  55953. /** @hidden */
  55954. _codeVariableName: string;
  55955. /** @hidden */
  55956. _inputs: NodeMaterialConnectionPoint[];
  55957. /** @hidden */
  55958. _outputs: NodeMaterialConnectionPoint[];
  55959. /** @hidden */
  55960. _preparationId: number;
  55961. /**
  55962. * Gets or sets the name of the block
  55963. */
  55964. name: string;
  55965. /**
  55966. * Gets or sets the unique id of the node
  55967. */
  55968. uniqueId: number;
  55969. /**
  55970. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55971. */
  55972. readonly isFinalMerger: boolean;
  55973. /**
  55974. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55975. */
  55976. readonly isInput: boolean;
  55977. /**
  55978. * Gets or sets the build Id
  55979. */
  55980. buildId: number;
  55981. /**
  55982. * Gets or sets the target of the block
  55983. */
  55984. target: NodeMaterialBlockTargets;
  55985. /**
  55986. * Gets the list of input points
  55987. */
  55988. readonly inputs: NodeMaterialConnectionPoint[];
  55989. /** Gets the list of output points */
  55990. readonly outputs: NodeMaterialConnectionPoint[];
  55991. /**
  55992. * Find an input by its name
  55993. * @param name defines the name of the input to look for
  55994. * @returns the input or null if not found
  55995. */
  55996. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55997. /**
  55998. * Find an output by its name
  55999. * @param name defines the name of the outputto look for
  56000. * @returns the output or null if not found
  56001. */
  56002. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56003. /**
  56004. * Creates a new NodeMaterialBlock
  56005. * @param name defines the block name
  56006. * @param target defines the target of that block (Vertex by default)
  56007. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56008. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56009. */
  56010. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56011. /**
  56012. * Initialize the block and prepare the context for build
  56013. * @param state defines the state that will be used for the build
  56014. */
  56015. initialize(state: NodeMaterialBuildState): void;
  56016. /**
  56017. * Bind data to effect. Will only be called for blocks with isBindable === true
  56018. * @param effect defines the effect to bind data to
  56019. * @param nodeMaterial defines the hosting NodeMaterial
  56020. * @param mesh defines the mesh that will be rendered
  56021. */
  56022. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56023. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56024. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56025. protected _writeFloat(value: number): string;
  56026. /**
  56027. * Gets the current class name e.g. "NodeMaterialBlock"
  56028. * @returns the class name
  56029. */
  56030. getClassName(): string;
  56031. /**
  56032. * Register a new input. Must be called inside a block constructor
  56033. * @param name defines the connection point name
  56034. * @param type defines the connection point type
  56035. * @param isOptional defines a boolean indicating that this input can be omitted
  56036. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56037. * @returns the current block
  56038. */
  56039. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56040. /**
  56041. * Register a new output. Must be called inside a block constructor
  56042. * @param name defines the connection point name
  56043. * @param type defines the connection point type
  56044. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56045. * @returns the current block
  56046. */
  56047. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56048. /**
  56049. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56050. * @param forOutput defines an optional connection point to check compatibility with
  56051. * @returns the first available input or null
  56052. */
  56053. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56054. /**
  56055. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56056. * @param forBlock defines an optional block to check compatibility with
  56057. * @returns the first available input or null
  56058. */
  56059. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56060. /**
  56061. * Gets the sibling of the given output
  56062. * @param current defines the current output
  56063. * @returns the next output in the list or null
  56064. */
  56065. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56066. /**
  56067. * Connect current block with another block
  56068. * @param other defines the block to connect with
  56069. * @param options define the various options to help pick the right connections
  56070. * @returns the current block
  56071. */
  56072. connectTo(other: NodeMaterialBlock, options?: {
  56073. input?: string;
  56074. output?: string;
  56075. outputSwizzle?: string;
  56076. }): this | undefined;
  56077. protected _buildBlock(state: NodeMaterialBuildState): void;
  56078. /**
  56079. * Add uniforms, samplers and uniform buffers at compilation time
  56080. * @param state defines the state to update
  56081. * @param nodeMaterial defines the node material requesting the update
  56082. * @param defines defines the material defines to update
  56083. */
  56084. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56085. /**
  56086. * Add potential fallbacks if shader compilation fails
  56087. * @param mesh defines the mesh to be rendered
  56088. * @param fallbacks defines the current prioritized list of fallbacks
  56089. */
  56090. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56091. /**
  56092. * Initialize defines for shader compilation
  56093. * @param mesh defines the mesh to be rendered
  56094. * @param nodeMaterial defines the node material requesting the update
  56095. * @param defines defines the material defines to update
  56096. * @param useInstances specifies that instances should be used
  56097. */
  56098. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56099. /**
  56100. * Update defines for shader compilation
  56101. * @param mesh defines the mesh to be rendered
  56102. * @param nodeMaterial defines the node material requesting the update
  56103. * @param defines defines the material defines to update
  56104. * @param useInstances specifies that instances should be used
  56105. */
  56106. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56107. /**
  56108. * Lets the block try to connect some inputs automatically
  56109. * @param material defines the hosting NodeMaterial
  56110. */
  56111. autoConfigure(material: NodeMaterial): void;
  56112. /**
  56113. * Function called when a block is declared as repeatable content generator
  56114. * @param vertexShaderState defines the current compilation state for the vertex shader
  56115. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56116. * @param mesh defines the mesh to be rendered
  56117. * @param defines defines the material defines to update
  56118. */
  56119. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56120. /**
  56121. * Checks if the block is ready
  56122. * @param mesh defines the mesh to be rendered
  56123. * @param nodeMaterial defines the node material requesting the update
  56124. * @param defines defines the material defines to update
  56125. * @param useInstances specifies that instances should be used
  56126. * @returns true if the block is ready
  56127. */
  56128. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56129. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56130. private _processBuild;
  56131. /**
  56132. * Compile the current node and generate the shader code
  56133. * @param state defines the current compilation state (uniforms, samplers, current string)
  56134. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56135. * @returns true if already built
  56136. */
  56137. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56138. protected _inputRename(name: string): string;
  56139. protected _outputRename(name: string): string;
  56140. protected _dumpPropertiesCode(): string;
  56141. /** @hidden */
  56142. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56143. /**
  56144. * Clone the current block to a new identical block
  56145. * @param scene defines the hosting scene
  56146. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56147. * @returns a copy of the current block
  56148. */
  56149. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56150. /**
  56151. * Serializes this block in a JSON representation
  56152. * @returns the serialized block object
  56153. */
  56154. serialize(): any;
  56155. /** @hidden */
  56156. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56157. }
  56158. }
  56159. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56160. /**
  56161. * Enum defining the type of animations supported by InputBlock
  56162. */
  56163. export enum AnimatedInputBlockTypes {
  56164. /** No animation */
  56165. None = 0,
  56166. /** Time based animation. Will only work for floats */
  56167. Time = 1
  56168. }
  56169. }
  56170. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56171. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56172. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56173. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56174. import { Nullable } from "babylonjs/types";
  56175. import { Effect } from "babylonjs/Materials/effect";
  56176. import { Matrix } from "babylonjs/Maths/math.vector";
  56177. import { Scene } from "babylonjs/scene";
  56178. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56180. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56181. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56182. /**
  56183. * Block used to expose an input value
  56184. */
  56185. export class InputBlock extends NodeMaterialBlock {
  56186. private _mode;
  56187. private _associatedVariableName;
  56188. private _storedValue;
  56189. private _valueCallback;
  56190. private _type;
  56191. private _animationType;
  56192. /** Gets or set a value used to limit the range of float values */
  56193. min: number;
  56194. /** Gets or set a value used to limit the range of float values */
  56195. max: number;
  56196. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56197. matrixMode: number;
  56198. /** @hidden */
  56199. _systemValue: Nullable<NodeMaterialSystemValues>;
  56200. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56201. visibleInInspector: boolean;
  56202. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56203. isConstant: boolean;
  56204. /**
  56205. * Gets or sets the connection point type (default is float)
  56206. */
  56207. readonly type: NodeMaterialBlockConnectionPointTypes;
  56208. /**
  56209. * Creates a new InputBlock
  56210. * @param name defines the block name
  56211. * @param target defines the target of that block (Vertex by default)
  56212. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56213. */
  56214. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56215. /**
  56216. * Gets the output component
  56217. */
  56218. readonly output: NodeMaterialConnectionPoint;
  56219. /**
  56220. * Set the source of this connection point to a vertex attribute
  56221. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56222. * @returns the current connection point
  56223. */
  56224. setAsAttribute(attributeName?: string): InputBlock;
  56225. /**
  56226. * Set the source of this connection point to a system value
  56227. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56228. * @returns the current connection point
  56229. */
  56230. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56231. /**
  56232. * Gets or sets the value of that point.
  56233. * Please note that this value will be ignored if valueCallback is defined
  56234. */
  56235. value: any;
  56236. /**
  56237. * Gets or sets a callback used to get the value of that point.
  56238. * Please note that setting this value will force the connection point to ignore the value property
  56239. */
  56240. valueCallback: () => any;
  56241. /**
  56242. * Gets or sets the associated variable name in the shader
  56243. */
  56244. associatedVariableName: string;
  56245. /** Gets or sets the type of animation applied to the input */
  56246. animationType: AnimatedInputBlockTypes;
  56247. /**
  56248. * Gets a boolean indicating that this connection point not defined yet
  56249. */
  56250. readonly isUndefined: boolean;
  56251. /**
  56252. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56253. * In this case the connection point name must be the name of the uniform to use.
  56254. * Can only be set on inputs
  56255. */
  56256. isUniform: boolean;
  56257. /**
  56258. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56259. * In this case the connection point name must be the name of the attribute to use
  56260. * Can only be set on inputs
  56261. */
  56262. isAttribute: boolean;
  56263. /**
  56264. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56265. * Can only be set on exit points
  56266. */
  56267. isVarying: boolean;
  56268. /**
  56269. * Gets a boolean indicating that the current connection point is a system value
  56270. */
  56271. readonly isSystemValue: boolean;
  56272. /**
  56273. * Gets or sets the current well known value or null if not defined as a system value
  56274. */
  56275. systemValue: Nullable<NodeMaterialSystemValues>;
  56276. /**
  56277. * Gets the current class name
  56278. * @returns the class name
  56279. */
  56280. getClassName(): string;
  56281. /**
  56282. * Animate the input if animationType !== None
  56283. * @param scene defines the rendering scene
  56284. */
  56285. animate(scene: Scene): void;
  56286. private _emitDefine;
  56287. initialize(state: NodeMaterialBuildState): void;
  56288. /**
  56289. * Set the input block to its default value (based on its type)
  56290. */
  56291. setDefaultValue(): void;
  56292. private _emitConstant;
  56293. private _emit;
  56294. /** @hidden */
  56295. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56296. /** @hidden */
  56297. _transmit(effect: Effect, scene: Scene): void;
  56298. protected _buildBlock(state: NodeMaterialBuildState): void;
  56299. protected _dumpPropertiesCode(): string;
  56300. serialize(): any;
  56301. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56302. }
  56303. }
  56304. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56305. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56306. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56307. import { Nullable } from "babylonjs/types";
  56308. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56309. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56310. /**
  56311. * Defines a connection point for a block
  56312. */
  56313. export class NodeMaterialConnectionPoint {
  56314. /** @hidden */
  56315. _ownerBlock: NodeMaterialBlock;
  56316. /** @hidden */
  56317. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56318. private _endpoints;
  56319. private _associatedVariableName;
  56320. /** @hidden */
  56321. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56322. /** @hidden */
  56323. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56324. private _type;
  56325. /** @hidden */
  56326. _enforceAssociatedVariableName: boolean;
  56327. /**
  56328. * Gets or sets the additional types supported by this connection point
  56329. */
  56330. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56331. /**
  56332. * Gets or sets the additional types excluded by this connection point
  56333. */
  56334. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56335. /**
  56336. * Gets or sets the associated variable name in the shader
  56337. */
  56338. associatedVariableName: string;
  56339. /**
  56340. * Gets or sets the connection point type (default is float)
  56341. */
  56342. type: NodeMaterialBlockConnectionPointTypes;
  56343. /**
  56344. * Gets or sets the connection point name
  56345. */
  56346. name: string;
  56347. /**
  56348. * Gets or sets a boolean indicating that this connection point can be omitted
  56349. */
  56350. isOptional: boolean;
  56351. /**
  56352. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56353. */
  56354. define: string;
  56355. /** Gets or sets the target of that connection point */
  56356. target: NodeMaterialBlockTargets;
  56357. /**
  56358. * Gets a boolean indicating that the current point is connected
  56359. */
  56360. readonly isConnected: boolean;
  56361. /**
  56362. * Gets a boolean indicating that the current point is connected to an input block
  56363. */
  56364. readonly isConnectedToInputBlock: boolean;
  56365. /**
  56366. * Gets a the connected input block (if any)
  56367. */
  56368. readonly connectInputBlock: Nullable<InputBlock>;
  56369. /** Get the other side of the connection (if any) */
  56370. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56371. /** Get the block that owns this connection point */
  56372. readonly ownerBlock: NodeMaterialBlock;
  56373. /** Get the block connected on the other side of this connection (if any) */
  56374. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56375. /** Get the block connected on the endpoints of this connection (if any) */
  56376. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56377. /** Gets the list of connected endpoints */
  56378. readonly endpoints: NodeMaterialConnectionPoint[];
  56379. /** Gets a boolean indicating if that output point is connected to at least one input */
  56380. readonly hasEndpoints: boolean;
  56381. /**
  56382. * Creates a new connection point
  56383. * @param name defines the connection point name
  56384. * @param ownerBlock defines the block hosting this connection point
  56385. */
  56386. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56387. /**
  56388. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56389. * @returns the class name
  56390. */
  56391. getClassName(): string;
  56392. /**
  56393. * Gets an boolean indicating if the current point can be connected to another point
  56394. * @param connectionPoint defines the other connection point
  56395. * @returns true if the connection is possible
  56396. */
  56397. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56398. /**
  56399. * Connect this point to another connection point
  56400. * @param connectionPoint defines the other connection point
  56401. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56402. * @returns the current connection point
  56403. */
  56404. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56405. /**
  56406. * Disconnect this point from one of his endpoint
  56407. * @param endpoint defines the other connection point
  56408. * @returns the current connection point
  56409. */
  56410. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56411. /**
  56412. * Serializes this point in a JSON representation
  56413. * @returns the serialized point object
  56414. */
  56415. serialize(): any;
  56416. }
  56417. }
  56418. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56419. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56422. import { Mesh } from "babylonjs/Meshes/mesh";
  56423. import { Effect } from "babylonjs/Materials/effect";
  56424. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56425. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56426. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56427. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56428. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56429. /**
  56430. * Block used to add support for vertex skinning (bones)
  56431. */
  56432. export class BonesBlock extends NodeMaterialBlock {
  56433. /**
  56434. * Creates a new BonesBlock
  56435. * @param name defines the block name
  56436. */
  56437. constructor(name: string);
  56438. /**
  56439. * Initialize the block and prepare the context for build
  56440. * @param state defines the state that will be used for the build
  56441. */
  56442. initialize(state: NodeMaterialBuildState): void;
  56443. /**
  56444. * Gets the current class name
  56445. * @returns the class name
  56446. */
  56447. getClassName(): string;
  56448. /**
  56449. * Gets the matrix indices input component
  56450. */
  56451. readonly matricesIndices: NodeMaterialConnectionPoint;
  56452. /**
  56453. * Gets the matrix weights input component
  56454. */
  56455. readonly matricesWeights: NodeMaterialConnectionPoint;
  56456. /**
  56457. * Gets the extra matrix indices input component
  56458. */
  56459. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56460. /**
  56461. * Gets the extra matrix weights input component
  56462. */
  56463. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56464. /**
  56465. * Gets the world input component
  56466. */
  56467. readonly world: NodeMaterialConnectionPoint;
  56468. /**
  56469. * Gets the output component
  56470. */
  56471. readonly output: NodeMaterialConnectionPoint;
  56472. autoConfigure(material: NodeMaterial): void;
  56473. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56474. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56475. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56476. protected _buildBlock(state: NodeMaterialBuildState): this;
  56477. }
  56478. }
  56479. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56480. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56481. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56482. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56484. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56485. /**
  56486. * Block used to add support for instances
  56487. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56488. */
  56489. export class InstancesBlock extends NodeMaterialBlock {
  56490. /**
  56491. * Creates a new InstancesBlock
  56492. * @param name defines the block name
  56493. */
  56494. constructor(name: string);
  56495. /**
  56496. * Gets the current class name
  56497. * @returns the class name
  56498. */
  56499. getClassName(): string;
  56500. /**
  56501. * Gets the first world row input component
  56502. */
  56503. readonly world0: NodeMaterialConnectionPoint;
  56504. /**
  56505. * Gets the second world row input component
  56506. */
  56507. readonly world1: NodeMaterialConnectionPoint;
  56508. /**
  56509. * Gets the third world row input component
  56510. */
  56511. readonly world2: NodeMaterialConnectionPoint;
  56512. /**
  56513. * Gets the forth world row input component
  56514. */
  56515. readonly world3: NodeMaterialConnectionPoint;
  56516. /**
  56517. * Gets the world input component
  56518. */
  56519. readonly world: NodeMaterialConnectionPoint;
  56520. /**
  56521. * Gets the output component
  56522. */
  56523. readonly output: NodeMaterialConnectionPoint;
  56524. autoConfigure(material: NodeMaterial): void;
  56525. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56526. protected _buildBlock(state: NodeMaterialBuildState): this;
  56527. }
  56528. }
  56529. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56530. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56531. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56532. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56534. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56535. import { Effect } from "babylonjs/Materials/effect";
  56536. import { Mesh } from "babylonjs/Meshes/mesh";
  56537. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56538. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56539. /**
  56540. * Block used to add morph targets support to vertex shader
  56541. */
  56542. export class MorphTargetsBlock extends NodeMaterialBlock {
  56543. private _repeatableContentAnchor;
  56544. private _repeatebleContentGenerated;
  56545. /**
  56546. * Create a new MorphTargetsBlock
  56547. * @param name defines the block name
  56548. */
  56549. constructor(name: string);
  56550. /**
  56551. * Gets the current class name
  56552. * @returns the class name
  56553. */
  56554. getClassName(): string;
  56555. /**
  56556. * Gets the position input component
  56557. */
  56558. readonly position: NodeMaterialConnectionPoint;
  56559. /**
  56560. * Gets the normal input component
  56561. */
  56562. readonly normal: NodeMaterialConnectionPoint;
  56563. /**
  56564. * Gets the tangent input component
  56565. */
  56566. readonly tangent: NodeMaterialConnectionPoint;
  56567. /**
  56568. * Gets the tangent input component
  56569. */
  56570. readonly uv: NodeMaterialConnectionPoint;
  56571. /**
  56572. * Gets the position output component
  56573. */
  56574. readonly positionOutput: NodeMaterialConnectionPoint;
  56575. /**
  56576. * Gets the normal output component
  56577. */
  56578. readonly normalOutput: NodeMaterialConnectionPoint;
  56579. /**
  56580. * Gets the tangent output component
  56581. */
  56582. readonly tangentOutput: NodeMaterialConnectionPoint;
  56583. /**
  56584. * Gets the tangent output component
  56585. */
  56586. readonly uvOutput: NodeMaterialConnectionPoint;
  56587. initialize(state: NodeMaterialBuildState): void;
  56588. autoConfigure(material: NodeMaterial): void;
  56589. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56590. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56591. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56592. protected _buildBlock(state: NodeMaterialBuildState): this;
  56593. }
  56594. }
  56595. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56596. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56597. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56598. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56599. import { Nullable } from "babylonjs/types";
  56600. import { Scene } from "babylonjs/scene";
  56601. import { Effect } from "babylonjs/Materials/effect";
  56602. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56603. import { Mesh } from "babylonjs/Meshes/mesh";
  56604. import { Light } from "babylonjs/Lights/light";
  56605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56606. /**
  56607. * Block used to get data information from a light
  56608. */
  56609. export class LightInformationBlock extends NodeMaterialBlock {
  56610. private _lightDataUniformName;
  56611. private _lightColorUniformName;
  56612. private _lightTypeDefineName;
  56613. /**
  56614. * Gets or sets the light associated with this block
  56615. */
  56616. light: Nullable<Light>;
  56617. /**
  56618. * Creates a new LightInformationBlock
  56619. * @param name defines the block name
  56620. */
  56621. constructor(name: string);
  56622. /**
  56623. * Gets the current class name
  56624. * @returns the class name
  56625. */
  56626. getClassName(): string;
  56627. /**
  56628. * Gets the world position input component
  56629. */
  56630. readonly worldPosition: NodeMaterialConnectionPoint;
  56631. /**
  56632. * Gets the direction output component
  56633. */
  56634. readonly direction: NodeMaterialConnectionPoint;
  56635. /**
  56636. * Gets the direction output component
  56637. */
  56638. readonly color: NodeMaterialConnectionPoint;
  56639. /**
  56640. * Gets the direction output component
  56641. */
  56642. readonly intensity: NodeMaterialConnectionPoint;
  56643. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56644. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56645. protected _buildBlock(state: NodeMaterialBuildState): this;
  56646. serialize(): any;
  56647. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56648. }
  56649. }
  56650. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56651. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56652. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56653. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56654. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56655. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56656. }
  56657. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56658. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56659. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56660. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56662. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56663. import { Effect } from "babylonjs/Materials/effect";
  56664. import { Mesh } from "babylonjs/Meshes/mesh";
  56665. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56666. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56667. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56668. /**
  56669. * Block used to add image processing support to fragment shader
  56670. */
  56671. export class ImageProcessingBlock extends NodeMaterialBlock {
  56672. /**
  56673. * Create a new ImageProcessingBlock
  56674. * @param name defines the block name
  56675. */
  56676. constructor(name: string);
  56677. /**
  56678. * Gets the current class name
  56679. * @returns the class name
  56680. */
  56681. getClassName(): string;
  56682. /**
  56683. * Gets the color input component
  56684. */
  56685. readonly color: NodeMaterialConnectionPoint;
  56686. /**
  56687. * Gets the output component
  56688. */
  56689. readonly output: NodeMaterialConnectionPoint;
  56690. /**
  56691. * Initialize the block and prepare the context for build
  56692. * @param state defines the state that will be used for the build
  56693. */
  56694. initialize(state: NodeMaterialBuildState): void;
  56695. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56696. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56697. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56698. protected _buildBlock(state: NodeMaterialBuildState): this;
  56699. }
  56700. }
  56701. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56702. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56703. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56704. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56705. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56707. import { Effect } from "babylonjs/Materials/effect";
  56708. import { Mesh } from "babylonjs/Meshes/mesh";
  56709. import { Scene } from "babylonjs/scene";
  56710. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56711. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56712. /**
  56713. * Block used to pertub normals based on a normal map
  56714. */
  56715. export class PerturbNormalBlock extends NodeMaterialBlock {
  56716. private _tangentSpaceParameterName;
  56717. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56718. invertX: boolean;
  56719. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56720. invertY: boolean;
  56721. /**
  56722. * Create a new PerturbNormalBlock
  56723. * @param name defines the block name
  56724. */
  56725. constructor(name: string);
  56726. /**
  56727. * Gets the current class name
  56728. * @returns the class name
  56729. */
  56730. getClassName(): string;
  56731. /**
  56732. * Gets the world position input component
  56733. */
  56734. readonly worldPosition: NodeMaterialConnectionPoint;
  56735. /**
  56736. * Gets the world normal input component
  56737. */
  56738. readonly worldNormal: NodeMaterialConnectionPoint;
  56739. /**
  56740. * Gets the uv input component
  56741. */
  56742. readonly uv: NodeMaterialConnectionPoint;
  56743. /**
  56744. * Gets the normal map color input component
  56745. */
  56746. readonly normalMapColor: NodeMaterialConnectionPoint;
  56747. /**
  56748. * Gets the strength input component
  56749. */
  56750. readonly strength: NodeMaterialConnectionPoint;
  56751. /**
  56752. * Gets the output component
  56753. */
  56754. readonly output: NodeMaterialConnectionPoint;
  56755. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56756. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56757. autoConfigure(material: NodeMaterial): void;
  56758. protected _buildBlock(state: NodeMaterialBuildState): this;
  56759. protected _dumpPropertiesCode(): string;
  56760. serialize(): any;
  56761. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56762. }
  56763. }
  56764. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56765. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56766. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56767. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56768. /**
  56769. * Block used to discard a pixel if a value is smaller than a cutoff
  56770. */
  56771. export class DiscardBlock extends NodeMaterialBlock {
  56772. /**
  56773. * Create a new DiscardBlock
  56774. * @param name defines the block name
  56775. */
  56776. constructor(name: string);
  56777. /**
  56778. * Gets the current class name
  56779. * @returns the class name
  56780. */
  56781. getClassName(): string;
  56782. /**
  56783. * Gets the color input component
  56784. */
  56785. readonly value: NodeMaterialConnectionPoint;
  56786. /**
  56787. * Gets the cutoff input component
  56788. */
  56789. readonly cutoff: NodeMaterialConnectionPoint;
  56790. protected _buildBlock(state: NodeMaterialBuildState): this;
  56791. }
  56792. }
  56793. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56794. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56795. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56796. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56797. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56798. }
  56799. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56800. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56801. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56802. import { Mesh } from "babylonjs/Meshes/mesh";
  56803. import { Effect } from "babylonjs/Materials/effect";
  56804. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56806. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56807. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56808. /**
  56809. * Block used to add support for scene fog
  56810. */
  56811. export class FogBlock extends NodeMaterialBlock {
  56812. private _fogDistanceName;
  56813. private _fogParameters;
  56814. /**
  56815. * Create a new FogBlock
  56816. * @param name defines the block name
  56817. */
  56818. constructor(name: string);
  56819. /**
  56820. * Gets the current class name
  56821. * @returns the class name
  56822. */
  56823. getClassName(): string;
  56824. /**
  56825. * Gets the world position input component
  56826. */
  56827. readonly worldPosition: NodeMaterialConnectionPoint;
  56828. /**
  56829. * Gets the view input component
  56830. */
  56831. readonly view: NodeMaterialConnectionPoint;
  56832. /**
  56833. * Gets the color input component
  56834. */
  56835. readonly input: NodeMaterialConnectionPoint;
  56836. /**
  56837. * Gets the fog color input component
  56838. */
  56839. readonly fogColor: NodeMaterialConnectionPoint;
  56840. /**
  56841. * Gets the output component
  56842. */
  56843. readonly output: NodeMaterialConnectionPoint;
  56844. autoConfigure(material: NodeMaterial): void;
  56845. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56846. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56847. protected _buildBlock(state: NodeMaterialBuildState): this;
  56848. }
  56849. }
  56850. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56851. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56852. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56853. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56855. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56856. import { Effect } from "babylonjs/Materials/effect";
  56857. import { Mesh } from "babylonjs/Meshes/mesh";
  56858. import { Light } from "babylonjs/Lights/light";
  56859. import { Nullable } from "babylonjs/types";
  56860. import { Scene } from "babylonjs/scene";
  56861. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56862. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56863. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56864. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56865. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56866. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56867. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56868. /**
  56869. * Block used to add light in the fragment shader
  56870. */
  56871. export class LightBlock extends NodeMaterialBlock {
  56872. private _lightId;
  56873. /**
  56874. * Gets or sets the light associated with this block
  56875. */
  56876. light: Nullable<Light>;
  56877. /**
  56878. * Create a new LightBlock
  56879. * @param name defines the block name
  56880. */
  56881. constructor(name: string);
  56882. /**
  56883. * Gets the current class name
  56884. * @returns the class name
  56885. */
  56886. getClassName(): string;
  56887. /**
  56888. * Gets the world position input component
  56889. */
  56890. readonly worldPosition: NodeMaterialConnectionPoint;
  56891. /**
  56892. * Gets the world normal input component
  56893. */
  56894. readonly worldNormal: NodeMaterialConnectionPoint;
  56895. /**
  56896. * Gets the camera (or eye) position component
  56897. */
  56898. readonly cameraPosition: NodeMaterialConnectionPoint;
  56899. /**
  56900. * Gets the glossiness component
  56901. */
  56902. readonly glossiness: NodeMaterialConnectionPoint;
  56903. /**
  56904. * Gets the glossinness power component
  56905. */
  56906. readonly glossPower: NodeMaterialConnectionPoint;
  56907. /**
  56908. * Gets the diffuse color component
  56909. */
  56910. readonly diffuseColor: NodeMaterialConnectionPoint;
  56911. /**
  56912. * Gets the specular color component
  56913. */
  56914. readonly specularColor: NodeMaterialConnectionPoint;
  56915. /**
  56916. * Gets the diffuse output component
  56917. */
  56918. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56919. /**
  56920. * Gets the specular output component
  56921. */
  56922. readonly specularOutput: NodeMaterialConnectionPoint;
  56923. autoConfigure(material: NodeMaterial): void;
  56924. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56925. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56926. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56927. private _injectVertexCode;
  56928. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56929. serialize(): any;
  56930. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56931. }
  56932. }
  56933. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56934. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56935. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56936. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56937. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56938. }
  56939. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56940. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56941. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56942. }
  56943. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56944. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56945. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56946. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56947. /**
  56948. * Block used to multiply 2 values
  56949. */
  56950. export class MultiplyBlock extends NodeMaterialBlock {
  56951. /**
  56952. * Creates a new MultiplyBlock
  56953. * @param name defines the block name
  56954. */
  56955. constructor(name: string);
  56956. /**
  56957. * Gets the current class name
  56958. * @returns the class name
  56959. */
  56960. getClassName(): string;
  56961. /**
  56962. * Gets the left operand input component
  56963. */
  56964. readonly left: NodeMaterialConnectionPoint;
  56965. /**
  56966. * Gets the right operand input component
  56967. */
  56968. readonly right: NodeMaterialConnectionPoint;
  56969. /**
  56970. * Gets the output component
  56971. */
  56972. readonly output: NodeMaterialConnectionPoint;
  56973. protected _buildBlock(state: NodeMaterialBuildState): this;
  56974. }
  56975. }
  56976. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56977. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56978. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56979. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56980. /**
  56981. * Block used to add 2 vectors
  56982. */
  56983. export class AddBlock extends NodeMaterialBlock {
  56984. /**
  56985. * Creates a new AddBlock
  56986. * @param name defines the block name
  56987. */
  56988. constructor(name: string);
  56989. /**
  56990. * Gets the current class name
  56991. * @returns the class name
  56992. */
  56993. getClassName(): string;
  56994. /**
  56995. * Gets the left operand input component
  56996. */
  56997. readonly left: NodeMaterialConnectionPoint;
  56998. /**
  56999. * Gets the right operand input component
  57000. */
  57001. readonly right: NodeMaterialConnectionPoint;
  57002. /**
  57003. * Gets the output component
  57004. */
  57005. readonly output: NodeMaterialConnectionPoint;
  57006. protected _buildBlock(state: NodeMaterialBuildState): this;
  57007. }
  57008. }
  57009. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57010. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57011. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57012. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57013. /**
  57014. * Block used to scale a vector by a float
  57015. */
  57016. export class ScaleBlock extends NodeMaterialBlock {
  57017. /**
  57018. * Creates a new ScaleBlock
  57019. * @param name defines the block name
  57020. */
  57021. constructor(name: string);
  57022. /**
  57023. * Gets the current class name
  57024. * @returns the class name
  57025. */
  57026. getClassName(): string;
  57027. /**
  57028. * Gets the input component
  57029. */
  57030. readonly input: NodeMaterialConnectionPoint;
  57031. /**
  57032. * Gets the factor input component
  57033. */
  57034. readonly factor: NodeMaterialConnectionPoint;
  57035. /**
  57036. * Gets the output component
  57037. */
  57038. readonly output: NodeMaterialConnectionPoint;
  57039. protected _buildBlock(state: NodeMaterialBuildState): this;
  57040. }
  57041. }
  57042. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57043. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57044. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57045. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57046. import { Scene } from "babylonjs/scene";
  57047. /**
  57048. * Block used to clamp a float
  57049. */
  57050. export class ClampBlock extends NodeMaterialBlock {
  57051. /** Gets or sets the minimum range */
  57052. minimum: number;
  57053. /** Gets or sets the maximum range */
  57054. maximum: number;
  57055. /**
  57056. * Creates a new ClampBlock
  57057. * @param name defines the block name
  57058. */
  57059. constructor(name: string);
  57060. /**
  57061. * Gets the current class name
  57062. * @returns the class name
  57063. */
  57064. getClassName(): string;
  57065. /**
  57066. * Gets the value input component
  57067. */
  57068. readonly value: NodeMaterialConnectionPoint;
  57069. /**
  57070. * Gets the output component
  57071. */
  57072. readonly output: NodeMaterialConnectionPoint;
  57073. protected _buildBlock(state: NodeMaterialBuildState): this;
  57074. protected _dumpPropertiesCode(): string;
  57075. serialize(): any;
  57076. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57077. }
  57078. }
  57079. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57080. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57081. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57082. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57083. /**
  57084. * Block used to apply a cross product between 2 vectors
  57085. */
  57086. export class CrossBlock extends NodeMaterialBlock {
  57087. /**
  57088. * Creates a new CrossBlock
  57089. * @param name defines the block name
  57090. */
  57091. constructor(name: string);
  57092. /**
  57093. * Gets the current class name
  57094. * @returns the class name
  57095. */
  57096. getClassName(): string;
  57097. /**
  57098. * Gets the left operand input component
  57099. */
  57100. readonly left: NodeMaterialConnectionPoint;
  57101. /**
  57102. * Gets the right operand input component
  57103. */
  57104. readonly right: NodeMaterialConnectionPoint;
  57105. /**
  57106. * Gets the output component
  57107. */
  57108. readonly output: NodeMaterialConnectionPoint;
  57109. protected _buildBlock(state: NodeMaterialBuildState): this;
  57110. }
  57111. }
  57112. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57113. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57114. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57115. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57116. /**
  57117. * Block used to apply a dot product between 2 vectors
  57118. */
  57119. export class DotBlock extends NodeMaterialBlock {
  57120. /**
  57121. * Creates a new DotBlock
  57122. * @param name defines the block name
  57123. */
  57124. constructor(name: string);
  57125. /**
  57126. * Gets the current class name
  57127. * @returns the class name
  57128. */
  57129. getClassName(): string;
  57130. /**
  57131. * Gets the left operand input component
  57132. */
  57133. readonly left: NodeMaterialConnectionPoint;
  57134. /**
  57135. * Gets the right operand input component
  57136. */
  57137. readonly right: NodeMaterialConnectionPoint;
  57138. /**
  57139. * Gets the output component
  57140. */
  57141. readonly output: NodeMaterialConnectionPoint;
  57142. protected _buildBlock(state: NodeMaterialBuildState): this;
  57143. }
  57144. }
  57145. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57146. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57147. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57148. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57149. import { Vector2 } from "babylonjs/Maths/math.vector";
  57150. import { Scene } from "babylonjs/scene";
  57151. /**
  57152. * Block used to remap a float from a range to a new one
  57153. */
  57154. export class RemapBlock extends NodeMaterialBlock {
  57155. /**
  57156. * Gets or sets the source range
  57157. */
  57158. sourceRange: Vector2;
  57159. /**
  57160. * Gets or sets the target range
  57161. */
  57162. targetRange: Vector2;
  57163. /**
  57164. * Creates a new RemapBlock
  57165. * @param name defines the block name
  57166. */
  57167. constructor(name: string);
  57168. /**
  57169. * Gets the current class name
  57170. * @returns the class name
  57171. */
  57172. getClassName(): string;
  57173. /**
  57174. * Gets the input component
  57175. */
  57176. readonly input: NodeMaterialConnectionPoint;
  57177. /**
  57178. * Gets the source min input component
  57179. */
  57180. readonly sourceMin: NodeMaterialConnectionPoint;
  57181. /**
  57182. * Gets the source max input component
  57183. */
  57184. readonly sourceMax: NodeMaterialConnectionPoint;
  57185. /**
  57186. * Gets the target min input component
  57187. */
  57188. readonly targetMin: NodeMaterialConnectionPoint;
  57189. /**
  57190. * Gets the target max input component
  57191. */
  57192. readonly targetMax: NodeMaterialConnectionPoint;
  57193. /**
  57194. * Gets the output component
  57195. */
  57196. readonly output: NodeMaterialConnectionPoint;
  57197. protected _buildBlock(state: NodeMaterialBuildState): this;
  57198. protected _dumpPropertiesCode(): string;
  57199. serialize(): any;
  57200. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57201. }
  57202. }
  57203. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57204. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57205. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57206. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57207. /**
  57208. * Block used to normalize a vector
  57209. */
  57210. export class NormalizeBlock extends NodeMaterialBlock {
  57211. /**
  57212. * Creates a new NormalizeBlock
  57213. * @param name defines the block name
  57214. */
  57215. constructor(name: string);
  57216. /**
  57217. * Gets the current class name
  57218. * @returns the class name
  57219. */
  57220. getClassName(): string;
  57221. /**
  57222. * Gets the input component
  57223. */
  57224. readonly input: NodeMaterialConnectionPoint;
  57225. /**
  57226. * Gets the output component
  57227. */
  57228. readonly output: NodeMaterialConnectionPoint;
  57229. protected _buildBlock(state: NodeMaterialBuildState): this;
  57230. }
  57231. }
  57232. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57233. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57234. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57235. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57236. import { Scene } from "babylonjs/scene";
  57237. /**
  57238. * Operations supported by the Trigonometry block
  57239. */
  57240. export enum TrigonometryBlockOperations {
  57241. /** Cos */
  57242. Cos = 0,
  57243. /** Sin */
  57244. Sin = 1,
  57245. /** Abs */
  57246. Abs = 2,
  57247. /** Exp */
  57248. Exp = 3,
  57249. /** Exp2 */
  57250. Exp2 = 4,
  57251. /** Round */
  57252. Round = 5,
  57253. /** Floor */
  57254. Floor = 6,
  57255. /** Ceiling */
  57256. Ceiling = 7,
  57257. /** Square root */
  57258. Sqrt = 8,
  57259. /** Log */
  57260. Log = 9,
  57261. /** Tangent */
  57262. Tan = 10,
  57263. /** Arc tangent */
  57264. ArcTan = 11,
  57265. /** Arc cosinus */
  57266. ArcCos = 12,
  57267. /** Arc sinus */
  57268. ArcSin = 13,
  57269. /** Fraction */
  57270. Fract = 14,
  57271. /** Sign */
  57272. Sign = 15,
  57273. /** To radians (from degrees) */
  57274. Radians = 16,
  57275. /** To degrees (from radians) */
  57276. Degrees = 17
  57277. }
  57278. /**
  57279. * Block used to apply trigonometry operation to floats
  57280. */
  57281. export class TrigonometryBlock extends NodeMaterialBlock {
  57282. /**
  57283. * Gets or sets the operation applied by the block
  57284. */
  57285. operation: TrigonometryBlockOperations;
  57286. /**
  57287. * Creates a new TrigonometryBlock
  57288. * @param name defines the block name
  57289. */
  57290. constructor(name: string);
  57291. /**
  57292. * Gets the current class name
  57293. * @returns the class name
  57294. */
  57295. getClassName(): string;
  57296. /**
  57297. * Gets the input component
  57298. */
  57299. readonly input: NodeMaterialConnectionPoint;
  57300. /**
  57301. * Gets the output component
  57302. */
  57303. readonly output: NodeMaterialConnectionPoint;
  57304. protected _buildBlock(state: NodeMaterialBuildState): this;
  57305. serialize(): any;
  57306. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57307. }
  57308. }
  57309. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57310. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57311. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57312. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57313. /**
  57314. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57315. */
  57316. export class ColorMergerBlock extends NodeMaterialBlock {
  57317. /**
  57318. * Create a new ColorMergerBlock
  57319. * @param name defines the block name
  57320. */
  57321. constructor(name: string);
  57322. /**
  57323. * Gets the current class name
  57324. * @returns the class name
  57325. */
  57326. getClassName(): string;
  57327. /**
  57328. * Gets the r component (input)
  57329. */
  57330. readonly r: NodeMaterialConnectionPoint;
  57331. /**
  57332. * Gets the g component (input)
  57333. */
  57334. readonly g: NodeMaterialConnectionPoint;
  57335. /**
  57336. * Gets the b component (input)
  57337. */
  57338. readonly b: NodeMaterialConnectionPoint;
  57339. /**
  57340. * Gets the a component (input)
  57341. */
  57342. readonly a: NodeMaterialConnectionPoint;
  57343. /**
  57344. * Gets the rgba component (output)
  57345. */
  57346. readonly rgba: NodeMaterialConnectionPoint;
  57347. /**
  57348. * Gets the rgb component (output)
  57349. */
  57350. readonly rgb: NodeMaterialConnectionPoint;
  57351. protected _buildBlock(state: NodeMaterialBuildState): this;
  57352. }
  57353. }
  57354. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57355. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57356. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57357. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57358. /**
  57359. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57360. */
  57361. export class VectorMergerBlock extends NodeMaterialBlock {
  57362. /**
  57363. * Create a new VectorMergerBlock
  57364. * @param name defines the block name
  57365. */
  57366. constructor(name: string);
  57367. /**
  57368. * Gets the current class name
  57369. * @returns the class name
  57370. */
  57371. getClassName(): string;
  57372. /**
  57373. * Gets the x component (input)
  57374. */
  57375. readonly x: NodeMaterialConnectionPoint;
  57376. /**
  57377. * Gets the y component (input)
  57378. */
  57379. readonly y: NodeMaterialConnectionPoint;
  57380. /**
  57381. * Gets the z component (input)
  57382. */
  57383. readonly z: NodeMaterialConnectionPoint;
  57384. /**
  57385. * Gets the w component (input)
  57386. */
  57387. readonly w: NodeMaterialConnectionPoint;
  57388. /**
  57389. * Gets the xyzw component (output)
  57390. */
  57391. readonly xyzw: NodeMaterialConnectionPoint;
  57392. /**
  57393. * Gets the xyz component (output)
  57394. */
  57395. readonly xyz: NodeMaterialConnectionPoint;
  57396. /**
  57397. * Gets the xy component (output)
  57398. */
  57399. readonly xy: NodeMaterialConnectionPoint;
  57400. protected _buildBlock(state: NodeMaterialBuildState): this;
  57401. }
  57402. }
  57403. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57404. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57405. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57406. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57407. /**
  57408. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57409. */
  57410. export class ColorSplitterBlock extends NodeMaterialBlock {
  57411. /**
  57412. * Create a new ColorSplitterBlock
  57413. * @param name defines the block name
  57414. */
  57415. constructor(name: string);
  57416. /**
  57417. * Gets the current class name
  57418. * @returns the class name
  57419. */
  57420. getClassName(): string;
  57421. /**
  57422. * Gets the rgba component (input)
  57423. */
  57424. readonly rgba: NodeMaterialConnectionPoint;
  57425. /**
  57426. * Gets the rgb component (input)
  57427. */
  57428. readonly rgbIn: NodeMaterialConnectionPoint;
  57429. /**
  57430. * Gets the rgb component (output)
  57431. */
  57432. readonly rgbOut: NodeMaterialConnectionPoint;
  57433. /**
  57434. * Gets the r component (output)
  57435. */
  57436. readonly r: NodeMaterialConnectionPoint;
  57437. /**
  57438. * Gets the g component (output)
  57439. */
  57440. readonly g: NodeMaterialConnectionPoint;
  57441. /**
  57442. * Gets the b component (output)
  57443. */
  57444. readonly b: NodeMaterialConnectionPoint;
  57445. /**
  57446. * Gets the a component (output)
  57447. */
  57448. readonly a: NodeMaterialConnectionPoint;
  57449. protected _inputRename(name: string): string;
  57450. protected _outputRename(name: string): string;
  57451. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57452. }
  57453. }
  57454. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57455. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57456. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57457. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57458. /**
  57459. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57460. */
  57461. export class VectorSplitterBlock extends NodeMaterialBlock {
  57462. /**
  57463. * Create a new VectorSplitterBlock
  57464. * @param name defines the block name
  57465. */
  57466. constructor(name: string);
  57467. /**
  57468. * Gets the current class name
  57469. * @returns the class name
  57470. */
  57471. getClassName(): string;
  57472. /**
  57473. * Gets the xyzw component (input)
  57474. */
  57475. readonly xyzw: NodeMaterialConnectionPoint;
  57476. /**
  57477. * Gets the xyz component (input)
  57478. */
  57479. readonly xyzIn: NodeMaterialConnectionPoint;
  57480. /**
  57481. * Gets the xy component (input)
  57482. */
  57483. readonly xyIn: NodeMaterialConnectionPoint;
  57484. /**
  57485. * Gets the xyz component (output)
  57486. */
  57487. readonly xyzOut: NodeMaterialConnectionPoint;
  57488. /**
  57489. * Gets the xy component (output)
  57490. */
  57491. readonly xyOut: NodeMaterialConnectionPoint;
  57492. /**
  57493. * Gets the x component (output)
  57494. */
  57495. readonly x: NodeMaterialConnectionPoint;
  57496. /**
  57497. * Gets the y component (output)
  57498. */
  57499. readonly y: NodeMaterialConnectionPoint;
  57500. /**
  57501. * Gets the z component (output)
  57502. */
  57503. readonly z: NodeMaterialConnectionPoint;
  57504. /**
  57505. * Gets the w component (output)
  57506. */
  57507. readonly w: NodeMaterialConnectionPoint;
  57508. protected _inputRename(name: string): string;
  57509. protected _outputRename(name: string): string;
  57510. protected _buildBlock(state: NodeMaterialBuildState): this;
  57511. }
  57512. }
  57513. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57514. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57515. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57516. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57517. /**
  57518. * Block used to lerp between 2 values
  57519. */
  57520. export class LerpBlock extends NodeMaterialBlock {
  57521. /**
  57522. * Creates a new LerpBlock
  57523. * @param name defines the block name
  57524. */
  57525. constructor(name: string);
  57526. /**
  57527. * Gets the current class name
  57528. * @returns the class name
  57529. */
  57530. getClassName(): string;
  57531. /**
  57532. * Gets the left operand input component
  57533. */
  57534. readonly left: NodeMaterialConnectionPoint;
  57535. /**
  57536. * Gets the right operand input component
  57537. */
  57538. readonly right: NodeMaterialConnectionPoint;
  57539. /**
  57540. * Gets the gradient operand input component
  57541. */
  57542. readonly gradient: NodeMaterialConnectionPoint;
  57543. /**
  57544. * Gets the output component
  57545. */
  57546. readonly output: NodeMaterialConnectionPoint;
  57547. protected _buildBlock(state: NodeMaterialBuildState): this;
  57548. }
  57549. }
  57550. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57551. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57552. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57553. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57554. /**
  57555. * Block used to divide 2 vectors
  57556. */
  57557. export class DivideBlock extends NodeMaterialBlock {
  57558. /**
  57559. * Creates a new DivideBlock
  57560. * @param name defines the block name
  57561. */
  57562. constructor(name: string);
  57563. /**
  57564. * Gets the current class name
  57565. * @returns the class name
  57566. */
  57567. getClassName(): string;
  57568. /**
  57569. * Gets the left operand input component
  57570. */
  57571. readonly left: NodeMaterialConnectionPoint;
  57572. /**
  57573. * Gets the right operand input component
  57574. */
  57575. readonly right: NodeMaterialConnectionPoint;
  57576. /**
  57577. * Gets the output component
  57578. */
  57579. readonly output: NodeMaterialConnectionPoint;
  57580. protected _buildBlock(state: NodeMaterialBuildState): this;
  57581. }
  57582. }
  57583. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57584. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57585. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57586. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57587. /**
  57588. * Block used to subtract 2 vectors
  57589. */
  57590. export class SubtractBlock extends NodeMaterialBlock {
  57591. /**
  57592. * Creates a new SubtractBlock
  57593. * @param name defines the block name
  57594. */
  57595. constructor(name: string);
  57596. /**
  57597. * Gets the current class name
  57598. * @returns the class name
  57599. */
  57600. getClassName(): string;
  57601. /**
  57602. * Gets the left operand input component
  57603. */
  57604. readonly left: NodeMaterialConnectionPoint;
  57605. /**
  57606. * Gets the right operand input component
  57607. */
  57608. readonly right: NodeMaterialConnectionPoint;
  57609. /**
  57610. * Gets the output component
  57611. */
  57612. readonly output: NodeMaterialConnectionPoint;
  57613. protected _buildBlock(state: NodeMaterialBuildState): this;
  57614. }
  57615. }
  57616. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57617. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57618. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57619. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57620. /**
  57621. * Block used to step a value
  57622. */
  57623. export class StepBlock extends NodeMaterialBlock {
  57624. /**
  57625. * Creates a new StepBlock
  57626. * @param name defines the block name
  57627. */
  57628. constructor(name: string);
  57629. /**
  57630. * Gets the current class name
  57631. * @returns the class name
  57632. */
  57633. getClassName(): string;
  57634. /**
  57635. * Gets the value operand input component
  57636. */
  57637. readonly value: NodeMaterialConnectionPoint;
  57638. /**
  57639. * Gets the edge operand input component
  57640. */
  57641. readonly edge: NodeMaterialConnectionPoint;
  57642. /**
  57643. * Gets the output component
  57644. */
  57645. readonly output: NodeMaterialConnectionPoint;
  57646. protected _buildBlock(state: NodeMaterialBuildState): this;
  57647. }
  57648. }
  57649. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57650. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57651. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57652. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57653. /**
  57654. * Block used to get the opposite (1 - x) of a value
  57655. */
  57656. export class OneMinusBlock extends NodeMaterialBlock {
  57657. /**
  57658. * Creates a new OneMinusBlock
  57659. * @param name defines the block name
  57660. */
  57661. constructor(name: string);
  57662. /**
  57663. * Gets the current class name
  57664. * @returns the class name
  57665. */
  57666. getClassName(): string;
  57667. /**
  57668. * Gets the input component
  57669. */
  57670. readonly input: NodeMaterialConnectionPoint;
  57671. /**
  57672. * Gets the output component
  57673. */
  57674. readonly output: NodeMaterialConnectionPoint;
  57675. protected _buildBlock(state: NodeMaterialBuildState): this;
  57676. }
  57677. }
  57678. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57682. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57683. /**
  57684. * Block used to get the view direction
  57685. */
  57686. export class ViewDirectionBlock extends NodeMaterialBlock {
  57687. /**
  57688. * Creates a new ViewDirectionBlock
  57689. * @param name defines the block name
  57690. */
  57691. constructor(name: string);
  57692. /**
  57693. * Gets the current class name
  57694. * @returns the class name
  57695. */
  57696. getClassName(): string;
  57697. /**
  57698. * Gets the world position component
  57699. */
  57700. readonly worldPosition: NodeMaterialConnectionPoint;
  57701. /**
  57702. * Gets the camera position component
  57703. */
  57704. readonly cameraPosition: NodeMaterialConnectionPoint;
  57705. /**
  57706. * Gets the output component
  57707. */
  57708. readonly output: NodeMaterialConnectionPoint;
  57709. autoConfigure(material: NodeMaterial): void;
  57710. protected _buildBlock(state: NodeMaterialBuildState): this;
  57711. }
  57712. }
  57713. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57714. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57715. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57716. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57717. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57718. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57719. /**
  57720. * Block used to compute fresnel value
  57721. */
  57722. export class FresnelBlock extends NodeMaterialBlock {
  57723. /**
  57724. * Create a new FresnelBlock
  57725. * @param name defines the block name
  57726. */
  57727. constructor(name: string);
  57728. /**
  57729. * Gets the current class name
  57730. * @returns the class name
  57731. */
  57732. getClassName(): string;
  57733. /**
  57734. * Gets the world normal input component
  57735. */
  57736. readonly worldNormal: NodeMaterialConnectionPoint;
  57737. /**
  57738. * Gets the view direction input component
  57739. */
  57740. readonly viewDirection: NodeMaterialConnectionPoint;
  57741. /**
  57742. * Gets the bias input component
  57743. */
  57744. readonly bias: NodeMaterialConnectionPoint;
  57745. /**
  57746. * Gets the camera (or eye) position component
  57747. */
  57748. readonly power: NodeMaterialConnectionPoint;
  57749. /**
  57750. * Gets the fresnel output component
  57751. */
  57752. readonly fresnel: NodeMaterialConnectionPoint;
  57753. autoConfigure(material: NodeMaterial): void;
  57754. protected _buildBlock(state: NodeMaterialBuildState): this;
  57755. }
  57756. }
  57757. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57758. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57759. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57760. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57761. /**
  57762. * Block used to get the max of 2 values
  57763. */
  57764. export class MaxBlock extends NodeMaterialBlock {
  57765. /**
  57766. * Creates a new MaxBlock
  57767. * @param name defines the block name
  57768. */
  57769. constructor(name: string);
  57770. /**
  57771. * Gets the current class name
  57772. * @returns the class name
  57773. */
  57774. getClassName(): string;
  57775. /**
  57776. * Gets the left operand input component
  57777. */
  57778. readonly left: NodeMaterialConnectionPoint;
  57779. /**
  57780. * Gets the right operand input component
  57781. */
  57782. readonly right: NodeMaterialConnectionPoint;
  57783. /**
  57784. * Gets the output component
  57785. */
  57786. readonly output: NodeMaterialConnectionPoint;
  57787. protected _buildBlock(state: NodeMaterialBuildState): this;
  57788. }
  57789. }
  57790. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57792. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57794. /**
  57795. * Block used to get the min of 2 values
  57796. */
  57797. export class MinBlock extends NodeMaterialBlock {
  57798. /**
  57799. * Creates a new MinBlock
  57800. * @param name defines the block name
  57801. */
  57802. constructor(name: string);
  57803. /**
  57804. * Gets the current class name
  57805. * @returns the class name
  57806. */
  57807. getClassName(): string;
  57808. /**
  57809. * Gets the left operand input component
  57810. */
  57811. readonly left: NodeMaterialConnectionPoint;
  57812. /**
  57813. * Gets the right operand input component
  57814. */
  57815. readonly right: NodeMaterialConnectionPoint;
  57816. /**
  57817. * Gets the output component
  57818. */
  57819. readonly output: NodeMaterialConnectionPoint;
  57820. protected _buildBlock(state: NodeMaterialBuildState): this;
  57821. }
  57822. }
  57823. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57824. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57825. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57826. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57827. /**
  57828. * Block used to get the distance between 2 values
  57829. */
  57830. export class DistanceBlock extends NodeMaterialBlock {
  57831. /**
  57832. * Creates a new DistanceBlock
  57833. * @param name defines the block name
  57834. */
  57835. constructor(name: string);
  57836. /**
  57837. * Gets the current class name
  57838. * @returns the class name
  57839. */
  57840. getClassName(): string;
  57841. /**
  57842. * Gets the left operand input component
  57843. */
  57844. readonly left: NodeMaterialConnectionPoint;
  57845. /**
  57846. * Gets the right operand input component
  57847. */
  57848. readonly right: NodeMaterialConnectionPoint;
  57849. /**
  57850. * Gets the output component
  57851. */
  57852. readonly output: NodeMaterialConnectionPoint;
  57853. protected _buildBlock(state: NodeMaterialBuildState): this;
  57854. }
  57855. }
  57856. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57857. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57858. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57859. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57860. /**
  57861. * Block used to get the length of a vector
  57862. */
  57863. export class LengthBlock extends NodeMaterialBlock {
  57864. /**
  57865. * Creates a new LengthBlock
  57866. * @param name defines the block name
  57867. */
  57868. constructor(name: string);
  57869. /**
  57870. * Gets the current class name
  57871. * @returns the class name
  57872. */
  57873. getClassName(): string;
  57874. /**
  57875. * Gets the value input component
  57876. */
  57877. readonly value: NodeMaterialConnectionPoint;
  57878. /**
  57879. * Gets the output component
  57880. */
  57881. readonly output: NodeMaterialConnectionPoint;
  57882. protected _buildBlock(state: NodeMaterialBuildState): this;
  57883. }
  57884. }
  57885. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57886. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57887. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57888. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57889. /**
  57890. * Block used to get negative version of a value (i.e. x * -1)
  57891. */
  57892. export class NegateBlock extends NodeMaterialBlock {
  57893. /**
  57894. * Creates a new NegateBlock
  57895. * @param name defines the block name
  57896. */
  57897. constructor(name: string);
  57898. /**
  57899. * Gets the current class name
  57900. * @returns the class name
  57901. */
  57902. getClassName(): string;
  57903. /**
  57904. * Gets the value input component
  57905. */
  57906. readonly value: NodeMaterialConnectionPoint;
  57907. /**
  57908. * Gets the output component
  57909. */
  57910. readonly output: NodeMaterialConnectionPoint;
  57911. protected _buildBlock(state: NodeMaterialBuildState): this;
  57912. }
  57913. }
  57914. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57915. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57916. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57917. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57918. /**
  57919. * Block used to get the value of the first parameter raised to the power of the second
  57920. */
  57921. export class PowBlock extends NodeMaterialBlock {
  57922. /**
  57923. * Creates a new PowBlock
  57924. * @param name defines the block name
  57925. */
  57926. constructor(name: string);
  57927. /**
  57928. * Gets the current class name
  57929. * @returns the class name
  57930. */
  57931. getClassName(): string;
  57932. /**
  57933. * Gets the value operand input component
  57934. */
  57935. readonly value: NodeMaterialConnectionPoint;
  57936. /**
  57937. * Gets the power operand input component
  57938. */
  57939. readonly power: NodeMaterialConnectionPoint;
  57940. /**
  57941. * Gets the output component
  57942. */
  57943. readonly output: NodeMaterialConnectionPoint;
  57944. protected _buildBlock(state: NodeMaterialBuildState): this;
  57945. }
  57946. }
  57947. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57948. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57949. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57950. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57951. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57952. /**
  57953. * Block used to get a random number
  57954. */
  57955. export class RandomNumberBlock extends NodeMaterialBlock {
  57956. /**
  57957. * Creates a new RandomNumberBlock
  57958. * @param name defines the block name
  57959. */
  57960. constructor(name: string);
  57961. /**
  57962. * Gets the current class name
  57963. * @returns the class name
  57964. */
  57965. getClassName(): string;
  57966. /**
  57967. * Gets the seed input component
  57968. */
  57969. readonly seed: NodeMaterialConnectionPoint;
  57970. /**
  57971. * Gets the output component
  57972. */
  57973. readonly output: NodeMaterialConnectionPoint;
  57974. protected _buildBlock(state: NodeMaterialBuildState): this;
  57975. }
  57976. }
  57977. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  57978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57981. /**
  57982. * Block used to compute arc tangent of 2 values
  57983. */
  57984. export class ArcTan2Block extends NodeMaterialBlock {
  57985. /**
  57986. * Creates a new ArcTan2Block
  57987. * @param name defines the block name
  57988. */
  57989. constructor(name: string);
  57990. /**
  57991. * Gets the current class name
  57992. * @returns the class name
  57993. */
  57994. getClassName(): string;
  57995. /**
  57996. * Gets the x operand input component
  57997. */
  57998. readonly x: NodeMaterialConnectionPoint;
  57999. /**
  58000. * Gets the y operand input component
  58001. */
  58002. readonly y: NodeMaterialConnectionPoint;
  58003. /**
  58004. * Gets the output component
  58005. */
  58006. readonly output: NodeMaterialConnectionPoint;
  58007. protected _buildBlock(state: NodeMaterialBuildState): this;
  58008. }
  58009. }
  58010. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58011. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58012. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58013. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58014. /**
  58015. * Block used to smooth step a value
  58016. */
  58017. export class SmoothStepBlock extends NodeMaterialBlock {
  58018. /**
  58019. * Creates a new SmoothStepBlock
  58020. * @param name defines the block name
  58021. */
  58022. constructor(name: string);
  58023. /**
  58024. * Gets the current class name
  58025. * @returns the class name
  58026. */
  58027. getClassName(): string;
  58028. /**
  58029. * Gets the value operand input component
  58030. */
  58031. readonly value: NodeMaterialConnectionPoint;
  58032. /**
  58033. * Gets the first edge operand input component
  58034. */
  58035. readonly edge0: NodeMaterialConnectionPoint;
  58036. /**
  58037. * Gets the second edge operand input component
  58038. */
  58039. readonly edge1: NodeMaterialConnectionPoint;
  58040. /**
  58041. * Gets the output component
  58042. */
  58043. readonly output: NodeMaterialConnectionPoint;
  58044. protected _buildBlock(state: NodeMaterialBuildState): this;
  58045. }
  58046. }
  58047. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58048. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58049. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58050. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58051. /**
  58052. * Block used to get the reciprocal (1 / x) of a value
  58053. */
  58054. export class ReciprocalBlock extends NodeMaterialBlock {
  58055. /**
  58056. * Creates a new ReciprocalBlock
  58057. * @param name defines the block name
  58058. */
  58059. constructor(name: string);
  58060. /**
  58061. * Gets the current class name
  58062. * @returns the class name
  58063. */
  58064. getClassName(): string;
  58065. /**
  58066. * Gets the input component
  58067. */
  58068. readonly input: NodeMaterialConnectionPoint;
  58069. /**
  58070. * Gets the output component
  58071. */
  58072. readonly output: NodeMaterialConnectionPoint;
  58073. protected _buildBlock(state: NodeMaterialBuildState): this;
  58074. }
  58075. }
  58076. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58077. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58078. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58079. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58080. /**
  58081. * Block used to replace a color by another one
  58082. */
  58083. export class ReplaceColorBlock extends NodeMaterialBlock {
  58084. /**
  58085. * Creates a new ReplaceColorBlock
  58086. * @param name defines the block name
  58087. */
  58088. constructor(name: string);
  58089. /**
  58090. * Gets the current class name
  58091. * @returns the class name
  58092. */
  58093. getClassName(): string;
  58094. /**
  58095. * Gets the value input component
  58096. */
  58097. readonly value: NodeMaterialConnectionPoint;
  58098. /**
  58099. * Gets the reference input component
  58100. */
  58101. readonly reference: NodeMaterialConnectionPoint;
  58102. /**
  58103. * Gets the distance input component
  58104. */
  58105. readonly distance: NodeMaterialConnectionPoint;
  58106. /**
  58107. * Gets the replacement input component
  58108. */
  58109. readonly replacement: NodeMaterialConnectionPoint;
  58110. /**
  58111. * Gets the output component
  58112. */
  58113. readonly output: NodeMaterialConnectionPoint;
  58114. protected _buildBlock(state: NodeMaterialBuildState): this;
  58115. }
  58116. }
  58117. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58118. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58119. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58120. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58121. /**
  58122. * Block used to posterize a value
  58123. * @see https://en.wikipedia.org/wiki/Posterization
  58124. */
  58125. export class PosterizeBlock extends NodeMaterialBlock {
  58126. /**
  58127. * Creates a new PosterizeBlock
  58128. * @param name defines the block name
  58129. */
  58130. constructor(name: string);
  58131. /**
  58132. * Gets the current class name
  58133. * @returns the class name
  58134. */
  58135. getClassName(): string;
  58136. /**
  58137. * Gets the value input component
  58138. */
  58139. readonly value: NodeMaterialConnectionPoint;
  58140. /**
  58141. * Gets the steps input component
  58142. */
  58143. readonly steps: NodeMaterialConnectionPoint;
  58144. /**
  58145. * Gets the output component
  58146. */
  58147. readonly output: NodeMaterialConnectionPoint;
  58148. protected _buildBlock(state: NodeMaterialBuildState): this;
  58149. }
  58150. }
  58151. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58152. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58153. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58154. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58155. import { Scene } from "babylonjs/scene";
  58156. /**
  58157. * Operations supported by the Wave block
  58158. */
  58159. export enum WaveBlockKind {
  58160. /** SawTooth */
  58161. SawTooth = 0,
  58162. /** Square */
  58163. Square = 1,
  58164. /** Triangle */
  58165. Triangle = 2
  58166. }
  58167. /**
  58168. * Block used to apply wave operation to floats
  58169. */
  58170. export class WaveBlock extends NodeMaterialBlock {
  58171. /**
  58172. * Gets or sets the kibnd of wave to be applied by the block
  58173. */
  58174. kind: WaveBlockKind;
  58175. /**
  58176. * Creates a new WaveBlock
  58177. * @param name defines the block name
  58178. */
  58179. constructor(name: string);
  58180. /**
  58181. * Gets the current class name
  58182. * @returns the class name
  58183. */
  58184. getClassName(): string;
  58185. /**
  58186. * Gets the input component
  58187. */
  58188. readonly input: NodeMaterialConnectionPoint;
  58189. /**
  58190. * Gets the output component
  58191. */
  58192. readonly output: NodeMaterialConnectionPoint;
  58193. protected _buildBlock(state: NodeMaterialBuildState): this;
  58194. serialize(): any;
  58195. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58196. }
  58197. }
  58198. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58199. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58200. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58201. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58202. import { Color3 } from "babylonjs/Maths/math.color";
  58203. import { Scene } from "babylonjs/scene";
  58204. /**
  58205. * Class used to store a color step for the GradientBlock
  58206. */
  58207. export class GradientBlockColorStep {
  58208. /**
  58209. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58210. */
  58211. step: number;
  58212. /**
  58213. * Gets or sets the color associated with this step
  58214. */
  58215. color: Color3;
  58216. /**
  58217. * Creates a new GradientBlockColorStep
  58218. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58219. * @param color defines the color associated with this step
  58220. */
  58221. constructor(
  58222. /**
  58223. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58224. */
  58225. step: number,
  58226. /**
  58227. * Gets or sets the color associated with this step
  58228. */
  58229. color: Color3);
  58230. }
  58231. /**
  58232. * Block used to return a color from a gradient based on an input value between 0 and 1
  58233. */
  58234. export class GradientBlock extends NodeMaterialBlock {
  58235. /**
  58236. * Gets or sets the list of color steps
  58237. */
  58238. colorSteps: GradientBlockColorStep[];
  58239. /**
  58240. * Creates a new GradientBlock
  58241. * @param name defines the block name
  58242. */
  58243. constructor(name: string);
  58244. /**
  58245. * Gets the current class name
  58246. * @returns the class name
  58247. */
  58248. getClassName(): string;
  58249. /**
  58250. * Gets the gradient input component
  58251. */
  58252. readonly gradient: NodeMaterialConnectionPoint;
  58253. /**
  58254. * Gets the output component
  58255. */
  58256. readonly output: NodeMaterialConnectionPoint;
  58257. private _writeColorConstant;
  58258. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58259. serialize(): any;
  58260. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58261. protected _dumpPropertiesCode(): string;
  58262. }
  58263. }
  58264. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58265. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58266. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58267. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58268. /**
  58269. * Block used to normalize lerp between 2 values
  58270. */
  58271. export class NLerpBlock extends NodeMaterialBlock {
  58272. /**
  58273. * Creates a new NLerpBlock
  58274. * @param name defines the block name
  58275. */
  58276. constructor(name: string);
  58277. /**
  58278. * Gets the current class name
  58279. * @returns the class name
  58280. */
  58281. getClassName(): string;
  58282. /**
  58283. * Gets the left operand input component
  58284. */
  58285. readonly left: NodeMaterialConnectionPoint;
  58286. /**
  58287. * Gets the right operand input component
  58288. */
  58289. readonly right: NodeMaterialConnectionPoint;
  58290. /**
  58291. * Gets the gradient operand input component
  58292. */
  58293. readonly gradient: NodeMaterialConnectionPoint;
  58294. /**
  58295. * Gets the output component
  58296. */
  58297. readonly output: NodeMaterialConnectionPoint;
  58298. protected _buildBlock(state: NodeMaterialBuildState): this;
  58299. }
  58300. }
  58301. declare module "babylonjs/Materials/Node/Blocks/index" {
  58302. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58303. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58304. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58305. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58306. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58307. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58308. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58309. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58310. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58311. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58312. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58313. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58314. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58315. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58316. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58317. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58318. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58319. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58320. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58321. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58322. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58323. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58324. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58325. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58326. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58327. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58328. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58329. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58330. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58331. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58332. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58333. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58334. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58335. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58336. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58337. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58338. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58339. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58340. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58341. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58342. }
  58343. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58344. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58345. }
  58346. declare module "babylonjs/Materials/Node/index" {
  58347. export * from "babylonjs/Materials/Node/Enums/index";
  58348. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58349. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58350. export * from "babylonjs/Materials/Node/nodeMaterial";
  58351. export * from "babylonjs/Materials/Node/Blocks/index";
  58352. export * from "babylonjs/Materials/Node/Optimizers/index";
  58353. }
  58354. declare module "babylonjs/Materials/effectRenderer" {
  58355. import { Nullable } from "babylonjs/types";
  58356. import { Texture } from "babylonjs/Materials/Textures/texture";
  58357. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58358. import { Viewport } from "babylonjs/Maths/math.viewport";
  58359. import { Observable } from "babylonjs/Misc/observable";
  58360. import { Effect } from "babylonjs/Materials/effect";
  58361. import "babylonjs/Engines/Extensions/engine.renderTarget";
  58362. import "babylonjs/Shaders/postprocess.vertex";
  58363. /**
  58364. * Effect Render Options
  58365. */
  58366. export interface IEffectRendererOptions {
  58367. /**
  58368. * Defines the vertices positions.
  58369. */
  58370. positions?: number[];
  58371. /**
  58372. * Defines the indices.
  58373. */
  58374. indices?: number[];
  58375. }
  58376. /**
  58377. * Helper class to render one or more effects
  58378. */
  58379. export class EffectRenderer {
  58380. private engine;
  58381. private static _DefaultOptions;
  58382. private _vertexBuffers;
  58383. private _indexBuffer;
  58384. private _ringBufferIndex;
  58385. private _ringScreenBuffer;
  58386. private _fullscreenViewport;
  58387. private _getNextFrameBuffer;
  58388. /**
  58389. * Creates an effect renderer
  58390. * @param engine the engine to use for rendering
  58391. * @param options defines the options of the effect renderer
  58392. */
  58393. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58394. /**
  58395. * Sets the current viewport in normalized coordinates 0-1
  58396. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58397. */
  58398. setViewport(viewport?: Viewport): void;
  58399. /**
  58400. * Binds the embedded attributes buffer to the effect.
  58401. * @param effect Defines the effect to bind the attributes for
  58402. */
  58403. bindBuffers(effect: Effect): void;
  58404. /**
  58405. * Sets the current effect wrapper to use during draw.
  58406. * The effect needs to be ready before calling this api.
  58407. * This also sets the default full screen position attribute.
  58408. * @param effectWrapper Defines the effect to draw with
  58409. */
  58410. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58411. /**
  58412. * Draws a full screen quad.
  58413. */
  58414. draw(): void;
  58415. /**
  58416. * renders one or more effects to a specified texture
  58417. * @param effectWrappers list of effects to renderer
  58418. * @param outputTexture texture to draw to, if null it will render to the screen
  58419. */
  58420. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58421. /**
  58422. * Disposes of the effect renderer
  58423. */
  58424. dispose(): void;
  58425. }
  58426. /**
  58427. * Options to create an EffectWrapper
  58428. */
  58429. interface EffectWrapperCreationOptions {
  58430. /**
  58431. * Engine to use to create the effect
  58432. */
  58433. engine: ThinEngine;
  58434. /**
  58435. * Fragment shader for the effect
  58436. */
  58437. fragmentShader: string;
  58438. /**
  58439. * Vertex shader for the effect
  58440. */
  58441. vertexShader?: string;
  58442. /**
  58443. * Attributes to use in the shader
  58444. */
  58445. attributeNames?: Array<string>;
  58446. /**
  58447. * Uniforms to use in the shader
  58448. */
  58449. uniformNames?: Array<string>;
  58450. /**
  58451. * Texture sampler names to use in the shader
  58452. */
  58453. samplerNames?: Array<string>;
  58454. /**
  58455. * The friendly name of the effect displayed in Spector.
  58456. */
  58457. name?: string;
  58458. }
  58459. /**
  58460. * Wraps an effect to be used for rendering
  58461. */
  58462. export class EffectWrapper {
  58463. /**
  58464. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58465. */
  58466. onApplyObservable: Observable<{}>;
  58467. /**
  58468. * The underlying effect
  58469. */
  58470. effect: Effect;
  58471. /**
  58472. * Creates an effect to be renderer
  58473. * @param creationOptions options to create the effect
  58474. */
  58475. constructor(creationOptions: EffectWrapperCreationOptions);
  58476. /**
  58477. * Disposes of the effect wrapper
  58478. */
  58479. dispose(): void;
  58480. }
  58481. }
  58482. declare module "babylonjs/Materials/index" {
  58483. export * from "babylonjs/Materials/Background/index";
  58484. export * from "babylonjs/Materials/colorCurves";
  58485. export * from "babylonjs/Materials/iEffectFallbacks";
  58486. export * from "babylonjs/Materials/effectFallbacks";
  58487. export * from "babylonjs/Materials/effect";
  58488. export * from "babylonjs/Materials/fresnelParameters";
  58489. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58490. export * from "babylonjs/Materials/material";
  58491. export * from "babylonjs/Materials/materialDefines";
  58492. export * from "babylonjs/Materials/materialHelper";
  58493. export * from "babylonjs/Materials/multiMaterial";
  58494. export * from "babylonjs/Materials/PBR/index";
  58495. export * from "babylonjs/Materials/pushMaterial";
  58496. export * from "babylonjs/Materials/shaderMaterial";
  58497. export * from "babylonjs/Materials/standardMaterial";
  58498. export * from "babylonjs/Materials/Textures/index";
  58499. export * from "babylonjs/Materials/uniformBuffer";
  58500. export * from "babylonjs/Materials/materialFlags";
  58501. export * from "babylonjs/Materials/Node/index";
  58502. export * from "babylonjs/Materials/effectRenderer";
  58503. }
  58504. declare module "babylonjs/Maths/index" {
  58505. export * from "babylonjs/Maths/math.scalar";
  58506. export * from "babylonjs/Maths/math";
  58507. export * from "babylonjs/Maths/sphericalPolynomial";
  58508. }
  58509. declare module "babylonjs/Misc/workerPool" {
  58510. import { IDisposable } from "babylonjs/scene";
  58511. /**
  58512. * Helper class to push actions to a pool of workers.
  58513. */
  58514. export class WorkerPool implements IDisposable {
  58515. private _workerInfos;
  58516. private _pendingActions;
  58517. /**
  58518. * Constructor
  58519. * @param workers Array of workers to use for actions
  58520. */
  58521. constructor(workers: Array<Worker>);
  58522. /**
  58523. * Terminates all workers and clears any pending actions.
  58524. */
  58525. dispose(): void;
  58526. /**
  58527. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58528. * pended until a worker has completed its action.
  58529. * @param action The action to perform. Call onComplete when the action is complete.
  58530. */
  58531. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58532. private _execute;
  58533. }
  58534. }
  58535. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58536. import { IDisposable } from "babylonjs/scene";
  58537. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58538. /**
  58539. * Configuration for Draco compression
  58540. */
  58541. export interface IDracoCompressionConfiguration {
  58542. /**
  58543. * Configuration for the decoder.
  58544. */
  58545. decoder: {
  58546. /**
  58547. * The url to the WebAssembly module.
  58548. */
  58549. wasmUrl?: string;
  58550. /**
  58551. * The url to the WebAssembly binary.
  58552. */
  58553. wasmBinaryUrl?: string;
  58554. /**
  58555. * The url to the fallback JavaScript module.
  58556. */
  58557. fallbackUrl?: string;
  58558. };
  58559. }
  58560. /**
  58561. * Draco compression (https://google.github.io/draco/)
  58562. *
  58563. * This class wraps the Draco module.
  58564. *
  58565. * **Encoder**
  58566. *
  58567. * The encoder is not currently implemented.
  58568. *
  58569. * **Decoder**
  58570. *
  58571. * 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.
  58572. *
  58573. * To update the configuration, use the following code:
  58574. * ```javascript
  58575. * DracoCompression.Configuration = {
  58576. * decoder: {
  58577. * wasmUrl: "<url to the WebAssembly library>",
  58578. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58579. * fallbackUrl: "<url to the fallback JavaScript library>",
  58580. * }
  58581. * };
  58582. * ```
  58583. *
  58584. * 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.
  58585. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58586. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58587. *
  58588. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58589. * ```javascript
  58590. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58591. * ```
  58592. *
  58593. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58594. */
  58595. export class DracoCompression implements IDisposable {
  58596. private _workerPoolPromise?;
  58597. private _decoderModulePromise?;
  58598. /**
  58599. * The configuration. Defaults to the following urls:
  58600. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58601. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58602. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58603. */
  58604. static Configuration: IDracoCompressionConfiguration;
  58605. /**
  58606. * Returns true if the decoder configuration is available.
  58607. */
  58608. static readonly DecoderAvailable: boolean;
  58609. /**
  58610. * Default number of workers to create when creating the draco compression object.
  58611. */
  58612. static DefaultNumWorkers: number;
  58613. private static GetDefaultNumWorkers;
  58614. private static _Default;
  58615. /**
  58616. * Default instance for the draco compression object.
  58617. */
  58618. static readonly Default: DracoCompression;
  58619. /**
  58620. * Constructor
  58621. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58622. */
  58623. constructor(numWorkers?: number);
  58624. /**
  58625. * Stop all async operations and release resources.
  58626. */
  58627. dispose(): void;
  58628. /**
  58629. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58630. * @returns a promise that resolves when ready
  58631. */
  58632. whenReadyAsync(): Promise<void>;
  58633. /**
  58634. * Decode Draco compressed mesh data to vertex data.
  58635. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58636. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58637. * @returns A promise that resolves with the decoded vertex data
  58638. */
  58639. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58640. [kind: string]: number;
  58641. }): Promise<VertexData>;
  58642. }
  58643. }
  58644. declare module "babylonjs/Meshes/Compression/index" {
  58645. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58646. }
  58647. declare module "babylonjs/Meshes/csg" {
  58648. import { Nullable } from "babylonjs/types";
  58649. import { Scene } from "babylonjs/scene";
  58650. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58651. import { Mesh } from "babylonjs/Meshes/mesh";
  58652. import { Material } from "babylonjs/Materials/material";
  58653. /**
  58654. * Class for building Constructive Solid Geometry
  58655. */
  58656. export class CSG {
  58657. private polygons;
  58658. /**
  58659. * The world matrix
  58660. */
  58661. matrix: Matrix;
  58662. /**
  58663. * Stores the position
  58664. */
  58665. position: Vector3;
  58666. /**
  58667. * Stores the rotation
  58668. */
  58669. rotation: Vector3;
  58670. /**
  58671. * Stores the rotation quaternion
  58672. */
  58673. rotationQuaternion: Nullable<Quaternion>;
  58674. /**
  58675. * Stores the scaling vector
  58676. */
  58677. scaling: Vector3;
  58678. /**
  58679. * Convert the Mesh to CSG
  58680. * @param mesh The Mesh to convert to CSG
  58681. * @returns A new CSG from the Mesh
  58682. */
  58683. static FromMesh(mesh: Mesh): CSG;
  58684. /**
  58685. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58686. * @param polygons Polygons used to construct a CSG solid
  58687. */
  58688. private static FromPolygons;
  58689. /**
  58690. * Clones, or makes a deep copy, of the CSG
  58691. * @returns A new CSG
  58692. */
  58693. clone(): CSG;
  58694. /**
  58695. * Unions this CSG with another CSG
  58696. * @param csg The CSG to union against this CSG
  58697. * @returns The unioned CSG
  58698. */
  58699. union(csg: CSG): CSG;
  58700. /**
  58701. * Unions this CSG with another CSG in place
  58702. * @param csg The CSG to union against this CSG
  58703. */
  58704. unionInPlace(csg: CSG): void;
  58705. /**
  58706. * Subtracts this CSG with another CSG
  58707. * @param csg The CSG to subtract against this CSG
  58708. * @returns A new CSG
  58709. */
  58710. subtract(csg: CSG): CSG;
  58711. /**
  58712. * Subtracts this CSG with another CSG in place
  58713. * @param csg The CSG to subtact against this CSG
  58714. */
  58715. subtractInPlace(csg: CSG): void;
  58716. /**
  58717. * Intersect this CSG with another CSG
  58718. * @param csg The CSG to intersect against this CSG
  58719. * @returns A new CSG
  58720. */
  58721. intersect(csg: CSG): CSG;
  58722. /**
  58723. * Intersects this CSG with another CSG in place
  58724. * @param csg The CSG to intersect against this CSG
  58725. */
  58726. intersectInPlace(csg: CSG): void;
  58727. /**
  58728. * Return a new CSG solid with solid and empty space switched. This solid is
  58729. * not modified.
  58730. * @returns A new CSG solid with solid and empty space switched
  58731. */
  58732. inverse(): CSG;
  58733. /**
  58734. * Inverses the CSG in place
  58735. */
  58736. inverseInPlace(): void;
  58737. /**
  58738. * This is used to keep meshes transformations so they can be restored
  58739. * when we build back a Babylon Mesh
  58740. * NB : All CSG operations are performed in world coordinates
  58741. * @param csg The CSG to copy the transform attributes from
  58742. * @returns This CSG
  58743. */
  58744. copyTransformAttributes(csg: CSG): CSG;
  58745. /**
  58746. * Build Raw mesh from CSG
  58747. * Coordinates here are in world space
  58748. * @param name The name of the mesh geometry
  58749. * @param scene The Scene
  58750. * @param keepSubMeshes Specifies if the submeshes should be kept
  58751. * @returns A new Mesh
  58752. */
  58753. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58754. /**
  58755. * Build Mesh from CSG taking material and transforms into account
  58756. * @param name The name of the Mesh
  58757. * @param material The material of the Mesh
  58758. * @param scene The Scene
  58759. * @param keepSubMeshes Specifies if submeshes should be kept
  58760. * @returns The new Mesh
  58761. */
  58762. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58763. }
  58764. }
  58765. declare module "babylonjs/Meshes/trailMesh" {
  58766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58767. import { Mesh } from "babylonjs/Meshes/mesh";
  58768. import { Scene } from "babylonjs/scene";
  58769. /**
  58770. * Class used to create a trail following a mesh
  58771. */
  58772. export class TrailMesh extends Mesh {
  58773. private _generator;
  58774. private _autoStart;
  58775. private _running;
  58776. private _diameter;
  58777. private _length;
  58778. private _sectionPolygonPointsCount;
  58779. private _sectionVectors;
  58780. private _sectionNormalVectors;
  58781. private _beforeRenderObserver;
  58782. /**
  58783. * @constructor
  58784. * @param name The value used by scene.getMeshByName() to do a lookup.
  58785. * @param generator The mesh to generate a trail.
  58786. * @param scene The scene to add this mesh to.
  58787. * @param diameter Diameter of trailing mesh. Default is 1.
  58788. * @param length Length of trailing mesh. Default is 60.
  58789. * @param autoStart Automatically start trailing mesh. Default true.
  58790. */
  58791. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58792. /**
  58793. * "TrailMesh"
  58794. * @returns "TrailMesh"
  58795. */
  58796. getClassName(): string;
  58797. private _createMesh;
  58798. /**
  58799. * Start trailing mesh.
  58800. */
  58801. start(): void;
  58802. /**
  58803. * Stop trailing mesh.
  58804. */
  58805. stop(): void;
  58806. /**
  58807. * Update trailing mesh geometry.
  58808. */
  58809. update(): void;
  58810. /**
  58811. * Returns a new TrailMesh object.
  58812. * @param name is a string, the name given to the new mesh
  58813. * @param newGenerator use new generator object for cloned trail mesh
  58814. * @returns a new mesh
  58815. */
  58816. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58817. /**
  58818. * Serializes this trail mesh
  58819. * @param serializationObject object to write serialization to
  58820. */
  58821. serialize(serializationObject: any): void;
  58822. /**
  58823. * Parses a serialized trail mesh
  58824. * @param parsedMesh the serialized mesh
  58825. * @param scene the scene to create the trail mesh in
  58826. * @returns the created trail mesh
  58827. */
  58828. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58829. }
  58830. }
  58831. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58832. import { Nullable } from "babylonjs/types";
  58833. import { Scene } from "babylonjs/scene";
  58834. import { Vector4 } from "babylonjs/Maths/math.vector";
  58835. import { Color4 } from "babylonjs/Maths/math.color";
  58836. import { Mesh } from "babylonjs/Meshes/mesh";
  58837. /**
  58838. * Class containing static functions to help procedurally build meshes
  58839. */
  58840. export class TiledBoxBuilder {
  58841. /**
  58842. * Creates a box mesh
  58843. * 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)
  58844. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58846. * * 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
  58847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58848. * @param name defines the name of the mesh
  58849. * @param options defines the options used to create the mesh
  58850. * @param scene defines the hosting scene
  58851. * @returns the box mesh
  58852. */
  58853. static CreateTiledBox(name: string, options: {
  58854. pattern?: number;
  58855. width?: number;
  58856. height?: number;
  58857. depth?: number;
  58858. tileSize?: number;
  58859. tileWidth?: number;
  58860. tileHeight?: number;
  58861. alignHorizontal?: number;
  58862. alignVertical?: number;
  58863. faceUV?: Vector4[];
  58864. faceColors?: Color4[];
  58865. sideOrientation?: number;
  58866. updatable?: boolean;
  58867. }, scene?: Nullable<Scene>): Mesh;
  58868. }
  58869. }
  58870. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58871. import { Vector4 } from "babylonjs/Maths/math.vector";
  58872. import { Mesh } from "babylonjs/Meshes/mesh";
  58873. /**
  58874. * Class containing static functions to help procedurally build meshes
  58875. */
  58876. export class TorusKnotBuilder {
  58877. /**
  58878. * Creates a torus knot mesh
  58879. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58880. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58881. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58882. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58884. * * 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
  58885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58886. * @param name defines the name of the mesh
  58887. * @param options defines the options used to create the mesh
  58888. * @param scene defines the hosting scene
  58889. * @returns the torus knot mesh
  58890. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58891. */
  58892. static CreateTorusKnot(name: string, options: {
  58893. radius?: number;
  58894. tube?: number;
  58895. radialSegments?: number;
  58896. tubularSegments?: number;
  58897. p?: number;
  58898. q?: number;
  58899. updatable?: boolean;
  58900. sideOrientation?: number;
  58901. frontUVs?: Vector4;
  58902. backUVs?: Vector4;
  58903. }, scene: any): Mesh;
  58904. }
  58905. }
  58906. declare module "babylonjs/Meshes/polygonMesh" {
  58907. import { Scene } from "babylonjs/scene";
  58908. import { Vector2 } from "babylonjs/Maths/math.vector";
  58909. import { Mesh } from "babylonjs/Meshes/mesh";
  58910. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58911. import { Path2 } from "babylonjs/Maths/math.path";
  58912. /**
  58913. * Polygon
  58914. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58915. */
  58916. export class Polygon {
  58917. /**
  58918. * Creates a rectangle
  58919. * @param xmin bottom X coord
  58920. * @param ymin bottom Y coord
  58921. * @param xmax top X coord
  58922. * @param ymax top Y coord
  58923. * @returns points that make the resulting rectation
  58924. */
  58925. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58926. /**
  58927. * Creates a circle
  58928. * @param radius radius of circle
  58929. * @param cx scale in x
  58930. * @param cy scale in y
  58931. * @param numberOfSides number of sides that make up the circle
  58932. * @returns points that make the resulting circle
  58933. */
  58934. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58935. /**
  58936. * Creates a polygon from input string
  58937. * @param input Input polygon data
  58938. * @returns the parsed points
  58939. */
  58940. static Parse(input: string): Vector2[];
  58941. /**
  58942. * Starts building a polygon from x and y coordinates
  58943. * @param x x coordinate
  58944. * @param y y coordinate
  58945. * @returns the started path2
  58946. */
  58947. static StartingAt(x: number, y: number): Path2;
  58948. }
  58949. /**
  58950. * Builds a polygon
  58951. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58952. */
  58953. export class PolygonMeshBuilder {
  58954. private _points;
  58955. private _outlinepoints;
  58956. private _holes;
  58957. private _name;
  58958. private _scene;
  58959. private _epoints;
  58960. private _eholes;
  58961. private _addToepoint;
  58962. /**
  58963. * Babylon reference to the earcut plugin.
  58964. */
  58965. bjsEarcut: any;
  58966. /**
  58967. * Creates a PolygonMeshBuilder
  58968. * @param name name of the builder
  58969. * @param contours Path of the polygon
  58970. * @param scene scene to add to when creating the mesh
  58971. * @param earcutInjection can be used to inject your own earcut reference
  58972. */
  58973. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58974. /**
  58975. * Adds a whole within the polygon
  58976. * @param hole Array of points defining the hole
  58977. * @returns this
  58978. */
  58979. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58980. /**
  58981. * Creates the polygon
  58982. * @param updatable If the mesh should be updatable
  58983. * @param depth The depth of the mesh created
  58984. * @returns the created mesh
  58985. */
  58986. build(updatable?: boolean, depth?: number): Mesh;
  58987. /**
  58988. * Creates the polygon
  58989. * @param depth The depth of the mesh created
  58990. * @returns the created VertexData
  58991. */
  58992. buildVertexData(depth?: number): VertexData;
  58993. /**
  58994. * Adds a side to the polygon
  58995. * @param positions points that make the polygon
  58996. * @param normals normals of the polygon
  58997. * @param uvs uvs of the polygon
  58998. * @param indices indices of the polygon
  58999. * @param bounds bounds of the polygon
  59000. * @param points points of the polygon
  59001. * @param depth depth of the polygon
  59002. * @param flip flip of the polygon
  59003. */
  59004. private addSide;
  59005. }
  59006. }
  59007. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59008. import { Scene } from "babylonjs/scene";
  59009. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59010. import { Color4 } from "babylonjs/Maths/math.color";
  59011. import { Mesh } from "babylonjs/Meshes/mesh";
  59012. import { Nullable } from "babylonjs/types";
  59013. /**
  59014. * Class containing static functions to help procedurally build meshes
  59015. */
  59016. export class PolygonBuilder {
  59017. /**
  59018. * Creates a polygon mesh
  59019. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59020. * * 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
  59021. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59023. * * 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)
  59024. * * Remember you can only change the shape positions, not their number when updating a polygon
  59025. * @param name defines the name of the mesh
  59026. * @param options defines the options used to create the mesh
  59027. * @param scene defines the hosting scene
  59028. * @param earcutInjection can be used to inject your own earcut reference
  59029. * @returns the polygon mesh
  59030. */
  59031. static CreatePolygon(name: string, options: {
  59032. shape: Vector3[];
  59033. holes?: Vector3[][];
  59034. depth?: number;
  59035. faceUV?: Vector4[];
  59036. faceColors?: Color4[];
  59037. updatable?: boolean;
  59038. sideOrientation?: number;
  59039. frontUVs?: Vector4;
  59040. backUVs?: Vector4;
  59041. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59042. /**
  59043. * Creates an extruded polygon mesh, with depth in the Y direction.
  59044. * * 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)
  59045. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59046. * @param name defines the name of the mesh
  59047. * @param options defines the options used to create the mesh
  59048. * @param scene defines the hosting scene
  59049. * @param earcutInjection can be used to inject your own earcut reference
  59050. * @returns the polygon mesh
  59051. */
  59052. static ExtrudePolygon(name: string, options: {
  59053. shape: Vector3[];
  59054. holes?: Vector3[][];
  59055. depth?: number;
  59056. faceUV?: Vector4[];
  59057. faceColors?: Color4[];
  59058. updatable?: boolean;
  59059. sideOrientation?: number;
  59060. frontUVs?: Vector4;
  59061. backUVs?: Vector4;
  59062. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59063. }
  59064. }
  59065. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59066. import { Scene } from "babylonjs/scene";
  59067. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59068. import { Mesh } from "babylonjs/Meshes/mesh";
  59069. import { Nullable } from "babylonjs/types";
  59070. /**
  59071. * Class containing static functions to help procedurally build meshes
  59072. */
  59073. export class LatheBuilder {
  59074. /**
  59075. * Creates lathe mesh.
  59076. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59077. * * 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
  59078. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59079. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59080. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59081. * * 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
  59082. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59083. * * 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
  59084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59085. * * 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
  59086. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59088. * @param name defines the name of the mesh
  59089. * @param options defines the options used to create the mesh
  59090. * @param scene defines the hosting scene
  59091. * @returns the lathe mesh
  59092. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59093. */
  59094. static CreateLathe(name: string, options: {
  59095. shape: Vector3[];
  59096. radius?: number;
  59097. tessellation?: number;
  59098. clip?: number;
  59099. arc?: number;
  59100. closed?: boolean;
  59101. updatable?: boolean;
  59102. sideOrientation?: number;
  59103. frontUVs?: Vector4;
  59104. backUVs?: Vector4;
  59105. cap?: number;
  59106. invertUV?: boolean;
  59107. }, scene?: Nullable<Scene>): Mesh;
  59108. }
  59109. }
  59110. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59111. import { Nullable } from "babylonjs/types";
  59112. import { Scene } from "babylonjs/scene";
  59113. import { Vector4 } from "babylonjs/Maths/math.vector";
  59114. import { Mesh } from "babylonjs/Meshes/mesh";
  59115. /**
  59116. * Class containing static functions to help procedurally build meshes
  59117. */
  59118. export class TiledPlaneBuilder {
  59119. /**
  59120. * Creates a tiled plane mesh
  59121. * * The parameter `pattern` will, depending on value, do nothing or
  59122. * * * flip (reflect about central vertical) alternate tiles across and up
  59123. * * * flip every tile on alternate rows
  59124. * * * rotate (180 degs) alternate tiles across and up
  59125. * * * rotate every tile on alternate rows
  59126. * * * flip and rotate alternate tiles across and up
  59127. * * * flip and rotate every tile on alternate rows
  59128. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59129. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59130. * * 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
  59131. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59132. * * 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)
  59133. * * 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)
  59134. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59135. * @param name defines the name of the mesh
  59136. * @param options defines the options used to create the mesh
  59137. * @param scene defines the hosting scene
  59138. * @returns the box mesh
  59139. */
  59140. static CreateTiledPlane(name: string, options: {
  59141. pattern?: number;
  59142. tileSize?: number;
  59143. tileWidth?: number;
  59144. tileHeight?: number;
  59145. size?: number;
  59146. width?: number;
  59147. height?: number;
  59148. alignHorizontal?: number;
  59149. alignVertical?: number;
  59150. sideOrientation?: number;
  59151. frontUVs?: Vector4;
  59152. backUVs?: Vector4;
  59153. updatable?: boolean;
  59154. }, scene?: Nullable<Scene>): Mesh;
  59155. }
  59156. }
  59157. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59158. import { Nullable } from "babylonjs/types";
  59159. import { Scene } from "babylonjs/scene";
  59160. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59161. import { Mesh } from "babylonjs/Meshes/mesh";
  59162. /**
  59163. * Class containing static functions to help procedurally build meshes
  59164. */
  59165. export class TubeBuilder {
  59166. /**
  59167. * Creates a tube mesh.
  59168. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59169. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59170. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59171. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59172. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59173. * * 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)
  59174. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59175. * * 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
  59176. * * 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
  59177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59178. * * 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
  59179. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59181. * @param name defines the name of the mesh
  59182. * @param options defines the options used to create the mesh
  59183. * @param scene defines the hosting scene
  59184. * @returns the tube mesh
  59185. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59186. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59187. */
  59188. static CreateTube(name: string, options: {
  59189. path: Vector3[];
  59190. radius?: number;
  59191. tessellation?: number;
  59192. radiusFunction?: {
  59193. (i: number, distance: number): number;
  59194. };
  59195. cap?: number;
  59196. arc?: number;
  59197. updatable?: boolean;
  59198. sideOrientation?: number;
  59199. frontUVs?: Vector4;
  59200. backUVs?: Vector4;
  59201. instance?: Mesh;
  59202. invertUV?: boolean;
  59203. }, scene?: Nullable<Scene>): Mesh;
  59204. }
  59205. }
  59206. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59207. import { Scene } from "babylonjs/scene";
  59208. import { Vector4 } from "babylonjs/Maths/math.vector";
  59209. import { Mesh } from "babylonjs/Meshes/mesh";
  59210. import { Nullable } from "babylonjs/types";
  59211. /**
  59212. * Class containing static functions to help procedurally build meshes
  59213. */
  59214. export class IcoSphereBuilder {
  59215. /**
  59216. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59217. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59218. * * 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`)
  59219. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59220. * * 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
  59221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59222. * * 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
  59223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59224. * @param name defines the name of the mesh
  59225. * @param options defines the options used to create the mesh
  59226. * @param scene defines the hosting scene
  59227. * @returns the icosahedron mesh
  59228. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59229. */
  59230. static CreateIcoSphere(name: string, options: {
  59231. radius?: number;
  59232. radiusX?: number;
  59233. radiusY?: number;
  59234. radiusZ?: number;
  59235. flat?: boolean;
  59236. subdivisions?: number;
  59237. sideOrientation?: number;
  59238. frontUVs?: Vector4;
  59239. backUVs?: Vector4;
  59240. updatable?: boolean;
  59241. }, scene?: Nullable<Scene>): Mesh;
  59242. }
  59243. }
  59244. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59245. import { Vector3 } from "babylonjs/Maths/math.vector";
  59246. import { Mesh } from "babylonjs/Meshes/mesh";
  59247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59248. /**
  59249. * Class containing static functions to help procedurally build meshes
  59250. */
  59251. export class DecalBuilder {
  59252. /**
  59253. * Creates a decal mesh.
  59254. * 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
  59255. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59256. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59257. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59258. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59259. * @param name defines the name of the mesh
  59260. * @param sourceMesh defines the mesh where the decal must be applied
  59261. * @param options defines the options used to create the mesh
  59262. * @param scene defines the hosting scene
  59263. * @returns the decal mesh
  59264. * @see https://doc.babylonjs.com/how_to/decals
  59265. */
  59266. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59267. position?: Vector3;
  59268. normal?: Vector3;
  59269. size?: Vector3;
  59270. angle?: number;
  59271. }): Mesh;
  59272. }
  59273. }
  59274. declare module "babylonjs/Meshes/meshBuilder" {
  59275. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59276. import { Nullable } from "babylonjs/types";
  59277. import { Scene } from "babylonjs/scene";
  59278. import { Mesh } from "babylonjs/Meshes/mesh";
  59279. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59280. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59282. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59283. import { Plane } from "babylonjs/Maths/math.plane";
  59284. /**
  59285. * Class containing static functions to help procedurally build meshes
  59286. */
  59287. export class MeshBuilder {
  59288. /**
  59289. * Creates a box mesh
  59290. * * The parameter `size` sets the size (float) of each box side (default 1)
  59291. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59292. * * 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)
  59293. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59295. * * 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
  59296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59297. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59298. * @param name defines the name of the mesh
  59299. * @param options defines the options used to create the mesh
  59300. * @param scene defines the hosting scene
  59301. * @returns the box mesh
  59302. */
  59303. static CreateBox(name: string, options: {
  59304. size?: number;
  59305. width?: number;
  59306. height?: number;
  59307. depth?: number;
  59308. faceUV?: Vector4[];
  59309. faceColors?: Color4[];
  59310. sideOrientation?: number;
  59311. frontUVs?: Vector4;
  59312. backUVs?: Vector4;
  59313. updatable?: boolean;
  59314. }, scene?: Nullable<Scene>): Mesh;
  59315. /**
  59316. * Creates a tiled box mesh
  59317. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59319. * @param name defines the name of the mesh
  59320. * @param options defines the options used to create the mesh
  59321. * @param scene defines the hosting scene
  59322. * @returns the tiled box mesh
  59323. */
  59324. static CreateTiledBox(name: string, options: {
  59325. pattern?: number;
  59326. size?: number;
  59327. width?: number;
  59328. height?: number;
  59329. depth: number;
  59330. tileSize?: number;
  59331. tileWidth?: number;
  59332. tileHeight?: number;
  59333. faceUV?: Vector4[];
  59334. faceColors?: Color4[];
  59335. alignHorizontal?: number;
  59336. alignVertical?: number;
  59337. sideOrientation?: number;
  59338. updatable?: boolean;
  59339. }, scene?: Nullable<Scene>): Mesh;
  59340. /**
  59341. * Creates a sphere mesh
  59342. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59343. * * 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`)
  59344. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59345. * * 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
  59346. * * 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)
  59347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59348. * * 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
  59349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59350. * @param name defines the name of the mesh
  59351. * @param options defines the options used to create the mesh
  59352. * @param scene defines the hosting scene
  59353. * @returns the sphere mesh
  59354. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59355. */
  59356. static CreateSphere(name: string, options: {
  59357. segments?: number;
  59358. diameter?: number;
  59359. diameterX?: number;
  59360. diameterY?: number;
  59361. diameterZ?: number;
  59362. arc?: number;
  59363. slice?: number;
  59364. sideOrientation?: number;
  59365. frontUVs?: Vector4;
  59366. backUVs?: Vector4;
  59367. updatable?: boolean;
  59368. }, scene?: Nullable<Scene>): Mesh;
  59369. /**
  59370. * Creates a plane polygonal mesh. By default, this is a disc
  59371. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59372. * * 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
  59373. * * 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
  59374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59375. * * 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
  59376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59377. * @param name defines the name of the mesh
  59378. * @param options defines the options used to create the mesh
  59379. * @param scene defines the hosting scene
  59380. * @returns the plane polygonal mesh
  59381. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59382. */
  59383. static CreateDisc(name: string, options: {
  59384. radius?: number;
  59385. tessellation?: number;
  59386. arc?: number;
  59387. updatable?: boolean;
  59388. sideOrientation?: number;
  59389. frontUVs?: Vector4;
  59390. backUVs?: Vector4;
  59391. }, scene?: Nullable<Scene>): Mesh;
  59392. /**
  59393. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59394. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59395. * * 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`)
  59396. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59397. * * 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
  59398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59399. * * 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
  59400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59401. * @param name defines the name of the mesh
  59402. * @param options defines the options used to create the mesh
  59403. * @param scene defines the hosting scene
  59404. * @returns the icosahedron mesh
  59405. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59406. */
  59407. static CreateIcoSphere(name: string, options: {
  59408. radius?: number;
  59409. radiusX?: number;
  59410. radiusY?: number;
  59411. radiusZ?: number;
  59412. flat?: boolean;
  59413. subdivisions?: number;
  59414. sideOrientation?: number;
  59415. frontUVs?: Vector4;
  59416. backUVs?: Vector4;
  59417. updatable?: boolean;
  59418. }, scene?: Nullable<Scene>): Mesh;
  59419. /**
  59420. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59421. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59422. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59423. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59424. * * 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
  59425. * * 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
  59426. * * 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
  59427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59428. * * 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
  59429. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59430. * * 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
  59431. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59432. * * 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
  59433. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59435. * @param name defines the name of the mesh
  59436. * @param options defines the options used to create the mesh
  59437. * @param scene defines the hosting scene
  59438. * @returns the ribbon mesh
  59439. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59440. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59441. */
  59442. static CreateRibbon(name: string, options: {
  59443. pathArray: Vector3[][];
  59444. closeArray?: boolean;
  59445. closePath?: boolean;
  59446. offset?: number;
  59447. updatable?: boolean;
  59448. sideOrientation?: number;
  59449. frontUVs?: Vector4;
  59450. backUVs?: Vector4;
  59451. instance?: Mesh;
  59452. invertUV?: boolean;
  59453. uvs?: Vector2[];
  59454. colors?: Color4[];
  59455. }, scene?: Nullable<Scene>): Mesh;
  59456. /**
  59457. * Creates a cylinder or a cone mesh
  59458. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59459. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59460. * * 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.
  59461. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59462. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59463. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59464. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59465. * * 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).
  59466. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59467. * * 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).
  59468. * * 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
  59469. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59470. * * 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
  59471. * * 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.
  59472. * * If `enclose` is false, a ring surface is one element.
  59473. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59474. * * 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
  59475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59476. * * 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
  59477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59478. * @param name defines the name of the mesh
  59479. * @param options defines the options used to create the mesh
  59480. * @param scene defines the hosting scene
  59481. * @returns the cylinder mesh
  59482. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59483. */
  59484. static CreateCylinder(name: string, options: {
  59485. height?: number;
  59486. diameterTop?: number;
  59487. diameterBottom?: number;
  59488. diameter?: number;
  59489. tessellation?: number;
  59490. subdivisions?: number;
  59491. arc?: number;
  59492. faceColors?: Color4[];
  59493. faceUV?: Vector4[];
  59494. updatable?: boolean;
  59495. hasRings?: boolean;
  59496. enclose?: boolean;
  59497. cap?: number;
  59498. sideOrientation?: number;
  59499. frontUVs?: Vector4;
  59500. backUVs?: Vector4;
  59501. }, scene?: Nullable<Scene>): Mesh;
  59502. /**
  59503. * Creates a torus mesh
  59504. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59505. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59506. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59508. * * 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
  59509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59510. * @param name defines the name of the mesh
  59511. * @param options defines the options used to create the mesh
  59512. * @param scene defines the hosting scene
  59513. * @returns the torus mesh
  59514. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59515. */
  59516. static CreateTorus(name: string, options: {
  59517. diameter?: number;
  59518. thickness?: number;
  59519. tessellation?: number;
  59520. updatable?: boolean;
  59521. sideOrientation?: number;
  59522. frontUVs?: Vector4;
  59523. backUVs?: Vector4;
  59524. }, scene?: Nullable<Scene>): Mesh;
  59525. /**
  59526. * Creates a torus knot mesh
  59527. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59528. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59529. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59530. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59532. * * 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
  59533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59534. * @param name defines the name of the mesh
  59535. * @param options defines the options used to create the mesh
  59536. * @param scene defines the hosting scene
  59537. * @returns the torus knot mesh
  59538. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59539. */
  59540. static CreateTorusKnot(name: string, options: {
  59541. radius?: number;
  59542. tube?: number;
  59543. radialSegments?: number;
  59544. tubularSegments?: number;
  59545. p?: number;
  59546. q?: number;
  59547. updatable?: boolean;
  59548. sideOrientation?: number;
  59549. frontUVs?: Vector4;
  59550. backUVs?: Vector4;
  59551. }, scene?: Nullable<Scene>): Mesh;
  59552. /**
  59553. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59554. * * 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
  59555. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59556. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59557. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59558. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59559. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59560. * * 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
  59561. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59563. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59564. * @param name defines the name of the new line system
  59565. * @param options defines the options used to create the line system
  59566. * @param scene defines the hosting scene
  59567. * @returns a new line system mesh
  59568. */
  59569. static CreateLineSystem(name: string, options: {
  59570. lines: Vector3[][];
  59571. updatable?: boolean;
  59572. instance?: Nullable<LinesMesh>;
  59573. colors?: Nullable<Color4[][]>;
  59574. useVertexAlpha?: boolean;
  59575. }, scene: Nullable<Scene>): LinesMesh;
  59576. /**
  59577. * Creates a line mesh
  59578. * 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
  59579. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59580. * * The parameter `points` is an array successive Vector3
  59581. * * 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
  59582. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59583. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59584. * * When updating an instance, remember that only point positions can change, not the number of points
  59585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59586. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59587. * @param name defines the name of the new line system
  59588. * @param options defines the options used to create the line system
  59589. * @param scene defines the hosting scene
  59590. * @returns a new line mesh
  59591. */
  59592. static CreateLines(name: string, options: {
  59593. points: Vector3[];
  59594. updatable?: boolean;
  59595. instance?: Nullable<LinesMesh>;
  59596. colors?: Color4[];
  59597. useVertexAlpha?: boolean;
  59598. }, scene?: Nullable<Scene>): LinesMesh;
  59599. /**
  59600. * Creates a dashed line mesh
  59601. * * 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
  59602. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59603. * * The parameter `points` is an array successive Vector3
  59604. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59605. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59606. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59607. * * 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
  59608. * * When updating an instance, remember that only point positions can change, not the number of points
  59609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59610. * @param name defines the name of the mesh
  59611. * @param options defines the options used to create the mesh
  59612. * @param scene defines the hosting scene
  59613. * @returns the dashed line mesh
  59614. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59615. */
  59616. static CreateDashedLines(name: string, options: {
  59617. points: Vector3[];
  59618. dashSize?: number;
  59619. gapSize?: number;
  59620. dashNb?: number;
  59621. updatable?: boolean;
  59622. instance?: LinesMesh;
  59623. }, scene?: Nullable<Scene>): LinesMesh;
  59624. /**
  59625. * 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.
  59626. * * 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.
  59627. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59628. * * 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.
  59629. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59630. * * 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
  59631. * * 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
  59632. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59634. * * 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
  59635. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59637. * @param name defines the name of the mesh
  59638. * @param options defines the options used to create the mesh
  59639. * @param scene defines the hosting scene
  59640. * @returns the extruded shape mesh
  59641. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59642. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59643. */
  59644. static ExtrudeShape(name: string, options: {
  59645. shape: Vector3[];
  59646. path: Vector3[];
  59647. scale?: number;
  59648. rotation?: number;
  59649. cap?: number;
  59650. updatable?: boolean;
  59651. sideOrientation?: number;
  59652. frontUVs?: Vector4;
  59653. backUVs?: Vector4;
  59654. instance?: Mesh;
  59655. invertUV?: boolean;
  59656. }, scene?: Nullable<Scene>): Mesh;
  59657. /**
  59658. * Creates an custom extruded shape mesh.
  59659. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59660. * * 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.
  59661. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59662. * * 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
  59663. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59664. * * 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
  59665. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59666. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59667. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59668. * * 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
  59669. * * 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
  59670. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59672. * * 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
  59673. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59675. * @param name defines the name of the mesh
  59676. * @param options defines the options used to create the mesh
  59677. * @param scene defines the hosting scene
  59678. * @returns the custom extruded shape mesh
  59679. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59680. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59681. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59682. */
  59683. static ExtrudeShapeCustom(name: string, options: {
  59684. shape: Vector3[];
  59685. path: Vector3[];
  59686. scaleFunction?: any;
  59687. rotationFunction?: any;
  59688. ribbonCloseArray?: boolean;
  59689. ribbonClosePath?: boolean;
  59690. cap?: number;
  59691. updatable?: boolean;
  59692. sideOrientation?: number;
  59693. frontUVs?: Vector4;
  59694. backUVs?: Vector4;
  59695. instance?: Mesh;
  59696. invertUV?: boolean;
  59697. }, scene?: Nullable<Scene>): Mesh;
  59698. /**
  59699. * Creates lathe mesh.
  59700. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59701. * * 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
  59702. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59703. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59704. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59705. * * 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
  59706. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59707. * * 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
  59708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59709. * * 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
  59710. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59712. * @param name defines the name of the mesh
  59713. * @param options defines the options used to create the mesh
  59714. * @param scene defines the hosting scene
  59715. * @returns the lathe mesh
  59716. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59717. */
  59718. static CreateLathe(name: string, options: {
  59719. shape: Vector3[];
  59720. radius?: number;
  59721. tessellation?: number;
  59722. clip?: number;
  59723. arc?: number;
  59724. closed?: boolean;
  59725. updatable?: boolean;
  59726. sideOrientation?: number;
  59727. frontUVs?: Vector4;
  59728. backUVs?: Vector4;
  59729. cap?: number;
  59730. invertUV?: boolean;
  59731. }, scene?: Nullable<Scene>): Mesh;
  59732. /**
  59733. * Creates a tiled plane mesh
  59734. * * You can set a limited pattern arrangement with the tiles
  59735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59736. * * 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
  59737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59738. * @param name defines the name of the mesh
  59739. * @param options defines the options used to create the mesh
  59740. * @param scene defines the hosting scene
  59741. * @returns the plane mesh
  59742. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59743. */
  59744. static CreateTiledPlane(name: string, options: {
  59745. pattern?: number;
  59746. tileSize?: number;
  59747. tileWidth?: number;
  59748. tileHeight?: number;
  59749. size?: number;
  59750. width?: number;
  59751. height?: number;
  59752. alignHorizontal?: number;
  59753. alignVertical?: number;
  59754. sideOrientation?: number;
  59755. frontUVs?: Vector4;
  59756. backUVs?: Vector4;
  59757. updatable?: boolean;
  59758. }, scene?: Nullable<Scene>): Mesh;
  59759. /**
  59760. * Creates a plane mesh
  59761. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59762. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59763. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59765. * * 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
  59766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59767. * @param name defines the name of the mesh
  59768. * @param options defines the options used to create the mesh
  59769. * @param scene defines the hosting scene
  59770. * @returns the plane mesh
  59771. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59772. */
  59773. static CreatePlane(name: string, options: {
  59774. size?: number;
  59775. width?: number;
  59776. height?: number;
  59777. sideOrientation?: number;
  59778. frontUVs?: Vector4;
  59779. backUVs?: Vector4;
  59780. updatable?: boolean;
  59781. sourcePlane?: Plane;
  59782. }, scene?: Nullable<Scene>): Mesh;
  59783. /**
  59784. * Creates a ground mesh
  59785. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59786. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59788. * @param name defines the name of the mesh
  59789. * @param options defines the options used to create the mesh
  59790. * @param scene defines the hosting scene
  59791. * @returns the ground mesh
  59792. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59793. */
  59794. static CreateGround(name: string, options: {
  59795. width?: number;
  59796. height?: number;
  59797. subdivisions?: number;
  59798. subdivisionsX?: number;
  59799. subdivisionsY?: number;
  59800. updatable?: boolean;
  59801. }, scene?: Nullable<Scene>): Mesh;
  59802. /**
  59803. * Creates a tiled ground mesh
  59804. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59805. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59806. * * 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
  59807. * * 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
  59808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59809. * @param name defines the name of the mesh
  59810. * @param options defines the options used to create the mesh
  59811. * @param scene defines the hosting scene
  59812. * @returns the tiled ground mesh
  59813. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59814. */
  59815. static CreateTiledGround(name: string, options: {
  59816. xmin: number;
  59817. zmin: number;
  59818. xmax: number;
  59819. zmax: number;
  59820. subdivisions?: {
  59821. w: number;
  59822. h: number;
  59823. };
  59824. precision?: {
  59825. w: number;
  59826. h: number;
  59827. };
  59828. updatable?: boolean;
  59829. }, scene?: Nullable<Scene>): Mesh;
  59830. /**
  59831. * Creates a ground mesh from a height map
  59832. * * The parameter `url` sets the URL of the height map image resource.
  59833. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59834. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59835. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59836. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59837. * * 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.
  59838. * * 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).
  59839. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59841. * @param name defines the name of the mesh
  59842. * @param url defines the url to the height map
  59843. * @param options defines the options used to create the mesh
  59844. * @param scene defines the hosting scene
  59845. * @returns the ground mesh
  59846. * @see https://doc.babylonjs.com/babylon101/height_map
  59847. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59848. */
  59849. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59850. width?: number;
  59851. height?: number;
  59852. subdivisions?: number;
  59853. minHeight?: number;
  59854. maxHeight?: number;
  59855. colorFilter?: Color3;
  59856. alphaFilter?: number;
  59857. updatable?: boolean;
  59858. onReady?: (mesh: GroundMesh) => void;
  59859. }, scene?: Nullable<Scene>): GroundMesh;
  59860. /**
  59861. * Creates a polygon mesh
  59862. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59863. * * 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
  59864. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59866. * * 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)
  59867. * * Remember you can only change the shape positions, not their number when updating a polygon
  59868. * @param name defines the name of the mesh
  59869. * @param options defines the options used to create the mesh
  59870. * @param scene defines the hosting scene
  59871. * @param earcutInjection can be used to inject your own earcut reference
  59872. * @returns the polygon mesh
  59873. */
  59874. static CreatePolygon(name: string, options: {
  59875. shape: Vector3[];
  59876. holes?: Vector3[][];
  59877. depth?: number;
  59878. faceUV?: Vector4[];
  59879. faceColors?: Color4[];
  59880. updatable?: boolean;
  59881. sideOrientation?: number;
  59882. frontUVs?: Vector4;
  59883. backUVs?: Vector4;
  59884. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59885. /**
  59886. * Creates an extruded polygon mesh, with depth in the Y direction.
  59887. * * 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)
  59888. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59889. * @param name defines the name of the mesh
  59890. * @param options defines the options used to create the mesh
  59891. * @param scene defines the hosting scene
  59892. * @param earcutInjection can be used to inject your own earcut reference
  59893. * @returns the polygon mesh
  59894. */
  59895. static ExtrudePolygon(name: string, options: {
  59896. shape: Vector3[];
  59897. holes?: Vector3[][];
  59898. depth?: number;
  59899. faceUV?: Vector4[];
  59900. faceColors?: Color4[];
  59901. updatable?: boolean;
  59902. sideOrientation?: number;
  59903. frontUVs?: Vector4;
  59904. backUVs?: Vector4;
  59905. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59906. /**
  59907. * Creates a tube mesh.
  59908. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59909. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59910. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59911. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59912. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59913. * * 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)
  59914. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59915. * * 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
  59916. * * 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
  59917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59918. * * 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
  59919. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59921. * @param name defines the name of the mesh
  59922. * @param options defines the options used to create the mesh
  59923. * @param scene defines the hosting scene
  59924. * @returns the tube mesh
  59925. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59926. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59927. */
  59928. static CreateTube(name: string, options: {
  59929. path: Vector3[];
  59930. radius?: number;
  59931. tessellation?: number;
  59932. radiusFunction?: {
  59933. (i: number, distance: number): number;
  59934. };
  59935. cap?: number;
  59936. arc?: number;
  59937. updatable?: boolean;
  59938. sideOrientation?: number;
  59939. frontUVs?: Vector4;
  59940. backUVs?: Vector4;
  59941. instance?: Mesh;
  59942. invertUV?: boolean;
  59943. }, scene?: Nullable<Scene>): Mesh;
  59944. /**
  59945. * Creates a polyhedron mesh
  59946. * * 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
  59947. * * The parameter `size` (positive float, default 1) sets the polygon size
  59948. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59949. * * 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`
  59950. * * 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
  59951. * * 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)`)
  59952. * * 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
  59953. * * 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
  59954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59955. * * 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
  59956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59957. * @param name defines the name of the mesh
  59958. * @param options defines the options used to create the mesh
  59959. * @param scene defines the hosting scene
  59960. * @returns the polyhedron mesh
  59961. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59962. */
  59963. static CreatePolyhedron(name: string, options: {
  59964. type?: number;
  59965. size?: number;
  59966. sizeX?: number;
  59967. sizeY?: number;
  59968. sizeZ?: number;
  59969. custom?: any;
  59970. faceUV?: Vector4[];
  59971. faceColors?: Color4[];
  59972. flat?: boolean;
  59973. updatable?: boolean;
  59974. sideOrientation?: number;
  59975. frontUVs?: Vector4;
  59976. backUVs?: Vector4;
  59977. }, scene?: Nullable<Scene>): Mesh;
  59978. /**
  59979. * Creates a decal mesh.
  59980. * 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
  59981. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59982. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59983. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59984. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59985. * @param name defines the name of the mesh
  59986. * @param sourceMesh defines the mesh where the decal must be applied
  59987. * @param options defines the options used to create the mesh
  59988. * @param scene defines the hosting scene
  59989. * @returns the decal mesh
  59990. * @see https://doc.babylonjs.com/how_to/decals
  59991. */
  59992. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59993. position?: Vector3;
  59994. normal?: Vector3;
  59995. size?: Vector3;
  59996. angle?: number;
  59997. }): Mesh;
  59998. }
  59999. }
  60000. declare module "babylonjs/Meshes/meshSimplification" {
  60001. import { Mesh } from "babylonjs/Meshes/mesh";
  60002. /**
  60003. * A simplifier interface for future simplification implementations
  60004. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60005. */
  60006. export interface ISimplifier {
  60007. /**
  60008. * Simplification of a given mesh according to the given settings.
  60009. * Since this requires computation, it is assumed that the function runs async.
  60010. * @param settings The settings of the simplification, including quality and distance
  60011. * @param successCallback A callback that will be called after the mesh was simplified.
  60012. * @param errorCallback in case of an error, this callback will be called. optional.
  60013. */
  60014. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60015. }
  60016. /**
  60017. * Expected simplification settings.
  60018. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60019. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60020. */
  60021. export interface ISimplificationSettings {
  60022. /**
  60023. * Gets or sets the expected quality
  60024. */
  60025. quality: number;
  60026. /**
  60027. * Gets or sets the distance when this optimized version should be used
  60028. */
  60029. distance: number;
  60030. /**
  60031. * Gets an already optimized mesh
  60032. */
  60033. optimizeMesh?: boolean;
  60034. }
  60035. /**
  60036. * Class used to specify simplification options
  60037. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60038. */
  60039. export class SimplificationSettings implements ISimplificationSettings {
  60040. /** expected quality */
  60041. quality: number;
  60042. /** distance when this optimized version should be used */
  60043. distance: number;
  60044. /** already optimized mesh */
  60045. optimizeMesh?: boolean | undefined;
  60046. /**
  60047. * Creates a SimplificationSettings
  60048. * @param quality expected quality
  60049. * @param distance distance when this optimized version should be used
  60050. * @param optimizeMesh already optimized mesh
  60051. */
  60052. constructor(
  60053. /** expected quality */
  60054. quality: number,
  60055. /** distance when this optimized version should be used */
  60056. distance: number,
  60057. /** already optimized mesh */
  60058. optimizeMesh?: boolean | undefined);
  60059. }
  60060. /**
  60061. * Interface used to define a simplification task
  60062. */
  60063. export interface ISimplificationTask {
  60064. /**
  60065. * Array of settings
  60066. */
  60067. settings: Array<ISimplificationSettings>;
  60068. /**
  60069. * Simplification type
  60070. */
  60071. simplificationType: SimplificationType;
  60072. /**
  60073. * Mesh to simplify
  60074. */
  60075. mesh: Mesh;
  60076. /**
  60077. * Callback called on success
  60078. */
  60079. successCallback?: () => void;
  60080. /**
  60081. * Defines if parallel processing can be used
  60082. */
  60083. parallelProcessing: boolean;
  60084. }
  60085. /**
  60086. * Queue used to order the simplification tasks
  60087. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60088. */
  60089. export class SimplificationQueue {
  60090. private _simplificationArray;
  60091. /**
  60092. * Gets a boolean indicating that the process is still running
  60093. */
  60094. running: boolean;
  60095. /**
  60096. * Creates a new queue
  60097. */
  60098. constructor();
  60099. /**
  60100. * Adds a new simplification task
  60101. * @param task defines a task to add
  60102. */
  60103. addTask(task: ISimplificationTask): void;
  60104. /**
  60105. * Execute next task
  60106. */
  60107. executeNext(): void;
  60108. /**
  60109. * Execute a simplification task
  60110. * @param task defines the task to run
  60111. */
  60112. runSimplification(task: ISimplificationTask): void;
  60113. private getSimplifier;
  60114. }
  60115. /**
  60116. * The implemented types of simplification
  60117. * At the moment only Quadratic Error Decimation is implemented
  60118. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60119. */
  60120. export enum SimplificationType {
  60121. /** Quadratic error decimation */
  60122. QUADRATIC = 0
  60123. }
  60124. }
  60125. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60126. import { Scene } from "babylonjs/scene";
  60127. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60128. import { ISceneComponent } from "babylonjs/sceneComponent";
  60129. module "babylonjs/scene" {
  60130. interface Scene {
  60131. /** @hidden (Backing field) */
  60132. _simplificationQueue: SimplificationQueue;
  60133. /**
  60134. * Gets or sets the simplification queue attached to the scene
  60135. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60136. */
  60137. simplificationQueue: SimplificationQueue;
  60138. }
  60139. }
  60140. module "babylonjs/Meshes/mesh" {
  60141. interface Mesh {
  60142. /**
  60143. * Simplify the mesh according to the given array of settings.
  60144. * Function will return immediately and will simplify async
  60145. * @param settings a collection of simplification settings
  60146. * @param parallelProcessing should all levels calculate parallel or one after the other
  60147. * @param simplificationType the type of simplification to run
  60148. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60149. * @returns the current mesh
  60150. */
  60151. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60152. }
  60153. }
  60154. /**
  60155. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60156. * created in a scene
  60157. */
  60158. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60159. /**
  60160. * The component name helpfull to identify the component in the list of scene components.
  60161. */
  60162. readonly name: string;
  60163. /**
  60164. * The scene the component belongs to.
  60165. */
  60166. scene: Scene;
  60167. /**
  60168. * Creates a new instance of the component for the given scene
  60169. * @param scene Defines the scene to register the component in
  60170. */
  60171. constructor(scene: Scene);
  60172. /**
  60173. * Registers the component in a given scene
  60174. */
  60175. register(): void;
  60176. /**
  60177. * Rebuilds the elements related to this component in case of
  60178. * context lost for instance.
  60179. */
  60180. rebuild(): void;
  60181. /**
  60182. * Disposes the component and the associated ressources
  60183. */
  60184. dispose(): void;
  60185. private _beforeCameraUpdate;
  60186. }
  60187. }
  60188. declare module "babylonjs/Meshes/Builders/index" {
  60189. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60190. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60191. export * from "babylonjs/Meshes/Builders/discBuilder";
  60192. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60193. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60194. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60195. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60196. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60197. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60198. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60199. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60200. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60201. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60202. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60203. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60204. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60205. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60206. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60207. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60208. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60209. }
  60210. declare module "babylonjs/Meshes/index" {
  60211. export * from "babylonjs/Meshes/abstractMesh";
  60212. export * from "babylonjs/Meshes/buffer";
  60213. export * from "babylonjs/Meshes/Compression/index";
  60214. export * from "babylonjs/Meshes/csg";
  60215. export * from "babylonjs/Meshes/geometry";
  60216. export * from "babylonjs/Meshes/groundMesh";
  60217. export * from "babylonjs/Meshes/trailMesh";
  60218. export * from "babylonjs/Meshes/instancedMesh";
  60219. export * from "babylonjs/Meshes/linesMesh";
  60220. export * from "babylonjs/Meshes/mesh";
  60221. export * from "babylonjs/Meshes/mesh.vertexData";
  60222. export * from "babylonjs/Meshes/meshBuilder";
  60223. export * from "babylonjs/Meshes/meshSimplification";
  60224. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60225. export * from "babylonjs/Meshes/polygonMesh";
  60226. export * from "babylonjs/Meshes/subMesh";
  60227. export * from "babylonjs/Meshes/meshLODLevel";
  60228. export * from "babylonjs/Meshes/transformNode";
  60229. export * from "babylonjs/Meshes/Builders/index";
  60230. export * from "babylonjs/Meshes/dataBuffer";
  60231. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60232. }
  60233. declare module "babylonjs/Morph/index" {
  60234. export * from "babylonjs/Morph/morphTarget";
  60235. export * from "babylonjs/Morph/morphTargetManager";
  60236. }
  60237. declare module "babylonjs/Navigation/INavigationEngine" {
  60238. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60239. import { Vector3 } from "babylonjs/Maths/math";
  60240. import { Mesh } from "babylonjs/Meshes/mesh";
  60241. import { Scene } from "babylonjs/scene";
  60242. /**
  60243. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60244. */
  60245. export interface INavigationEnginePlugin {
  60246. /**
  60247. * plugin name
  60248. */
  60249. name: string;
  60250. /**
  60251. * Creates a navigation mesh
  60252. * @param meshes array of all the geometry used to compute the navigatio mesh
  60253. * @param parameters bunch of parameters used to filter geometry
  60254. */
  60255. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60256. /**
  60257. * Create a navigation mesh debug mesh
  60258. * @param scene is where the mesh will be added
  60259. * @returns debug display mesh
  60260. */
  60261. createDebugNavMesh(scene: Scene): Mesh;
  60262. /**
  60263. * Get a navigation mesh constrained position, closest to the parameter position
  60264. * @param position world position
  60265. * @returns the closest point to position constrained by the navigation mesh
  60266. */
  60267. getClosestPoint(position: Vector3): Vector3;
  60268. /**
  60269. * Get a navigation mesh constrained position, within a particular radius
  60270. * @param position world position
  60271. * @param maxRadius the maximum distance to the constrained world position
  60272. * @returns the closest point to position constrained by the navigation mesh
  60273. */
  60274. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60275. /**
  60276. * Compute the final position from a segment made of destination-position
  60277. * @param position world position
  60278. * @param destination world position
  60279. * @returns the resulting point along the navmesh
  60280. */
  60281. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60282. /**
  60283. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60284. * @param start world position
  60285. * @param end world position
  60286. * @returns array containing world position composing the path
  60287. */
  60288. computePath(start: Vector3, end: Vector3): Vector3[];
  60289. /**
  60290. * If this plugin is supported
  60291. * @returns true if plugin is supported
  60292. */
  60293. isSupported(): boolean;
  60294. /**
  60295. * Create a new Crowd so you can add agents
  60296. * @param maxAgents the maximum agent count in the crowd
  60297. * @param maxAgentRadius the maximum radius an agent can have
  60298. * @param scene to attach the crowd to
  60299. * @returns the crowd you can add agents to
  60300. */
  60301. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60302. /**
  60303. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60304. * The queries will try to find a solution within those bounds
  60305. * default is (1,1,1)
  60306. * @param extent x,y,z value that define the extent around the queries point of reference
  60307. */
  60308. setDefaultQueryExtent(extent: Vector3): void;
  60309. /**
  60310. * Get the Bounding box extent specified by setDefaultQueryExtent
  60311. * @returns the box extent values
  60312. */
  60313. getDefaultQueryExtent(): Vector3;
  60314. /**
  60315. * Release all resources
  60316. */
  60317. dispose(): void;
  60318. }
  60319. /**
  60320. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60321. */
  60322. export interface ICrowd {
  60323. /**
  60324. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60325. * You can attach anything to that node. The node position is updated in the scene update tick.
  60326. * @param pos world position that will be constrained by the navigation mesh
  60327. * @param parameters agent parameters
  60328. * @param transform hooked to the agent that will be update by the scene
  60329. * @returns agent index
  60330. */
  60331. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60332. /**
  60333. * Returns the agent position in world space
  60334. * @param index agent index returned by addAgent
  60335. * @returns world space position
  60336. */
  60337. getAgentPosition(index: number): Vector3;
  60338. /**
  60339. * Gets the agent velocity in world space
  60340. * @param index agent index returned by addAgent
  60341. * @returns world space velocity
  60342. */
  60343. getAgentVelocity(index: number): Vector3;
  60344. /**
  60345. * remove a particular agent previously created
  60346. * @param index agent index returned by addAgent
  60347. */
  60348. removeAgent(index: number): void;
  60349. /**
  60350. * get the list of all agents attached to this crowd
  60351. * @returns list of agent indices
  60352. */
  60353. getAgents(): number[];
  60354. /**
  60355. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60356. * @param deltaTime in seconds
  60357. */
  60358. update(deltaTime: number): void;
  60359. /**
  60360. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60361. * @param index agent index returned by addAgent
  60362. * @param destination targeted world position
  60363. */
  60364. agentGoto(index: number, destination: Vector3): void;
  60365. /**
  60366. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60367. * The queries will try to find a solution within those bounds
  60368. * default is (1,1,1)
  60369. * @param extent x,y,z value that define the extent around the queries point of reference
  60370. */
  60371. setDefaultQueryExtent(extent: Vector3): void;
  60372. /**
  60373. * Get the Bounding box extent specified by setDefaultQueryExtent
  60374. * @returns the box extent values
  60375. */
  60376. getDefaultQueryExtent(): Vector3;
  60377. /**
  60378. * Release all resources
  60379. */
  60380. dispose(): void;
  60381. }
  60382. /**
  60383. * Configures an agent
  60384. */
  60385. export interface IAgentParameters {
  60386. /**
  60387. * Agent radius. [Limit: >= 0]
  60388. */
  60389. radius: number;
  60390. /**
  60391. * Agent height. [Limit: > 0]
  60392. */
  60393. height: number;
  60394. /**
  60395. * Maximum allowed acceleration. [Limit: >= 0]
  60396. */
  60397. maxAcceleration: number;
  60398. /**
  60399. * Maximum allowed speed. [Limit: >= 0]
  60400. */
  60401. maxSpeed: number;
  60402. /**
  60403. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60404. */
  60405. collisionQueryRange: number;
  60406. /**
  60407. * The path visibility optimization range. [Limit: > 0]
  60408. */
  60409. pathOptimizationRange: number;
  60410. /**
  60411. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60412. */
  60413. separationWeight: number;
  60414. }
  60415. /**
  60416. * Configures the navigation mesh creation
  60417. */
  60418. export interface INavMeshParameters {
  60419. /**
  60420. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60421. */
  60422. cs: number;
  60423. /**
  60424. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60425. */
  60426. ch: number;
  60427. /**
  60428. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60429. */
  60430. walkableSlopeAngle: number;
  60431. /**
  60432. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60433. * be considered walkable. [Limit: >= 3] [Units: vx]
  60434. */
  60435. walkableHeight: number;
  60436. /**
  60437. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60438. */
  60439. walkableClimb: number;
  60440. /**
  60441. * The distance to erode/shrink the walkable area of the heightfield away from
  60442. * obstructions. [Limit: >=0] [Units: vx]
  60443. */
  60444. walkableRadius: number;
  60445. /**
  60446. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60447. */
  60448. maxEdgeLen: number;
  60449. /**
  60450. * The maximum distance a simplfied contour's border edges should deviate
  60451. * the original raw contour. [Limit: >=0] [Units: vx]
  60452. */
  60453. maxSimplificationError: number;
  60454. /**
  60455. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60456. */
  60457. minRegionArea: number;
  60458. /**
  60459. * Any regions with a span count smaller than this value will, if possible,
  60460. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60461. */
  60462. mergeRegionArea: number;
  60463. /**
  60464. * The maximum number of vertices allowed for polygons generated during the
  60465. * contour to polygon conversion process. [Limit: >= 3]
  60466. */
  60467. maxVertsPerPoly: number;
  60468. /**
  60469. * Sets the sampling distance to use when generating the detail mesh.
  60470. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60471. */
  60472. detailSampleDist: number;
  60473. /**
  60474. * The maximum distance the detail mesh surface should deviate from heightfield
  60475. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60476. */
  60477. detailSampleMaxError: number;
  60478. }
  60479. }
  60480. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60481. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60482. import { Mesh } from "babylonjs/Meshes/mesh";
  60483. import { Scene } from "babylonjs/scene";
  60484. import { Vector3 } from "babylonjs/Maths/math";
  60485. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60486. /**
  60487. * RecastJS navigation plugin
  60488. */
  60489. export class RecastJSPlugin implements INavigationEnginePlugin {
  60490. /**
  60491. * Reference to the Recast library
  60492. */
  60493. bjsRECAST: any;
  60494. /**
  60495. * plugin name
  60496. */
  60497. name: string;
  60498. /**
  60499. * the first navmesh created. We might extend this to support multiple navmeshes
  60500. */
  60501. navMesh: any;
  60502. /**
  60503. * Initializes the recastJS plugin
  60504. * @param recastInjection can be used to inject your own recast reference
  60505. */
  60506. constructor(recastInjection?: any);
  60507. /**
  60508. * Creates a navigation mesh
  60509. * @param meshes array of all the geometry used to compute the navigatio mesh
  60510. * @param parameters bunch of parameters used to filter geometry
  60511. */
  60512. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60513. /**
  60514. * Create a navigation mesh debug mesh
  60515. * @param scene is where the mesh will be added
  60516. * @returns debug display mesh
  60517. */
  60518. createDebugNavMesh(scene: Scene): Mesh;
  60519. /**
  60520. * Get a navigation mesh constrained position, closest to the parameter position
  60521. * @param position world position
  60522. * @returns the closest point to position constrained by the navigation mesh
  60523. */
  60524. getClosestPoint(position: Vector3): Vector3;
  60525. /**
  60526. * Get a navigation mesh constrained position, within a particular radius
  60527. * @param position world position
  60528. * @param maxRadius the maximum distance to the constrained world position
  60529. * @returns the closest point to position constrained by the navigation mesh
  60530. */
  60531. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60532. /**
  60533. * Compute the final position from a segment made of destination-position
  60534. * @param position world position
  60535. * @param destination world position
  60536. * @returns the resulting point along the navmesh
  60537. */
  60538. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60539. /**
  60540. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60541. * @param start world position
  60542. * @param end world position
  60543. * @returns array containing world position composing the path
  60544. */
  60545. computePath(start: Vector3, end: Vector3): Vector3[];
  60546. /**
  60547. * Create a new Crowd so you can add agents
  60548. * @param maxAgents the maximum agent count in the crowd
  60549. * @param maxAgentRadius the maximum radius an agent can have
  60550. * @param scene to attach the crowd to
  60551. * @returns the crowd you can add agents to
  60552. */
  60553. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60554. /**
  60555. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60556. * The queries will try to find a solution within those bounds
  60557. * default is (1,1,1)
  60558. * @param extent x,y,z value that define the extent around the queries point of reference
  60559. */
  60560. setDefaultQueryExtent(extent: Vector3): void;
  60561. /**
  60562. * Get the Bounding box extent specified by setDefaultQueryExtent
  60563. * @returns the box extent values
  60564. */
  60565. getDefaultQueryExtent(): Vector3;
  60566. /**
  60567. * Disposes
  60568. */
  60569. dispose(): void;
  60570. /**
  60571. * If this plugin is supported
  60572. * @returns true if plugin is supported
  60573. */
  60574. isSupported(): boolean;
  60575. }
  60576. /**
  60577. * Recast detour crowd implementation
  60578. */
  60579. export class RecastJSCrowd implements ICrowd {
  60580. /**
  60581. * Recast/detour plugin
  60582. */
  60583. bjsRECASTPlugin: RecastJSPlugin;
  60584. /**
  60585. * Link to the detour crowd
  60586. */
  60587. recastCrowd: any;
  60588. /**
  60589. * One transform per agent
  60590. */
  60591. transforms: TransformNode[];
  60592. /**
  60593. * All agents created
  60594. */
  60595. agents: number[];
  60596. /**
  60597. * Link to the scene is kept to unregister the crowd from the scene
  60598. */
  60599. private _scene;
  60600. /**
  60601. * Observer for crowd updates
  60602. */
  60603. private _onBeforeAnimationsObserver;
  60604. /**
  60605. * Constructor
  60606. * @param plugin recastJS plugin
  60607. * @param maxAgents the maximum agent count in the crowd
  60608. * @param maxAgentRadius the maximum radius an agent can have
  60609. * @param scene to attach the crowd to
  60610. * @returns the crowd you can add agents to
  60611. */
  60612. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60613. /**
  60614. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60615. * You can attach anything to that node. The node position is updated in the scene update tick.
  60616. * @param pos world position that will be constrained by the navigation mesh
  60617. * @param parameters agent parameters
  60618. * @param transform hooked to the agent that will be update by the scene
  60619. * @returns agent index
  60620. */
  60621. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60622. /**
  60623. * Returns the agent position in world space
  60624. * @param index agent index returned by addAgent
  60625. * @returns world space position
  60626. */
  60627. getAgentPosition(index: number): Vector3;
  60628. /**
  60629. * Returns the agent velocity in world space
  60630. * @param index agent index returned by addAgent
  60631. * @returns world space velocity
  60632. */
  60633. getAgentVelocity(index: number): Vector3;
  60634. /**
  60635. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60636. * @param index agent index returned by addAgent
  60637. * @param destination targeted world position
  60638. */
  60639. agentGoto(index: number, destination: Vector3): void;
  60640. /**
  60641. * remove a particular agent previously created
  60642. * @param index agent index returned by addAgent
  60643. */
  60644. removeAgent(index: number): void;
  60645. /**
  60646. * get the list of all agents attached to this crowd
  60647. * @returns list of agent indices
  60648. */
  60649. getAgents(): number[];
  60650. /**
  60651. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60652. * @param deltaTime in seconds
  60653. */
  60654. update(deltaTime: number): void;
  60655. /**
  60656. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60657. * The queries will try to find a solution within those bounds
  60658. * default is (1,1,1)
  60659. * @param extent x,y,z value that define the extent around the queries point of reference
  60660. */
  60661. setDefaultQueryExtent(extent: Vector3): void;
  60662. /**
  60663. * Get the Bounding box extent specified by setDefaultQueryExtent
  60664. * @returns the box extent values
  60665. */
  60666. getDefaultQueryExtent(): Vector3;
  60667. /**
  60668. * Release all resources
  60669. */
  60670. dispose(): void;
  60671. }
  60672. }
  60673. declare module "babylonjs/Navigation/Plugins/index" {
  60674. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60675. }
  60676. declare module "babylonjs/Navigation/index" {
  60677. export * from "babylonjs/Navigation/INavigationEngine";
  60678. export * from "babylonjs/Navigation/Plugins/index";
  60679. }
  60680. declare module "babylonjs/Offline/database" {
  60681. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60682. /**
  60683. * Class used to enable access to IndexedDB
  60684. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60685. */
  60686. export class Database implements IOfflineProvider {
  60687. private _callbackManifestChecked;
  60688. private _currentSceneUrl;
  60689. private _db;
  60690. private _enableSceneOffline;
  60691. private _enableTexturesOffline;
  60692. private _manifestVersionFound;
  60693. private _mustUpdateRessources;
  60694. private _hasReachedQuota;
  60695. private _isSupported;
  60696. private _idbFactory;
  60697. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60698. private static IsUASupportingBlobStorage;
  60699. /**
  60700. * Gets a boolean indicating if Database storate is enabled (off by default)
  60701. */
  60702. static IDBStorageEnabled: boolean;
  60703. /**
  60704. * Gets a boolean indicating if scene must be saved in the database
  60705. */
  60706. readonly enableSceneOffline: boolean;
  60707. /**
  60708. * Gets a boolean indicating if textures must be saved in the database
  60709. */
  60710. readonly enableTexturesOffline: boolean;
  60711. /**
  60712. * Creates a new Database
  60713. * @param urlToScene defines the url to load the scene
  60714. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60715. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60716. */
  60717. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60718. private static _ParseURL;
  60719. private static _ReturnFullUrlLocation;
  60720. private _checkManifestFile;
  60721. /**
  60722. * Open the database and make it available
  60723. * @param successCallback defines the callback to call on success
  60724. * @param errorCallback defines the callback to call on error
  60725. */
  60726. open(successCallback: () => void, errorCallback: () => void): void;
  60727. /**
  60728. * Loads an image from the database
  60729. * @param url defines the url to load from
  60730. * @param image defines the target DOM image
  60731. */
  60732. loadImage(url: string, image: HTMLImageElement): void;
  60733. private _loadImageFromDBAsync;
  60734. private _saveImageIntoDBAsync;
  60735. private _checkVersionFromDB;
  60736. private _loadVersionFromDBAsync;
  60737. private _saveVersionIntoDBAsync;
  60738. /**
  60739. * Loads a file from database
  60740. * @param url defines the URL to load from
  60741. * @param sceneLoaded defines a callback to call on success
  60742. * @param progressCallBack defines a callback to call when progress changed
  60743. * @param errorCallback defines a callback to call on error
  60744. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60745. */
  60746. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60747. private _loadFileAsync;
  60748. private _saveFileAsync;
  60749. /**
  60750. * Validates if xhr data is correct
  60751. * @param xhr defines the request to validate
  60752. * @param dataType defines the expected data type
  60753. * @returns true if data is correct
  60754. */
  60755. private static _ValidateXHRData;
  60756. }
  60757. }
  60758. declare module "babylonjs/Offline/index" {
  60759. export * from "babylonjs/Offline/database";
  60760. export * from "babylonjs/Offline/IOfflineProvider";
  60761. }
  60762. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60763. /** @hidden */
  60764. export var gpuUpdateParticlesPixelShader: {
  60765. name: string;
  60766. shader: string;
  60767. };
  60768. }
  60769. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60770. /** @hidden */
  60771. export var gpuUpdateParticlesVertexShader: {
  60772. name: string;
  60773. shader: string;
  60774. };
  60775. }
  60776. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60777. /** @hidden */
  60778. export var clipPlaneFragmentDeclaration2: {
  60779. name: string;
  60780. shader: string;
  60781. };
  60782. }
  60783. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60784. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60785. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60786. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60787. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60788. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60789. /** @hidden */
  60790. export var gpuRenderParticlesPixelShader: {
  60791. name: string;
  60792. shader: string;
  60793. };
  60794. }
  60795. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60796. /** @hidden */
  60797. export var clipPlaneVertexDeclaration2: {
  60798. name: string;
  60799. shader: string;
  60800. };
  60801. }
  60802. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60803. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60804. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60805. /** @hidden */
  60806. export var gpuRenderParticlesVertexShader: {
  60807. name: string;
  60808. shader: string;
  60809. };
  60810. }
  60811. declare module "babylonjs/Particles/gpuParticleSystem" {
  60812. import { Nullable } from "babylonjs/types";
  60813. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60814. import { Observable } from "babylonjs/Misc/observable";
  60815. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60816. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60817. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60818. import { Scene, IDisposable } from "babylonjs/scene";
  60819. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60820. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60821. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60822. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60823. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60824. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60825. /**
  60826. * This represents a GPU particle system in Babylon
  60827. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60828. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60829. */
  60830. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60831. /**
  60832. * The layer mask we are rendering the particles through.
  60833. */
  60834. layerMask: number;
  60835. private _capacity;
  60836. private _activeCount;
  60837. private _currentActiveCount;
  60838. private _accumulatedCount;
  60839. private _renderEffect;
  60840. private _updateEffect;
  60841. private _buffer0;
  60842. private _buffer1;
  60843. private _spriteBuffer;
  60844. private _updateVAO;
  60845. private _renderVAO;
  60846. private _targetIndex;
  60847. private _sourceBuffer;
  60848. private _targetBuffer;
  60849. private _engine;
  60850. private _currentRenderId;
  60851. private _started;
  60852. private _stopped;
  60853. private _timeDelta;
  60854. private _randomTexture;
  60855. private _randomTexture2;
  60856. private _attributesStrideSize;
  60857. private _updateEffectOptions;
  60858. private _randomTextureSize;
  60859. private _actualFrame;
  60860. private readonly _rawTextureWidth;
  60861. /**
  60862. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60863. */
  60864. static readonly IsSupported: boolean;
  60865. /**
  60866. * An event triggered when the system is disposed.
  60867. */
  60868. onDisposeObservable: Observable<GPUParticleSystem>;
  60869. /**
  60870. * Gets the maximum number of particles active at the same time.
  60871. * @returns The max number of active particles.
  60872. */
  60873. getCapacity(): number;
  60874. /**
  60875. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60876. * to override the particles.
  60877. */
  60878. forceDepthWrite: boolean;
  60879. /**
  60880. * Gets or set the number of active particles
  60881. */
  60882. activeParticleCount: number;
  60883. private _preWarmDone;
  60884. /**
  60885. * Is this system ready to be used/rendered
  60886. * @return true if the system is ready
  60887. */
  60888. isReady(): boolean;
  60889. /**
  60890. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60891. * @returns True if it has been started, otherwise false.
  60892. */
  60893. isStarted(): boolean;
  60894. /**
  60895. * Starts the particle system and begins to emit
  60896. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60897. */
  60898. start(delay?: number): void;
  60899. /**
  60900. * Stops the particle system.
  60901. */
  60902. stop(): void;
  60903. /**
  60904. * Remove all active particles
  60905. */
  60906. reset(): void;
  60907. /**
  60908. * Returns the string "GPUParticleSystem"
  60909. * @returns a string containing the class name
  60910. */
  60911. getClassName(): string;
  60912. private _colorGradientsTexture;
  60913. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60914. /**
  60915. * Adds a new color gradient
  60916. * @param gradient defines the gradient to use (between 0 and 1)
  60917. * @param color1 defines the color to affect to the specified gradient
  60918. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60919. * @returns the current particle system
  60920. */
  60921. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60922. /**
  60923. * Remove a specific color gradient
  60924. * @param gradient defines the gradient to remove
  60925. * @returns the current particle system
  60926. */
  60927. removeColorGradient(gradient: number): GPUParticleSystem;
  60928. private _angularSpeedGradientsTexture;
  60929. private _sizeGradientsTexture;
  60930. private _velocityGradientsTexture;
  60931. private _limitVelocityGradientsTexture;
  60932. private _dragGradientsTexture;
  60933. private _addFactorGradient;
  60934. /**
  60935. * Adds a new size gradient
  60936. * @param gradient defines the gradient to use (between 0 and 1)
  60937. * @param factor defines the size factor to affect to the specified gradient
  60938. * @returns the current particle system
  60939. */
  60940. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60941. /**
  60942. * Remove a specific size gradient
  60943. * @param gradient defines the gradient to remove
  60944. * @returns the current particle system
  60945. */
  60946. removeSizeGradient(gradient: number): GPUParticleSystem;
  60947. /**
  60948. * Adds a new angular speed gradient
  60949. * @param gradient defines the gradient to use (between 0 and 1)
  60950. * @param factor defines the angular speed to affect to the specified gradient
  60951. * @returns the current particle system
  60952. */
  60953. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60954. /**
  60955. * Remove a specific angular speed gradient
  60956. * @param gradient defines the gradient to remove
  60957. * @returns the current particle system
  60958. */
  60959. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60960. /**
  60961. * Adds a new velocity gradient
  60962. * @param gradient defines the gradient to use (between 0 and 1)
  60963. * @param factor defines the velocity to affect to the specified gradient
  60964. * @returns the current particle system
  60965. */
  60966. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60967. /**
  60968. * Remove a specific velocity gradient
  60969. * @param gradient defines the gradient to remove
  60970. * @returns the current particle system
  60971. */
  60972. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60973. /**
  60974. * Adds a new limit velocity gradient
  60975. * @param gradient defines the gradient to use (between 0 and 1)
  60976. * @param factor defines the limit velocity value to affect to the specified gradient
  60977. * @returns the current particle system
  60978. */
  60979. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60980. /**
  60981. * Remove a specific limit velocity gradient
  60982. * @param gradient defines the gradient to remove
  60983. * @returns the current particle system
  60984. */
  60985. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60986. /**
  60987. * Adds a new drag gradient
  60988. * @param gradient defines the gradient to use (between 0 and 1)
  60989. * @param factor defines the drag value to affect to the specified gradient
  60990. * @returns the current particle system
  60991. */
  60992. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60993. /**
  60994. * Remove a specific drag gradient
  60995. * @param gradient defines the gradient to remove
  60996. * @returns the current particle system
  60997. */
  60998. removeDragGradient(gradient: number): GPUParticleSystem;
  60999. /**
  61000. * Not supported by GPUParticleSystem
  61001. * @param gradient defines the gradient to use (between 0 and 1)
  61002. * @param factor defines the emit rate value to affect to the specified gradient
  61003. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61004. * @returns the current particle system
  61005. */
  61006. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61007. /**
  61008. * Not supported by GPUParticleSystem
  61009. * @param gradient defines the gradient to remove
  61010. * @returns the current particle system
  61011. */
  61012. removeEmitRateGradient(gradient: number): IParticleSystem;
  61013. /**
  61014. * Not supported by GPUParticleSystem
  61015. * @param gradient defines the gradient to use (between 0 and 1)
  61016. * @param factor defines the start size value to affect to the specified gradient
  61017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61018. * @returns the current particle system
  61019. */
  61020. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61021. /**
  61022. * Not supported by GPUParticleSystem
  61023. * @param gradient defines the gradient to remove
  61024. * @returns the current particle system
  61025. */
  61026. removeStartSizeGradient(gradient: number): IParticleSystem;
  61027. /**
  61028. * Not supported by GPUParticleSystem
  61029. * @param gradient defines the gradient to use (between 0 and 1)
  61030. * @param min defines the color remap minimal range
  61031. * @param max defines the color remap maximal range
  61032. * @returns the current particle system
  61033. */
  61034. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61035. /**
  61036. * Not supported by GPUParticleSystem
  61037. * @param gradient defines the gradient to remove
  61038. * @returns the current particle system
  61039. */
  61040. removeColorRemapGradient(): IParticleSystem;
  61041. /**
  61042. * Not supported by GPUParticleSystem
  61043. * @param gradient defines the gradient to use (between 0 and 1)
  61044. * @param min defines the alpha remap minimal range
  61045. * @param max defines the alpha remap maximal range
  61046. * @returns the current particle system
  61047. */
  61048. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61049. /**
  61050. * Not supported by GPUParticleSystem
  61051. * @param gradient defines the gradient to remove
  61052. * @returns the current particle system
  61053. */
  61054. removeAlphaRemapGradient(): IParticleSystem;
  61055. /**
  61056. * Not supported by GPUParticleSystem
  61057. * @param gradient defines the gradient to use (between 0 and 1)
  61058. * @param color defines the color to affect to the specified gradient
  61059. * @returns the current particle system
  61060. */
  61061. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61062. /**
  61063. * Not supported by GPUParticleSystem
  61064. * @param gradient defines the gradient to remove
  61065. * @returns the current particle system
  61066. */
  61067. removeRampGradient(): IParticleSystem;
  61068. /**
  61069. * Not supported by GPUParticleSystem
  61070. * @returns the list of ramp gradients
  61071. */
  61072. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61073. /**
  61074. * Not supported by GPUParticleSystem
  61075. * Gets or sets a boolean indicating that ramp gradients must be used
  61076. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61077. */
  61078. useRampGradients: boolean;
  61079. /**
  61080. * Not supported by GPUParticleSystem
  61081. * @param gradient defines the gradient to use (between 0 and 1)
  61082. * @param factor defines the life time factor to affect to the specified gradient
  61083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61084. * @returns the current particle system
  61085. */
  61086. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61087. /**
  61088. * Not supported by GPUParticleSystem
  61089. * @param gradient defines the gradient to remove
  61090. * @returns the current particle system
  61091. */
  61092. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61093. /**
  61094. * Instantiates a GPU particle system.
  61095. * 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.
  61096. * @param name The name of the particle system
  61097. * @param options The options used to create the system
  61098. * @param scene The scene the particle system belongs to
  61099. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61100. */
  61101. constructor(name: string, options: Partial<{
  61102. capacity: number;
  61103. randomTextureSize: number;
  61104. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61105. protected _reset(): void;
  61106. private _createUpdateVAO;
  61107. private _createRenderVAO;
  61108. private _initialize;
  61109. /** @hidden */
  61110. _recreateUpdateEffect(): void;
  61111. /** @hidden */
  61112. _recreateRenderEffect(): void;
  61113. /**
  61114. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61115. * @param preWarm defines if we are in the pre-warmimg phase
  61116. */
  61117. animate(preWarm?: boolean): void;
  61118. private _createFactorGradientTexture;
  61119. private _createSizeGradientTexture;
  61120. private _createAngularSpeedGradientTexture;
  61121. private _createVelocityGradientTexture;
  61122. private _createLimitVelocityGradientTexture;
  61123. private _createDragGradientTexture;
  61124. private _createColorGradientTexture;
  61125. /**
  61126. * Renders the particle system in its current state
  61127. * @param preWarm defines if the system should only update the particles but not render them
  61128. * @returns the current number of particles
  61129. */
  61130. render(preWarm?: boolean): number;
  61131. /**
  61132. * Rebuilds the particle system
  61133. */
  61134. rebuild(): void;
  61135. private _releaseBuffers;
  61136. private _releaseVAOs;
  61137. /**
  61138. * Disposes the particle system and free the associated resources
  61139. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61140. */
  61141. dispose(disposeTexture?: boolean): void;
  61142. /**
  61143. * Clones the particle system.
  61144. * @param name The name of the cloned object
  61145. * @param newEmitter The new emitter to use
  61146. * @returns the cloned particle system
  61147. */
  61148. clone(name: string, newEmitter: any): GPUParticleSystem;
  61149. /**
  61150. * Serializes the particle system to a JSON object.
  61151. * @returns the JSON object
  61152. */
  61153. serialize(): any;
  61154. /**
  61155. * Parses a JSON object to create a GPU particle system.
  61156. * @param parsedParticleSystem The JSON object to parse
  61157. * @param scene The scene to create the particle system in
  61158. * @param rootUrl The root url to use to load external dependencies like texture
  61159. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61160. * @returns the parsed GPU particle system
  61161. */
  61162. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61163. }
  61164. }
  61165. declare module "babylonjs/Particles/particleSystemSet" {
  61166. import { Nullable } from "babylonjs/types";
  61167. import { Color3 } from "babylonjs/Maths/math.color";
  61168. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61170. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61171. import { Scene, IDisposable } from "babylonjs/scene";
  61172. /**
  61173. * Represents a set of particle systems working together to create a specific effect
  61174. */
  61175. export class ParticleSystemSet implements IDisposable {
  61176. private _emitterCreationOptions;
  61177. private _emitterNode;
  61178. /**
  61179. * Gets the particle system list
  61180. */
  61181. systems: IParticleSystem[];
  61182. /**
  61183. * Gets the emitter node used with this set
  61184. */
  61185. readonly emitterNode: Nullable<TransformNode>;
  61186. /**
  61187. * Creates a new emitter mesh as a sphere
  61188. * @param options defines the options used to create the sphere
  61189. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61190. * @param scene defines the hosting scene
  61191. */
  61192. setEmitterAsSphere(options: {
  61193. diameter: number;
  61194. segments: number;
  61195. color: Color3;
  61196. }, renderingGroupId: number, scene: Scene): void;
  61197. /**
  61198. * Starts all particle systems of the set
  61199. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61200. */
  61201. start(emitter?: AbstractMesh): void;
  61202. /**
  61203. * Release all associated resources
  61204. */
  61205. dispose(): void;
  61206. /**
  61207. * Serialize the set into a JSON compatible object
  61208. * @returns a JSON compatible representation of the set
  61209. */
  61210. serialize(): any;
  61211. /**
  61212. * Parse a new ParticleSystemSet from a serialized source
  61213. * @param data defines a JSON compatible representation of the set
  61214. * @param scene defines the hosting scene
  61215. * @param gpu defines if we want GPU particles or CPU particles
  61216. * @returns a new ParticleSystemSet
  61217. */
  61218. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61219. }
  61220. }
  61221. declare module "babylonjs/Particles/particleHelper" {
  61222. import { Nullable } from "babylonjs/types";
  61223. import { Scene } from "babylonjs/scene";
  61224. import { Vector3 } from "babylonjs/Maths/math.vector";
  61225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61226. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61227. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61228. /**
  61229. * This class is made for on one-liner static method to help creating particle system set.
  61230. */
  61231. export class ParticleHelper {
  61232. /**
  61233. * Gets or sets base Assets URL
  61234. */
  61235. static BaseAssetsUrl: string;
  61236. /**
  61237. * Create a default particle system that you can tweak
  61238. * @param emitter defines the emitter to use
  61239. * @param capacity defines the system capacity (default is 500 particles)
  61240. * @param scene defines the hosting scene
  61241. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61242. * @returns the new Particle system
  61243. */
  61244. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61245. /**
  61246. * This is the main static method (one-liner) of this helper to create different particle systems
  61247. * @param type This string represents the type to the particle system to create
  61248. * @param scene The scene where the particle system should live
  61249. * @param gpu If the system will use gpu
  61250. * @returns the ParticleSystemSet created
  61251. */
  61252. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61253. /**
  61254. * Static function used to export a particle system to a ParticleSystemSet variable.
  61255. * Please note that the emitter shape is not exported
  61256. * @param systems defines the particle systems to export
  61257. * @returns the created particle system set
  61258. */
  61259. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61260. }
  61261. }
  61262. declare module "babylonjs/Particles/particleSystemComponent" {
  61263. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61264. import { Effect } from "babylonjs/Materials/effect";
  61265. import "babylonjs/Shaders/particles.vertex";
  61266. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61267. module "babylonjs/Engines/engine" {
  61268. interface Engine {
  61269. /**
  61270. * Create an effect to use with particle systems.
  61271. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61272. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61273. * @param uniformsNames defines a list of attribute names
  61274. * @param samplers defines an array of string used to represent textures
  61275. * @param defines defines the string containing the defines to use to compile the shaders
  61276. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61277. * @param onCompiled defines a function to call when the effect creation is successful
  61278. * @param onError defines a function to call when the effect creation has failed
  61279. * @returns the new Effect
  61280. */
  61281. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61282. }
  61283. }
  61284. module "babylonjs/Meshes/mesh" {
  61285. interface Mesh {
  61286. /**
  61287. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61288. * @returns an array of IParticleSystem
  61289. */
  61290. getEmittedParticleSystems(): IParticleSystem[];
  61291. /**
  61292. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61293. * @returns an array of IParticleSystem
  61294. */
  61295. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61296. }
  61297. }
  61298. /**
  61299. * @hidden
  61300. */
  61301. export var _IDoNeedToBeInTheBuild: number;
  61302. }
  61303. declare module "babylonjs/Particles/index" {
  61304. export * from "babylonjs/Particles/baseParticleSystem";
  61305. export * from "babylonjs/Particles/EmitterTypes/index";
  61306. export * from "babylonjs/Particles/gpuParticleSystem";
  61307. export * from "babylonjs/Particles/IParticleSystem";
  61308. export * from "babylonjs/Particles/particle";
  61309. export * from "babylonjs/Particles/particleHelper";
  61310. export * from "babylonjs/Particles/particleSystem";
  61311. export * from "babylonjs/Particles/particleSystemComponent";
  61312. export * from "babylonjs/Particles/particleSystemSet";
  61313. export * from "babylonjs/Particles/solidParticle";
  61314. export * from "babylonjs/Particles/solidParticleSystem";
  61315. export * from "babylonjs/Particles/subEmitter";
  61316. }
  61317. declare module "babylonjs/Physics/physicsEngineComponent" {
  61318. import { Nullable } from "babylonjs/types";
  61319. import { Observable, Observer } from "babylonjs/Misc/observable";
  61320. import { Vector3 } from "babylonjs/Maths/math.vector";
  61321. import { Mesh } from "babylonjs/Meshes/mesh";
  61322. import { ISceneComponent } from "babylonjs/sceneComponent";
  61323. import { Scene } from "babylonjs/scene";
  61324. import { Node } from "babylonjs/node";
  61325. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61326. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61327. module "babylonjs/scene" {
  61328. interface Scene {
  61329. /** @hidden (Backing field) */
  61330. _physicsEngine: Nullable<IPhysicsEngine>;
  61331. /**
  61332. * Gets the current physics engine
  61333. * @returns a IPhysicsEngine or null if none attached
  61334. */
  61335. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61336. /**
  61337. * Enables physics to the current scene
  61338. * @param gravity defines the scene's gravity for the physics engine
  61339. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61340. * @return a boolean indicating if the physics engine was initialized
  61341. */
  61342. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61343. /**
  61344. * Disables and disposes the physics engine associated with the scene
  61345. */
  61346. disablePhysicsEngine(): void;
  61347. /**
  61348. * Gets a boolean indicating if there is an active physics engine
  61349. * @returns a boolean indicating if there is an active physics engine
  61350. */
  61351. isPhysicsEnabled(): boolean;
  61352. /**
  61353. * Deletes a physics compound impostor
  61354. * @param compound defines the compound to delete
  61355. */
  61356. deleteCompoundImpostor(compound: any): void;
  61357. /**
  61358. * An event triggered when physic simulation is about to be run
  61359. */
  61360. onBeforePhysicsObservable: Observable<Scene>;
  61361. /**
  61362. * An event triggered when physic simulation has been done
  61363. */
  61364. onAfterPhysicsObservable: Observable<Scene>;
  61365. }
  61366. }
  61367. module "babylonjs/Meshes/abstractMesh" {
  61368. interface AbstractMesh {
  61369. /** @hidden */
  61370. _physicsImpostor: Nullable<PhysicsImpostor>;
  61371. /**
  61372. * Gets or sets impostor used for physic simulation
  61373. * @see http://doc.babylonjs.com/features/physics_engine
  61374. */
  61375. physicsImpostor: Nullable<PhysicsImpostor>;
  61376. /**
  61377. * Gets the current physics impostor
  61378. * @see http://doc.babylonjs.com/features/physics_engine
  61379. * @returns a physics impostor or null
  61380. */
  61381. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61382. /** Apply a physic impulse to the mesh
  61383. * @param force defines the force to apply
  61384. * @param contactPoint defines where to apply the force
  61385. * @returns the current mesh
  61386. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61387. */
  61388. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61389. /**
  61390. * Creates a physic joint between two meshes
  61391. * @param otherMesh defines the other mesh to use
  61392. * @param pivot1 defines the pivot to use on this mesh
  61393. * @param pivot2 defines the pivot to use on the other mesh
  61394. * @param options defines additional options (can be plugin dependent)
  61395. * @returns the current mesh
  61396. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61397. */
  61398. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61399. /** @hidden */
  61400. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61401. }
  61402. }
  61403. /**
  61404. * Defines the physics engine scene component responsible to manage a physics engine
  61405. */
  61406. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61407. /**
  61408. * The component name helpful to identify the component in the list of scene components.
  61409. */
  61410. readonly name: string;
  61411. /**
  61412. * The scene the component belongs to.
  61413. */
  61414. scene: Scene;
  61415. /**
  61416. * Creates a new instance of the component for the given scene
  61417. * @param scene Defines the scene to register the component in
  61418. */
  61419. constructor(scene: Scene);
  61420. /**
  61421. * Registers the component in a given scene
  61422. */
  61423. register(): void;
  61424. /**
  61425. * Rebuilds the elements related to this component in case of
  61426. * context lost for instance.
  61427. */
  61428. rebuild(): void;
  61429. /**
  61430. * Disposes the component and the associated ressources
  61431. */
  61432. dispose(): void;
  61433. }
  61434. }
  61435. declare module "babylonjs/Physics/physicsHelper" {
  61436. import { Nullable } from "babylonjs/types";
  61437. import { Vector3 } from "babylonjs/Maths/math.vector";
  61438. import { Mesh } from "babylonjs/Meshes/mesh";
  61439. import { Scene } from "babylonjs/scene";
  61440. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61441. /**
  61442. * A helper for physics simulations
  61443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61444. */
  61445. export class PhysicsHelper {
  61446. private _scene;
  61447. private _physicsEngine;
  61448. /**
  61449. * Initializes the Physics helper
  61450. * @param scene Babylon.js scene
  61451. */
  61452. constructor(scene: Scene);
  61453. /**
  61454. * Applies a radial explosion impulse
  61455. * @param origin the origin of the explosion
  61456. * @param radiusOrEventOptions the radius or the options of radial explosion
  61457. * @param strength the explosion strength
  61458. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61459. * @returns A physics radial explosion event, or null
  61460. */
  61461. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61462. /**
  61463. * Applies a radial explosion force
  61464. * @param origin the origin of the explosion
  61465. * @param radiusOrEventOptions the radius or the options of radial explosion
  61466. * @param strength the explosion strength
  61467. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61468. * @returns A physics radial explosion event, or null
  61469. */
  61470. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61471. /**
  61472. * Creates a gravitational field
  61473. * @param origin the origin of the explosion
  61474. * @param radiusOrEventOptions the radius or the options of radial explosion
  61475. * @param strength the explosion strength
  61476. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61477. * @returns A physics gravitational field event, or null
  61478. */
  61479. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61480. /**
  61481. * Creates a physics updraft event
  61482. * @param origin the origin of the updraft
  61483. * @param radiusOrEventOptions the radius or the options of the updraft
  61484. * @param strength the strength of the updraft
  61485. * @param height the height of the updraft
  61486. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61487. * @returns A physics updraft event, or null
  61488. */
  61489. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61490. /**
  61491. * Creates a physics vortex event
  61492. * @param origin the of the vortex
  61493. * @param radiusOrEventOptions the radius or the options of the vortex
  61494. * @param strength the strength of the vortex
  61495. * @param height the height of the vortex
  61496. * @returns a Physics vortex event, or null
  61497. * A physics vortex event or null
  61498. */
  61499. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61500. }
  61501. /**
  61502. * Represents a physics radial explosion event
  61503. */
  61504. class PhysicsRadialExplosionEvent {
  61505. private _scene;
  61506. private _options;
  61507. private _sphere;
  61508. private _dataFetched;
  61509. /**
  61510. * Initializes a radial explosioin event
  61511. * @param _scene BabylonJS scene
  61512. * @param _options The options for the vortex event
  61513. */
  61514. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61515. /**
  61516. * Returns the data related to the radial explosion event (sphere).
  61517. * @returns The radial explosion event data
  61518. */
  61519. getData(): PhysicsRadialExplosionEventData;
  61520. /**
  61521. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61522. * @param impostor A physics imposter
  61523. * @param origin the origin of the explosion
  61524. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61525. */
  61526. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61527. /**
  61528. * Triggers affecterd impostors callbacks
  61529. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61530. */
  61531. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61532. /**
  61533. * Disposes the sphere.
  61534. * @param force Specifies if the sphere should be disposed by force
  61535. */
  61536. dispose(force?: boolean): void;
  61537. /*** Helpers ***/
  61538. private _prepareSphere;
  61539. private _intersectsWithSphere;
  61540. }
  61541. /**
  61542. * Represents a gravitational field event
  61543. */
  61544. class PhysicsGravitationalFieldEvent {
  61545. private _physicsHelper;
  61546. private _scene;
  61547. private _origin;
  61548. private _options;
  61549. private _tickCallback;
  61550. private _sphere;
  61551. private _dataFetched;
  61552. /**
  61553. * Initializes the physics gravitational field event
  61554. * @param _physicsHelper A physics helper
  61555. * @param _scene BabylonJS scene
  61556. * @param _origin The origin position of the gravitational field event
  61557. * @param _options The options for the vortex event
  61558. */
  61559. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61560. /**
  61561. * Returns the data related to the gravitational field event (sphere).
  61562. * @returns A gravitational field event
  61563. */
  61564. getData(): PhysicsGravitationalFieldEventData;
  61565. /**
  61566. * Enables the gravitational field.
  61567. */
  61568. enable(): void;
  61569. /**
  61570. * Disables the gravitational field.
  61571. */
  61572. disable(): void;
  61573. /**
  61574. * Disposes the sphere.
  61575. * @param force The force to dispose from the gravitational field event
  61576. */
  61577. dispose(force?: boolean): void;
  61578. private _tick;
  61579. }
  61580. /**
  61581. * Represents a physics updraft event
  61582. */
  61583. class PhysicsUpdraftEvent {
  61584. private _scene;
  61585. private _origin;
  61586. private _options;
  61587. private _physicsEngine;
  61588. private _originTop;
  61589. private _originDirection;
  61590. private _tickCallback;
  61591. private _cylinder;
  61592. private _cylinderPosition;
  61593. private _dataFetched;
  61594. /**
  61595. * Initializes the physics updraft event
  61596. * @param _scene BabylonJS scene
  61597. * @param _origin The origin position of the updraft
  61598. * @param _options The options for the updraft event
  61599. */
  61600. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61601. /**
  61602. * Returns the data related to the updraft event (cylinder).
  61603. * @returns A physics updraft event
  61604. */
  61605. getData(): PhysicsUpdraftEventData;
  61606. /**
  61607. * Enables the updraft.
  61608. */
  61609. enable(): void;
  61610. /**
  61611. * Disables the updraft.
  61612. */
  61613. disable(): void;
  61614. /**
  61615. * Disposes the cylinder.
  61616. * @param force Specifies if the updraft should be disposed by force
  61617. */
  61618. dispose(force?: boolean): void;
  61619. private getImpostorHitData;
  61620. private _tick;
  61621. /*** Helpers ***/
  61622. private _prepareCylinder;
  61623. private _intersectsWithCylinder;
  61624. }
  61625. /**
  61626. * Represents a physics vortex event
  61627. */
  61628. class PhysicsVortexEvent {
  61629. private _scene;
  61630. private _origin;
  61631. private _options;
  61632. private _physicsEngine;
  61633. private _originTop;
  61634. private _tickCallback;
  61635. private _cylinder;
  61636. private _cylinderPosition;
  61637. private _dataFetched;
  61638. /**
  61639. * Initializes the physics vortex event
  61640. * @param _scene The BabylonJS scene
  61641. * @param _origin The origin position of the vortex
  61642. * @param _options The options for the vortex event
  61643. */
  61644. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61645. /**
  61646. * Returns the data related to the vortex event (cylinder).
  61647. * @returns The physics vortex event data
  61648. */
  61649. getData(): PhysicsVortexEventData;
  61650. /**
  61651. * Enables the vortex.
  61652. */
  61653. enable(): void;
  61654. /**
  61655. * Disables the cortex.
  61656. */
  61657. disable(): void;
  61658. /**
  61659. * Disposes the sphere.
  61660. * @param force
  61661. */
  61662. dispose(force?: boolean): void;
  61663. private getImpostorHitData;
  61664. private _tick;
  61665. /*** Helpers ***/
  61666. private _prepareCylinder;
  61667. private _intersectsWithCylinder;
  61668. }
  61669. /**
  61670. * Options fot the radial explosion event
  61671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61672. */
  61673. export class PhysicsRadialExplosionEventOptions {
  61674. /**
  61675. * The radius of the sphere for the radial explosion.
  61676. */
  61677. radius: number;
  61678. /**
  61679. * The strenth of the explosion.
  61680. */
  61681. strength: number;
  61682. /**
  61683. * The strenght of the force in correspondence to the distance of the affected object
  61684. */
  61685. falloff: PhysicsRadialImpulseFalloff;
  61686. /**
  61687. * Sphere options for the radial explosion.
  61688. */
  61689. sphere: {
  61690. segments: number;
  61691. diameter: number;
  61692. };
  61693. /**
  61694. * Sphere options for the radial explosion.
  61695. */
  61696. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61697. }
  61698. /**
  61699. * Options fot the updraft event
  61700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61701. */
  61702. export class PhysicsUpdraftEventOptions {
  61703. /**
  61704. * The radius of the cylinder for the vortex
  61705. */
  61706. radius: number;
  61707. /**
  61708. * The strenth of the updraft.
  61709. */
  61710. strength: number;
  61711. /**
  61712. * The height of the cylinder for the updraft.
  61713. */
  61714. height: number;
  61715. /**
  61716. * The mode for the the updraft.
  61717. */
  61718. updraftMode: PhysicsUpdraftMode;
  61719. }
  61720. /**
  61721. * Options fot the vortex event
  61722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61723. */
  61724. export class PhysicsVortexEventOptions {
  61725. /**
  61726. * The radius of the cylinder for the vortex
  61727. */
  61728. radius: number;
  61729. /**
  61730. * The strenth of the vortex.
  61731. */
  61732. strength: number;
  61733. /**
  61734. * The height of the cylinder for the vortex.
  61735. */
  61736. height: number;
  61737. /**
  61738. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61739. */
  61740. centripetalForceThreshold: number;
  61741. /**
  61742. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61743. */
  61744. centripetalForceMultiplier: number;
  61745. /**
  61746. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61747. */
  61748. centrifugalForceMultiplier: number;
  61749. /**
  61750. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61751. */
  61752. updraftForceMultiplier: number;
  61753. }
  61754. /**
  61755. * The strenght of the force in correspondence to the distance of the affected object
  61756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61757. */
  61758. export enum PhysicsRadialImpulseFalloff {
  61759. /** Defines that impulse is constant in strength across it's whole radius */
  61760. Constant = 0,
  61761. /** Defines that impulse gets weaker if it's further from the origin */
  61762. Linear = 1
  61763. }
  61764. /**
  61765. * The strength of the force in correspondence to the distance of the affected object
  61766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61767. */
  61768. export enum PhysicsUpdraftMode {
  61769. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61770. Center = 0,
  61771. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61772. Perpendicular = 1
  61773. }
  61774. /**
  61775. * Interface for a physics hit data
  61776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61777. */
  61778. export interface PhysicsHitData {
  61779. /**
  61780. * The force applied at the contact point
  61781. */
  61782. force: Vector3;
  61783. /**
  61784. * The contact point
  61785. */
  61786. contactPoint: Vector3;
  61787. /**
  61788. * The distance from the origin to the contact point
  61789. */
  61790. distanceFromOrigin: number;
  61791. }
  61792. /**
  61793. * Interface for radial explosion event data
  61794. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61795. */
  61796. export interface PhysicsRadialExplosionEventData {
  61797. /**
  61798. * A sphere used for the radial explosion event
  61799. */
  61800. sphere: Mesh;
  61801. }
  61802. /**
  61803. * Interface for gravitational field event data
  61804. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61805. */
  61806. export interface PhysicsGravitationalFieldEventData {
  61807. /**
  61808. * A sphere mesh used for the gravitational field event
  61809. */
  61810. sphere: Mesh;
  61811. }
  61812. /**
  61813. * Interface for updraft event data
  61814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61815. */
  61816. export interface PhysicsUpdraftEventData {
  61817. /**
  61818. * A cylinder used for the updraft event
  61819. */
  61820. cylinder: Mesh;
  61821. }
  61822. /**
  61823. * Interface for vortex event data
  61824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61825. */
  61826. export interface PhysicsVortexEventData {
  61827. /**
  61828. * A cylinder used for the vortex event
  61829. */
  61830. cylinder: Mesh;
  61831. }
  61832. /**
  61833. * Interface for an affected physics impostor
  61834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61835. */
  61836. export interface PhysicsAffectedImpostorWithData {
  61837. /**
  61838. * The impostor affected by the effect
  61839. */
  61840. impostor: PhysicsImpostor;
  61841. /**
  61842. * The data about the hit/horce from the explosion
  61843. */
  61844. hitData: PhysicsHitData;
  61845. }
  61846. }
  61847. declare module "babylonjs/Physics/Plugins/index" {
  61848. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  61849. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  61850. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  61851. }
  61852. declare module "babylonjs/Physics/index" {
  61853. export * from "babylonjs/Physics/IPhysicsEngine";
  61854. export * from "babylonjs/Physics/physicsEngine";
  61855. export * from "babylonjs/Physics/physicsEngineComponent";
  61856. export * from "babylonjs/Physics/physicsHelper";
  61857. export * from "babylonjs/Physics/physicsImpostor";
  61858. export * from "babylonjs/Physics/physicsJoint";
  61859. export * from "babylonjs/Physics/Plugins/index";
  61860. }
  61861. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  61862. /** @hidden */
  61863. export var blackAndWhitePixelShader: {
  61864. name: string;
  61865. shader: string;
  61866. };
  61867. }
  61868. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  61869. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61870. import { Camera } from "babylonjs/Cameras/camera";
  61871. import { Engine } from "babylonjs/Engines/engine";
  61872. import "babylonjs/Shaders/blackAndWhite.fragment";
  61873. /**
  61874. * Post process used to render in black and white
  61875. */
  61876. export class BlackAndWhitePostProcess extends PostProcess {
  61877. /**
  61878. * Linear about to convert he result to black and white (default: 1)
  61879. */
  61880. degree: number;
  61881. /**
  61882. * Creates a black and white post process
  61883. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61884. * @param name The name of the effect.
  61885. * @param options The required width/height ratio to downsize to before computing the render pass.
  61886. * @param camera The camera to apply the render pass to.
  61887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61888. * @param engine The engine which the post process will be applied. (default: current engine)
  61889. * @param reusable If the post process can be reused on the same frame. (default: false)
  61890. */
  61891. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61892. }
  61893. }
  61894. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  61895. import { Nullable } from "babylonjs/types";
  61896. import { Camera } from "babylonjs/Cameras/camera";
  61897. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61898. import { Engine } from "babylonjs/Engines/engine";
  61899. /**
  61900. * This represents a set of one or more post processes in Babylon.
  61901. * A post process can be used to apply a shader to a texture after it is rendered.
  61902. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61903. */
  61904. export class PostProcessRenderEffect {
  61905. private _postProcesses;
  61906. private _getPostProcesses;
  61907. private _singleInstance;
  61908. private _cameras;
  61909. private _indicesForCamera;
  61910. /**
  61911. * Name of the effect
  61912. * @hidden
  61913. */
  61914. _name: string;
  61915. /**
  61916. * Instantiates a post process render effect.
  61917. * A post process can be used to apply a shader to a texture after it is rendered.
  61918. * @param engine The engine the effect is tied to
  61919. * @param name The name of the effect
  61920. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61921. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61922. */
  61923. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61924. /**
  61925. * Checks if all the post processes in the effect are supported.
  61926. */
  61927. readonly isSupported: boolean;
  61928. /**
  61929. * Updates the current state of the effect
  61930. * @hidden
  61931. */
  61932. _update(): void;
  61933. /**
  61934. * Attaches the effect on cameras
  61935. * @param cameras The camera to attach to.
  61936. * @hidden
  61937. */
  61938. _attachCameras(cameras: Camera): void;
  61939. /**
  61940. * Attaches the effect on cameras
  61941. * @param cameras The camera to attach to.
  61942. * @hidden
  61943. */
  61944. _attachCameras(cameras: Camera[]): void;
  61945. /**
  61946. * Detaches the effect on cameras
  61947. * @param cameras The camera to detatch from.
  61948. * @hidden
  61949. */
  61950. _detachCameras(cameras: Camera): void;
  61951. /**
  61952. * Detatches the effect on cameras
  61953. * @param cameras The camera to detatch from.
  61954. * @hidden
  61955. */
  61956. _detachCameras(cameras: Camera[]): void;
  61957. /**
  61958. * Enables the effect on given cameras
  61959. * @param cameras The camera to enable.
  61960. * @hidden
  61961. */
  61962. _enable(cameras: Camera): void;
  61963. /**
  61964. * Enables the effect on given cameras
  61965. * @param cameras The camera to enable.
  61966. * @hidden
  61967. */
  61968. _enable(cameras: Nullable<Camera[]>): void;
  61969. /**
  61970. * Disables the effect on the given cameras
  61971. * @param cameras The camera to disable.
  61972. * @hidden
  61973. */
  61974. _disable(cameras: Camera): void;
  61975. /**
  61976. * Disables the effect on the given cameras
  61977. * @param cameras The camera to disable.
  61978. * @hidden
  61979. */
  61980. _disable(cameras: Nullable<Camera[]>): void;
  61981. /**
  61982. * Gets a list of the post processes contained in the effect.
  61983. * @param camera The camera to get the post processes on.
  61984. * @returns The list of the post processes in the effect.
  61985. */
  61986. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61987. }
  61988. }
  61989. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61990. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61991. /** @hidden */
  61992. export var extractHighlightsPixelShader: {
  61993. name: string;
  61994. shader: string;
  61995. };
  61996. }
  61997. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  61998. import { Nullable } from "babylonjs/types";
  61999. import { Camera } from "babylonjs/Cameras/camera";
  62000. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62001. import { Engine } from "babylonjs/Engines/engine";
  62002. import "babylonjs/Shaders/extractHighlights.fragment";
  62003. /**
  62004. * 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.
  62005. */
  62006. export class ExtractHighlightsPostProcess extends PostProcess {
  62007. /**
  62008. * The luminance threshold, pixels below this value will be set to black.
  62009. */
  62010. threshold: number;
  62011. /** @hidden */
  62012. _exposure: number;
  62013. /**
  62014. * Post process which has the input texture to be used when performing highlight extraction
  62015. * @hidden
  62016. */
  62017. _inputPostProcess: Nullable<PostProcess>;
  62018. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62019. }
  62020. }
  62021. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  62022. /** @hidden */
  62023. export var bloomMergePixelShader: {
  62024. name: string;
  62025. shader: string;
  62026. };
  62027. }
  62028. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  62029. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62030. import { Nullable } from "babylonjs/types";
  62031. import { Engine } from "babylonjs/Engines/engine";
  62032. import { Camera } from "babylonjs/Cameras/camera";
  62033. import "babylonjs/Shaders/bloomMerge.fragment";
  62034. /**
  62035. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62036. */
  62037. export class BloomMergePostProcess extends PostProcess {
  62038. /** Weight of the bloom to be added to the original input. */
  62039. weight: number;
  62040. /**
  62041. * Creates a new instance of @see BloomMergePostProcess
  62042. * @param name The name of the effect.
  62043. * @param originalFromInput Post process which's input will be used for the merge.
  62044. * @param blurred Blurred highlights post process which's output will be used.
  62045. * @param weight Weight of the bloom to be added to the original input.
  62046. * @param options The required width/height ratio to downsize to before computing the render pass.
  62047. * @param camera The camera to apply the render pass to.
  62048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62049. * @param engine The engine which the post process will be applied. (default: current engine)
  62050. * @param reusable If the post process can be reused on the same frame. (default: false)
  62051. * @param textureType Type of textures used when performing the post process. (default: 0)
  62052. * @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)
  62053. */
  62054. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62055. /** Weight of the bloom to be added to the original input. */
  62056. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62057. }
  62058. }
  62059. declare module "babylonjs/PostProcesses/bloomEffect" {
  62060. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62061. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62062. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62063. import { Camera } from "babylonjs/Cameras/camera";
  62064. import { Scene } from "babylonjs/scene";
  62065. /**
  62066. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62067. */
  62068. export class BloomEffect extends PostProcessRenderEffect {
  62069. private bloomScale;
  62070. /**
  62071. * @hidden Internal
  62072. */
  62073. _effects: Array<PostProcess>;
  62074. /**
  62075. * @hidden Internal
  62076. */
  62077. _downscale: ExtractHighlightsPostProcess;
  62078. private _blurX;
  62079. private _blurY;
  62080. private _merge;
  62081. /**
  62082. * The luminance threshold to find bright areas of the image to bloom.
  62083. */
  62084. threshold: number;
  62085. /**
  62086. * The strength of the bloom.
  62087. */
  62088. weight: number;
  62089. /**
  62090. * Specifies the size of the bloom blur kernel, relative to the final output size
  62091. */
  62092. kernel: number;
  62093. /**
  62094. * Creates a new instance of @see BloomEffect
  62095. * @param scene The scene the effect belongs to.
  62096. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62097. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62098. * @param bloomWeight The the strength of bloom.
  62099. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62100. * @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)
  62101. */
  62102. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62103. /**
  62104. * Disposes each of the internal effects for a given camera.
  62105. * @param camera The camera to dispose the effect on.
  62106. */
  62107. disposeEffects(camera: Camera): void;
  62108. /**
  62109. * @hidden Internal
  62110. */
  62111. _updateEffects(): void;
  62112. /**
  62113. * Internal
  62114. * @returns if all the contained post processes are ready.
  62115. * @hidden
  62116. */
  62117. _isReady(): boolean;
  62118. }
  62119. }
  62120. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62121. /** @hidden */
  62122. export var chromaticAberrationPixelShader: {
  62123. name: string;
  62124. shader: string;
  62125. };
  62126. }
  62127. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62128. import { Vector2 } from "babylonjs/Maths/math.vector";
  62129. import { Nullable } from "babylonjs/types";
  62130. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62131. import { Camera } from "babylonjs/Cameras/camera";
  62132. import { Engine } from "babylonjs/Engines/engine";
  62133. import "babylonjs/Shaders/chromaticAberration.fragment";
  62134. /**
  62135. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62136. */
  62137. export class ChromaticAberrationPostProcess extends PostProcess {
  62138. /**
  62139. * The amount of seperation of rgb channels (default: 30)
  62140. */
  62141. aberrationAmount: number;
  62142. /**
  62143. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62144. */
  62145. radialIntensity: number;
  62146. /**
  62147. * 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))
  62148. */
  62149. direction: Vector2;
  62150. /**
  62151. * 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))
  62152. */
  62153. centerPosition: Vector2;
  62154. /**
  62155. * Creates a new instance ChromaticAberrationPostProcess
  62156. * @param name The name of the effect.
  62157. * @param screenWidth The width of the screen to apply the effect on.
  62158. * @param screenHeight The height of the screen to apply the effect on.
  62159. * @param options The required width/height ratio to downsize to before computing the render pass.
  62160. * @param camera The camera to apply the render pass to.
  62161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62162. * @param engine The engine which the post process will be applied. (default: current engine)
  62163. * @param reusable If the post process can be reused on the same frame. (default: false)
  62164. * @param textureType Type of textures used when performing the post process. (default: 0)
  62165. * @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)
  62166. */
  62167. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62168. }
  62169. }
  62170. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62171. /** @hidden */
  62172. export var circleOfConfusionPixelShader: {
  62173. name: string;
  62174. shader: string;
  62175. };
  62176. }
  62177. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62178. import { Nullable } from "babylonjs/types";
  62179. import { Engine } from "babylonjs/Engines/engine";
  62180. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62181. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62182. import { Camera } from "babylonjs/Cameras/camera";
  62183. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62184. /**
  62185. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62186. */
  62187. export class CircleOfConfusionPostProcess extends PostProcess {
  62188. /**
  62189. * 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.
  62190. */
  62191. lensSize: number;
  62192. /**
  62193. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62194. */
  62195. fStop: number;
  62196. /**
  62197. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62198. */
  62199. focusDistance: number;
  62200. /**
  62201. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62202. */
  62203. focalLength: number;
  62204. private _depthTexture;
  62205. /**
  62206. * Creates a new instance CircleOfConfusionPostProcess
  62207. * @param name The name of the effect.
  62208. * @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.
  62209. * @param options The required width/height ratio to downsize to before computing the render pass.
  62210. * @param camera The camera to apply the render pass to.
  62211. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62212. * @param engine The engine which the post process will be applied. (default: current engine)
  62213. * @param reusable If the post process can be reused on the same frame. (default: false)
  62214. * @param textureType Type of textures used when performing the post process. (default: 0)
  62215. * @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)
  62216. */
  62217. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62218. /**
  62219. * 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.
  62220. */
  62221. depthTexture: RenderTargetTexture;
  62222. }
  62223. }
  62224. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62225. /** @hidden */
  62226. export var colorCorrectionPixelShader: {
  62227. name: string;
  62228. shader: string;
  62229. };
  62230. }
  62231. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62232. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62233. import { Engine } from "babylonjs/Engines/engine";
  62234. import { Camera } from "babylonjs/Cameras/camera";
  62235. import "babylonjs/Shaders/colorCorrection.fragment";
  62236. /**
  62237. *
  62238. * This post-process allows the modification of rendered colors by using
  62239. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62240. *
  62241. * The object needs to be provided an url to a texture containing the color
  62242. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62243. * Use an image editing software to tweak the LUT to match your needs.
  62244. *
  62245. * For an example of a color LUT, see here:
  62246. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62247. * For explanations on color grading, see here:
  62248. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62249. *
  62250. */
  62251. export class ColorCorrectionPostProcess extends PostProcess {
  62252. private _colorTableTexture;
  62253. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62254. }
  62255. }
  62256. declare module "babylonjs/Shaders/convolution.fragment" {
  62257. /** @hidden */
  62258. export var convolutionPixelShader: {
  62259. name: string;
  62260. shader: string;
  62261. };
  62262. }
  62263. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62264. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62265. import { Nullable } from "babylonjs/types";
  62266. import { Camera } from "babylonjs/Cameras/camera";
  62267. import { Engine } from "babylonjs/Engines/engine";
  62268. import "babylonjs/Shaders/convolution.fragment";
  62269. /**
  62270. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62271. * input texture to perform effects such as edge detection or sharpening
  62272. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62273. */
  62274. export class ConvolutionPostProcess extends PostProcess {
  62275. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62276. kernel: number[];
  62277. /**
  62278. * Creates a new instance ConvolutionPostProcess
  62279. * @param name The name of the effect.
  62280. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62281. * @param options The required width/height ratio to downsize to before computing the render pass.
  62282. * @param camera The camera to apply the render pass to.
  62283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62284. * @param engine The engine which the post process will be applied. (default: current engine)
  62285. * @param reusable If the post process can be reused on the same frame. (default: false)
  62286. * @param textureType Type of textures used when performing the post process. (default: 0)
  62287. */
  62288. constructor(name: string,
  62289. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62290. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62291. /**
  62292. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62293. */
  62294. static EdgeDetect0Kernel: number[];
  62295. /**
  62296. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62297. */
  62298. static EdgeDetect1Kernel: number[];
  62299. /**
  62300. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62301. */
  62302. static EdgeDetect2Kernel: number[];
  62303. /**
  62304. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62305. */
  62306. static SharpenKernel: number[];
  62307. /**
  62308. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62309. */
  62310. static EmbossKernel: number[];
  62311. /**
  62312. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62313. */
  62314. static GaussianKernel: number[];
  62315. }
  62316. }
  62317. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62318. import { Nullable } from "babylonjs/types";
  62319. import { Vector2 } from "babylonjs/Maths/math.vector";
  62320. import { Camera } from "babylonjs/Cameras/camera";
  62321. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62322. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62323. import { Engine } from "babylonjs/Engines/engine";
  62324. import { Scene } from "babylonjs/scene";
  62325. /**
  62326. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62327. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62328. * based on samples that have a large difference in distance than the center pixel.
  62329. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62330. */
  62331. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62332. direction: Vector2;
  62333. /**
  62334. * Creates a new instance CircleOfConfusionPostProcess
  62335. * @param name The name of the effect.
  62336. * @param scene The scene the effect belongs to.
  62337. * @param direction The direction the blur should be applied.
  62338. * @param kernel The size of the kernel used to blur.
  62339. * @param options The required width/height ratio to downsize to before computing the render pass.
  62340. * @param camera The camera to apply the render pass to.
  62341. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62342. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62343. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62344. * @param engine The engine which the post process will be applied. (default: current engine)
  62345. * @param reusable If the post process can be reused on the same frame. (default: false)
  62346. * @param textureType Type of textures used when performing the post process. (default: 0)
  62347. * @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)
  62348. */
  62349. 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);
  62350. }
  62351. }
  62352. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62353. /** @hidden */
  62354. export var depthOfFieldMergePixelShader: {
  62355. name: string;
  62356. shader: string;
  62357. };
  62358. }
  62359. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62360. import { Nullable } from "babylonjs/types";
  62361. import { Camera } from "babylonjs/Cameras/camera";
  62362. import { Effect } from "babylonjs/Materials/effect";
  62363. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62364. import { Engine } from "babylonjs/Engines/engine";
  62365. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62366. /**
  62367. * Options to be set when merging outputs from the default pipeline.
  62368. */
  62369. export class DepthOfFieldMergePostProcessOptions {
  62370. /**
  62371. * The original image to merge on top of
  62372. */
  62373. originalFromInput: PostProcess;
  62374. /**
  62375. * Parameters to perform the merge of the depth of field effect
  62376. */
  62377. depthOfField?: {
  62378. circleOfConfusion: PostProcess;
  62379. blurSteps: Array<PostProcess>;
  62380. };
  62381. /**
  62382. * Parameters to perform the merge of bloom effect
  62383. */
  62384. bloom?: {
  62385. blurred: PostProcess;
  62386. weight: number;
  62387. };
  62388. }
  62389. /**
  62390. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62391. */
  62392. export class DepthOfFieldMergePostProcess extends PostProcess {
  62393. private blurSteps;
  62394. /**
  62395. * Creates a new instance of DepthOfFieldMergePostProcess
  62396. * @param name The name of the effect.
  62397. * @param originalFromInput Post process which's input will be used for the merge.
  62398. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62399. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62400. * @param options The required width/height ratio to downsize to before computing the render pass.
  62401. * @param camera The camera to apply the render pass to.
  62402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62403. * @param engine The engine which the post process will be applied. (default: current engine)
  62404. * @param reusable If the post process can be reused on the same frame. (default: false)
  62405. * @param textureType Type of textures used when performing the post process. (default: 0)
  62406. * @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)
  62407. */
  62408. 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);
  62409. /**
  62410. * Updates the effect with the current post process compile time values and recompiles the shader.
  62411. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62412. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62413. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62414. * @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
  62415. * @param onCompiled Called when the shader has been compiled.
  62416. * @param onError Called if there is an error when compiling a shader.
  62417. */
  62418. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62419. }
  62420. }
  62421. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  62422. import { Nullable } from "babylonjs/types";
  62423. import { Camera } from "babylonjs/Cameras/camera";
  62424. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62425. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62426. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62427. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62428. import { Scene } from "babylonjs/scene";
  62429. /**
  62430. * Specifies the level of max blur that should be applied when using the depth of field effect
  62431. */
  62432. export enum DepthOfFieldEffectBlurLevel {
  62433. /**
  62434. * Subtle blur
  62435. */
  62436. Low = 0,
  62437. /**
  62438. * Medium blur
  62439. */
  62440. Medium = 1,
  62441. /**
  62442. * Large blur
  62443. */
  62444. High = 2
  62445. }
  62446. /**
  62447. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62448. */
  62449. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62450. private _circleOfConfusion;
  62451. /**
  62452. * @hidden Internal, blurs from high to low
  62453. */
  62454. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62455. private _depthOfFieldBlurY;
  62456. private _dofMerge;
  62457. /**
  62458. * @hidden Internal post processes in depth of field effect
  62459. */
  62460. _effects: Array<PostProcess>;
  62461. /**
  62462. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62463. */
  62464. focalLength: number;
  62465. /**
  62466. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62467. */
  62468. fStop: number;
  62469. /**
  62470. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62471. */
  62472. focusDistance: number;
  62473. /**
  62474. * 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.
  62475. */
  62476. lensSize: number;
  62477. /**
  62478. * Creates a new instance DepthOfFieldEffect
  62479. * @param scene The scene the effect belongs to.
  62480. * @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.
  62481. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62482. * @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)
  62483. */
  62484. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62485. /**
  62486. * Get the current class name of the current effet
  62487. * @returns "DepthOfFieldEffect"
  62488. */
  62489. getClassName(): string;
  62490. /**
  62491. * 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.
  62492. */
  62493. depthTexture: RenderTargetTexture;
  62494. /**
  62495. * Disposes each of the internal effects for a given camera.
  62496. * @param camera The camera to dispose the effect on.
  62497. */
  62498. disposeEffects(camera: Camera): void;
  62499. /**
  62500. * @hidden Internal
  62501. */
  62502. _updateEffects(): void;
  62503. /**
  62504. * Internal
  62505. * @returns if all the contained post processes are ready.
  62506. * @hidden
  62507. */
  62508. _isReady(): boolean;
  62509. }
  62510. }
  62511. declare module "babylonjs/Shaders/displayPass.fragment" {
  62512. /** @hidden */
  62513. export var displayPassPixelShader: {
  62514. name: string;
  62515. shader: string;
  62516. };
  62517. }
  62518. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  62519. import { Nullable } from "babylonjs/types";
  62520. import { Camera } from "babylonjs/Cameras/camera";
  62521. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62522. import { Engine } from "babylonjs/Engines/engine";
  62523. import "babylonjs/Shaders/displayPass.fragment";
  62524. /**
  62525. * DisplayPassPostProcess which produces an output the same as it's input
  62526. */
  62527. export class DisplayPassPostProcess extends PostProcess {
  62528. /**
  62529. * Creates the DisplayPassPostProcess
  62530. * @param name The name of the effect.
  62531. * @param options The required width/height ratio to downsize to before computing the render pass.
  62532. * @param camera The camera to apply the render pass to.
  62533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62534. * @param engine The engine which the post process will be applied. (default: current engine)
  62535. * @param reusable If the post process can be reused on the same frame. (default: false)
  62536. */
  62537. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62538. }
  62539. }
  62540. declare module "babylonjs/Shaders/filter.fragment" {
  62541. /** @hidden */
  62542. export var filterPixelShader: {
  62543. name: string;
  62544. shader: string;
  62545. };
  62546. }
  62547. declare module "babylonjs/PostProcesses/filterPostProcess" {
  62548. import { Nullable } from "babylonjs/types";
  62549. import { Matrix } from "babylonjs/Maths/math.vector";
  62550. import { Camera } from "babylonjs/Cameras/camera";
  62551. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62552. import { Engine } from "babylonjs/Engines/engine";
  62553. import "babylonjs/Shaders/filter.fragment";
  62554. /**
  62555. * Applies a kernel filter to the image
  62556. */
  62557. export class FilterPostProcess extends PostProcess {
  62558. /** The matrix to be applied to the image */
  62559. kernelMatrix: Matrix;
  62560. /**
  62561. *
  62562. * @param name The name of the effect.
  62563. * @param kernelMatrix The matrix to be applied to the image
  62564. * @param options The required width/height ratio to downsize to before computing the render pass.
  62565. * @param camera The camera to apply the render pass to.
  62566. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62567. * @param engine The engine which the post process will be applied. (default: current engine)
  62568. * @param reusable If the post process can be reused on the same frame. (default: false)
  62569. */
  62570. constructor(name: string,
  62571. /** The matrix to be applied to the image */
  62572. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62573. }
  62574. }
  62575. declare module "babylonjs/Shaders/fxaa.fragment" {
  62576. /** @hidden */
  62577. export var fxaaPixelShader: {
  62578. name: string;
  62579. shader: string;
  62580. };
  62581. }
  62582. declare module "babylonjs/Shaders/fxaa.vertex" {
  62583. /** @hidden */
  62584. export var fxaaVertexShader: {
  62585. name: string;
  62586. shader: string;
  62587. };
  62588. }
  62589. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  62590. import { Nullable } from "babylonjs/types";
  62591. import { Camera } from "babylonjs/Cameras/camera";
  62592. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62593. import { Engine } from "babylonjs/Engines/engine";
  62594. import "babylonjs/Shaders/fxaa.fragment";
  62595. import "babylonjs/Shaders/fxaa.vertex";
  62596. /**
  62597. * Fxaa post process
  62598. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62599. */
  62600. export class FxaaPostProcess extends PostProcess {
  62601. /** @hidden */
  62602. texelWidth: number;
  62603. /** @hidden */
  62604. texelHeight: number;
  62605. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62606. private _getDefines;
  62607. }
  62608. }
  62609. declare module "babylonjs/Shaders/grain.fragment" {
  62610. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62611. /** @hidden */
  62612. export var grainPixelShader: {
  62613. name: string;
  62614. shader: string;
  62615. };
  62616. }
  62617. declare module "babylonjs/PostProcesses/grainPostProcess" {
  62618. import { Nullable } from "babylonjs/types";
  62619. import { Camera } from "babylonjs/Cameras/camera";
  62620. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62621. import { Engine } from "babylonjs/Engines/engine";
  62622. import "babylonjs/Shaders/grain.fragment";
  62623. /**
  62624. * The GrainPostProcess adds noise to the image at mid luminance levels
  62625. */
  62626. export class GrainPostProcess extends PostProcess {
  62627. /**
  62628. * The intensity of the grain added (default: 30)
  62629. */
  62630. intensity: number;
  62631. /**
  62632. * If the grain should be randomized on every frame
  62633. */
  62634. animated: boolean;
  62635. /**
  62636. * Creates a new instance of @see GrainPostProcess
  62637. * @param name The name of the effect.
  62638. * @param options The required width/height ratio to downsize to before computing the render pass.
  62639. * @param camera The camera to apply the render pass to.
  62640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62641. * @param engine The engine which the post process will be applied. (default: current engine)
  62642. * @param reusable If the post process can be reused on the same frame. (default: false)
  62643. * @param textureType Type of textures used when performing the post process. (default: 0)
  62644. * @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)
  62645. */
  62646. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62647. }
  62648. }
  62649. declare module "babylonjs/Shaders/highlights.fragment" {
  62650. /** @hidden */
  62651. export var highlightsPixelShader: {
  62652. name: string;
  62653. shader: string;
  62654. };
  62655. }
  62656. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  62657. import { Nullable } from "babylonjs/types";
  62658. import { Camera } from "babylonjs/Cameras/camera";
  62659. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62660. import { Engine } from "babylonjs/Engines/engine";
  62661. import "babylonjs/Shaders/highlights.fragment";
  62662. /**
  62663. * Extracts highlights from the image
  62664. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62665. */
  62666. export class HighlightsPostProcess extends PostProcess {
  62667. /**
  62668. * Extracts highlights from the image
  62669. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62670. * @param name The name of the effect.
  62671. * @param options The required width/height ratio to downsize to before computing the render pass.
  62672. * @param camera The camera to apply the render pass to.
  62673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62674. * @param engine The engine which the post process will be applied. (default: current engine)
  62675. * @param reusable If the post process can be reused on the same frame. (default: false)
  62676. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62677. */
  62678. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62679. }
  62680. }
  62681. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  62682. /** @hidden */
  62683. export var mrtFragmentDeclaration: {
  62684. name: string;
  62685. shader: string;
  62686. };
  62687. }
  62688. declare module "babylonjs/Shaders/geometry.fragment" {
  62689. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  62690. /** @hidden */
  62691. export var geometryPixelShader: {
  62692. name: string;
  62693. shader: string;
  62694. };
  62695. }
  62696. declare module "babylonjs/Shaders/geometry.vertex" {
  62697. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62698. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62699. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62700. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62701. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62702. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62703. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62704. /** @hidden */
  62705. export var geometryVertexShader: {
  62706. name: string;
  62707. shader: string;
  62708. };
  62709. }
  62710. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  62711. import { Matrix } from "babylonjs/Maths/math.vector";
  62712. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62713. import { Mesh } from "babylonjs/Meshes/mesh";
  62714. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  62715. import { Effect } from "babylonjs/Materials/effect";
  62716. import { Scene } from "babylonjs/scene";
  62717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62718. import "babylonjs/Shaders/geometry.fragment";
  62719. import "babylonjs/Shaders/geometry.vertex";
  62720. /** @hidden */
  62721. interface ISavedTransformationMatrix {
  62722. world: Matrix;
  62723. viewProjection: Matrix;
  62724. }
  62725. /**
  62726. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62727. */
  62728. export class GeometryBufferRenderer {
  62729. /**
  62730. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62731. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62732. */
  62733. static readonly POSITION_TEXTURE_TYPE: number;
  62734. /**
  62735. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62736. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62737. */
  62738. static readonly VELOCITY_TEXTURE_TYPE: number;
  62739. /**
  62740. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62741. * in order to compute objects velocities when enableVelocity is set to "true"
  62742. * @hidden
  62743. */
  62744. _previousTransformationMatrices: {
  62745. [index: number]: ISavedTransformationMatrix;
  62746. };
  62747. /**
  62748. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62749. * in order to compute objects velocities when enableVelocity is set to "true"
  62750. * @hidden
  62751. */
  62752. _previousBonesTransformationMatrices: {
  62753. [index: number]: Float32Array;
  62754. };
  62755. /**
  62756. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62757. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62758. */
  62759. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62760. private _scene;
  62761. private _multiRenderTarget;
  62762. private _ratio;
  62763. private _enablePosition;
  62764. private _enableVelocity;
  62765. private _positionIndex;
  62766. private _velocityIndex;
  62767. protected _effect: Effect;
  62768. protected _cachedDefines: string;
  62769. /**
  62770. * Set the render list (meshes to be rendered) used in the G buffer.
  62771. */
  62772. renderList: Mesh[];
  62773. /**
  62774. * Gets wether or not G buffer are supported by the running hardware.
  62775. * This requires draw buffer supports
  62776. */
  62777. readonly isSupported: boolean;
  62778. /**
  62779. * Returns the index of the given texture type in the G-Buffer textures array
  62780. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62781. * @returns the index of the given texture type in the G-Buffer textures array
  62782. */
  62783. getTextureIndex(textureType: number): number;
  62784. /**
  62785. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62786. */
  62787. /**
  62788. * Sets whether or not objects positions are enabled for the G buffer.
  62789. */
  62790. enablePosition: boolean;
  62791. /**
  62792. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62793. */
  62794. /**
  62795. * Sets wether or not objects velocities are enabled for the G buffer.
  62796. */
  62797. enableVelocity: boolean;
  62798. /**
  62799. * Gets the scene associated with the buffer.
  62800. */
  62801. readonly scene: Scene;
  62802. /**
  62803. * Gets the ratio used by the buffer during its creation.
  62804. * How big is the buffer related to the main canvas.
  62805. */
  62806. readonly ratio: number;
  62807. /** @hidden */
  62808. static _SceneComponentInitialization: (scene: Scene) => void;
  62809. /**
  62810. * Creates a new G Buffer for the scene
  62811. * @param scene The scene the buffer belongs to
  62812. * @param ratio How big is the buffer related to the main canvas.
  62813. */
  62814. constructor(scene: Scene, ratio?: number);
  62815. /**
  62816. * Checks wether everything is ready to render a submesh to the G buffer.
  62817. * @param subMesh the submesh to check readiness for
  62818. * @param useInstances is the mesh drawn using instance or not
  62819. * @returns true if ready otherwise false
  62820. */
  62821. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62822. /**
  62823. * Gets the current underlying G Buffer.
  62824. * @returns the buffer
  62825. */
  62826. getGBuffer(): MultiRenderTarget;
  62827. /**
  62828. * Gets the number of samples used to render the buffer (anti aliasing).
  62829. */
  62830. /**
  62831. * Sets the number of samples used to render the buffer (anti aliasing).
  62832. */
  62833. samples: number;
  62834. /**
  62835. * Disposes the renderer and frees up associated resources.
  62836. */
  62837. dispose(): void;
  62838. protected _createRenderTargets(): void;
  62839. private _copyBonesTransformationMatrices;
  62840. }
  62841. }
  62842. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  62843. import { Nullable } from "babylonjs/types";
  62844. import { Scene } from "babylonjs/scene";
  62845. import { ISceneComponent } from "babylonjs/sceneComponent";
  62846. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  62847. module "babylonjs/scene" {
  62848. interface Scene {
  62849. /** @hidden (Backing field) */
  62850. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62851. /**
  62852. * Gets or Sets the current geometry buffer associated to the scene.
  62853. */
  62854. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62855. /**
  62856. * Enables a GeometryBufferRender and associates it with the scene
  62857. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62858. * @returns the GeometryBufferRenderer
  62859. */
  62860. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62861. /**
  62862. * Disables the GeometryBufferRender associated with the scene
  62863. */
  62864. disableGeometryBufferRenderer(): void;
  62865. }
  62866. }
  62867. /**
  62868. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62869. * in several rendering techniques.
  62870. */
  62871. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62872. /**
  62873. * The component name helpful to identify the component in the list of scene components.
  62874. */
  62875. readonly name: string;
  62876. /**
  62877. * The scene the component belongs to.
  62878. */
  62879. scene: Scene;
  62880. /**
  62881. * Creates a new instance of the component for the given scene
  62882. * @param scene Defines the scene to register the component in
  62883. */
  62884. constructor(scene: Scene);
  62885. /**
  62886. * Registers the component in a given scene
  62887. */
  62888. register(): void;
  62889. /**
  62890. * Rebuilds the elements related to this component in case of
  62891. * context lost for instance.
  62892. */
  62893. rebuild(): void;
  62894. /**
  62895. * Disposes the component and the associated ressources
  62896. */
  62897. dispose(): void;
  62898. private _gatherRenderTargets;
  62899. }
  62900. }
  62901. declare module "babylonjs/Shaders/motionBlur.fragment" {
  62902. /** @hidden */
  62903. export var motionBlurPixelShader: {
  62904. name: string;
  62905. shader: string;
  62906. };
  62907. }
  62908. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  62909. import { Nullable } from "babylonjs/types";
  62910. import { Camera } from "babylonjs/Cameras/camera";
  62911. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62912. import { Scene } from "babylonjs/scene";
  62913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62914. import "babylonjs/Animations/animatable";
  62915. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62916. import "babylonjs/Shaders/motionBlur.fragment";
  62917. import { Engine } from "babylonjs/Engines/engine";
  62918. /**
  62919. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62920. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62921. * As an example, all you have to do is to create the post-process:
  62922. * var mb = new BABYLON.MotionBlurPostProcess(
  62923. * 'mb', // The name of the effect.
  62924. * scene, // The scene containing the objects to blur according to their velocity.
  62925. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62926. * camera // The camera to apply the render pass to.
  62927. * );
  62928. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62929. */
  62930. export class MotionBlurPostProcess extends PostProcess {
  62931. /**
  62932. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62933. */
  62934. motionStrength: number;
  62935. /**
  62936. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62937. */
  62938. /**
  62939. * Sets the number of iterations to be used for motion blur quality
  62940. */
  62941. motionBlurSamples: number;
  62942. private _motionBlurSamples;
  62943. private _geometryBufferRenderer;
  62944. /**
  62945. * Creates a new instance MotionBlurPostProcess
  62946. * @param name The name of the effect.
  62947. * @param scene The scene containing the objects to blur according to their velocity.
  62948. * @param options The required width/height ratio to downsize to before computing the render pass.
  62949. * @param camera The camera to apply the render pass to.
  62950. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62951. * @param engine The engine which the post process will be applied. (default: current engine)
  62952. * @param reusable If the post process can be reused on the same frame. (default: false)
  62953. * @param textureType Type of textures used when performing the post process. (default: 0)
  62954. * @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)
  62955. */
  62956. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62957. /**
  62958. * Excludes the given skinned mesh from computing bones velocities.
  62959. * 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.
  62960. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62961. */
  62962. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62963. /**
  62964. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62965. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62966. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62967. */
  62968. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62969. /**
  62970. * Disposes the post process.
  62971. * @param camera The camera to dispose the post process on.
  62972. */
  62973. dispose(camera?: Camera): void;
  62974. }
  62975. }
  62976. declare module "babylonjs/Shaders/refraction.fragment" {
  62977. /** @hidden */
  62978. export var refractionPixelShader: {
  62979. name: string;
  62980. shader: string;
  62981. };
  62982. }
  62983. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62984. import { Color3 } from "babylonjs/Maths/math.color";
  62985. import { Camera } from "babylonjs/Cameras/camera";
  62986. import { Texture } from "babylonjs/Materials/Textures/texture";
  62987. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62988. import { Engine } from "babylonjs/Engines/engine";
  62989. import "babylonjs/Shaders/refraction.fragment";
  62990. /**
  62991. * Post process which applies a refractin texture
  62992. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62993. */
  62994. export class RefractionPostProcess extends PostProcess {
  62995. /** the base color of the refraction (used to taint the rendering) */
  62996. color: Color3;
  62997. /** simulated refraction depth */
  62998. depth: number;
  62999. /** the coefficient of the base color (0 to remove base color tainting) */
  63000. colorLevel: number;
  63001. private _refTexture;
  63002. private _ownRefractionTexture;
  63003. /**
  63004. * Gets or sets the refraction texture
  63005. * Please note that you are responsible for disposing the texture if you set it manually
  63006. */
  63007. refractionTexture: Texture;
  63008. /**
  63009. * Initializes the RefractionPostProcess
  63010. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63011. * @param name The name of the effect.
  63012. * @param refractionTextureUrl Url of the refraction texture to use
  63013. * @param color the base color of the refraction (used to taint the rendering)
  63014. * @param depth simulated refraction depth
  63015. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63016. * @param camera The camera to apply the render pass to.
  63017. * @param options The required width/height ratio to downsize to before computing the render pass.
  63018. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63019. * @param engine The engine which the post process will be applied. (default: current engine)
  63020. * @param reusable If the post process can be reused on the same frame. (default: false)
  63021. */
  63022. constructor(name: string, refractionTextureUrl: string,
  63023. /** the base color of the refraction (used to taint the rendering) */
  63024. color: Color3,
  63025. /** simulated refraction depth */
  63026. depth: number,
  63027. /** the coefficient of the base color (0 to remove base color tainting) */
  63028. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63029. /**
  63030. * Disposes of the post process
  63031. * @param camera Camera to dispose post process on
  63032. */
  63033. dispose(camera: Camera): void;
  63034. }
  63035. }
  63036. declare module "babylonjs/Shaders/sharpen.fragment" {
  63037. /** @hidden */
  63038. export var sharpenPixelShader: {
  63039. name: string;
  63040. shader: string;
  63041. };
  63042. }
  63043. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  63044. import { Nullable } from "babylonjs/types";
  63045. import { Camera } from "babylonjs/Cameras/camera";
  63046. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63047. import "babylonjs/Shaders/sharpen.fragment";
  63048. import { Engine } from "babylonjs/Engines/engine";
  63049. /**
  63050. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63051. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63052. */
  63053. export class SharpenPostProcess extends PostProcess {
  63054. /**
  63055. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63056. */
  63057. colorAmount: number;
  63058. /**
  63059. * How much sharpness should be applied (default: 0.3)
  63060. */
  63061. edgeAmount: number;
  63062. /**
  63063. * Creates a new instance ConvolutionPostProcess
  63064. * @param name The name of the effect.
  63065. * @param options The required width/height ratio to downsize to before computing the render pass.
  63066. * @param camera The camera to apply the render pass to.
  63067. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63068. * @param engine The engine which the post process will be applied. (default: current engine)
  63069. * @param reusable If the post process can be reused on the same frame. (default: false)
  63070. * @param textureType Type of textures used when performing the post process. (default: 0)
  63071. * @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)
  63072. */
  63073. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63074. }
  63075. }
  63076. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  63077. import { Nullable } from "babylonjs/types";
  63078. import { Camera } from "babylonjs/Cameras/camera";
  63079. import { Engine } from "babylonjs/Engines/engine";
  63080. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63081. import { IInspectable } from "babylonjs/Misc/iInspectable";
  63082. /**
  63083. * PostProcessRenderPipeline
  63084. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63085. */
  63086. export class PostProcessRenderPipeline {
  63087. private engine;
  63088. private _renderEffects;
  63089. private _renderEffectsForIsolatedPass;
  63090. /**
  63091. * List of inspectable custom properties (used by the Inspector)
  63092. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63093. */
  63094. inspectableCustomProperties: IInspectable[];
  63095. /**
  63096. * @hidden
  63097. */
  63098. protected _cameras: Camera[];
  63099. /** @hidden */
  63100. _name: string;
  63101. /**
  63102. * Gets pipeline name
  63103. */
  63104. readonly name: string;
  63105. /**
  63106. * Initializes a PostProcessRenderPipeline
  63107. * @param engine engine to add the pipeline to
  63108. * @param name name of the pipeline
  63109. */
  63110. constructor(engine: Engine, name: string);
  63111. /**
  63112. * Gets the class name
  63113. * @returns "PostProcessRenderPipeline"
  63114. */
  63115. getClassName(): string;
  63116. /**
  63117. * If all the render effects in the pipeline are supported
  63118. */
  63119. readonly isSupported: boolean;
  63120. /**
  63121. * Adds an effect to the pipeline
  63122. * @param renderEffect the effect to add
  63123. */
  63124. addEffect(renderEffect: PostProcessRenderEffect): void;
  63125. /** @hidden */
  63126. _rebuild(): void;
  63127. /** @hidden */
  63128. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63129. /** @hidden */
  63130. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63131. /** @hidden */
  63132. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63133. /** @hidden */
  63134. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63135. /** @hidden */
  63136. _attachCameras(cameras: Camera, unique: boolean): void;
  63137. /** @hidden */
  63138. _attachCameras(cameras: Camera[], unique: boolean): void;
  63139. /** @hidden */
  63140. _detachCameras(cameras: Camera): void;
  63141. /** @hidden */
  63142. _detachCameras(cameras: Nullable<Camera[]>): void;
  63143. /** @hidden */
  63144. _update(): void;
  63145. /** @hidden */
  63146. _reset(): void;
  63147. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63148. /**
  63149. * Disposes of the pipeline
  63150. */
  63151. dispose(): void;
  63152. }
  63153. }
  63154. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63155. import { Camera } from "babylonjs/Cameras/camera";
  63156. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63157. /**
  63158. * PostProcessRenderPipelineManager class
  63159. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63160. */
  63161. export class PostProcessRenderPipelineManager {
  63162. private _renderPipelines;
  63163. /**
  63164. * Initializes a PostProcessRenderPipelineManager
  63165. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63166. */
  63167. constructor();
  63168. /**
  63169. * Gets the list of supported render pipelines
  63170. */
  63171. readonly supportedPipelines: PostProcessRenderPipeline[];
  63172. /**
  63173. * Adds a pipeline to the manager
  63174. * @param renderPipeline The pipeline to add
  63175. */
  63176. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63177. /**
  63178. * Attaches a camera to the pipeline
  63179. * @param renderPipelineName The name of the pipeline to attach to
  63180. * @param cameras the camera to attach
  63181. * @param unique if the camera can be attached multiple times to the pipeline
  63182. */
  63183. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63184. /**
  63185. * Detaches a camera from the pipeline
  63186. * @param renderPipelineName The name of the pipeline to detach from
  63187. * @param cameras the camera to detach
  63188. */
  63189. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63190. /**
  63191. * Enables an effect by name on a pipeline
  63192. * @param renderPipelineName the name of the pipeline to enable the effect in
  63193. * @param renderEffectName the name of the effect to enable
  63194. * @param cameras the cameras that the effect should be enabled on
  63195. */
  63196. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63197. /**
  63198. * Disables an effect by name on a pipeline
  63199. * @param renderPipelineName the name of the pipeline to disable the effect in
  63200. * @param renderEffectName the name of the effect to disable
  63201. * @param cameras the cameras that the effect should be disabled on
  63202. */
  63203. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63204. /**
  63205. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63206. */
  63207. update(): void;
  63208. /** @hidden */
  63209. _rebuild(): void;
  63210. /**
  63211. * Disposes of the manager and pipelines
  63212. */
  63213. dispose(): void;
  63214. }
  63215. }
  63216. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63217. import { ISceneComponent } from "babylonjs/sceneComponent";
  63218. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63219. import { Scene } from "babylonjs/scene";
  63220. module "babylonjs/scene" {
  63221. interface Scene {
  63222. /** @hidden (Backing field) */
  63223. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63224. /**
  63225. * Gets the postprocess render pipeline manager
  63226. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63227. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63228. */
  63229. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63230. }
  63231. }
  63232. /**
  63233. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63234. */
  63235. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63236. /**
  63237. * The component name helpfull to identify the component in the list of scene components.
  63238. */
  63239. readonly name: string;
  63240. /**
  63241. * The scene the component belongs to.
  63242. */
  63243. scene: Scene;
  63244. /**
  63245. * Creates a new instance of the component for the given scene
  63246. * @param scene Defines the scene to register the component in
  63247. */
  63248. constructor(scene: Scene);
  63249. /**
  63250. * Registers the component in a given scene
  63251. */
  63252. register(): void;
  63253. /**
  63254. * Rebuilds the elements related to this component in case of
  63255. * context lost for instance.
  63256. */
  63257. rebuild(): void;
  63258. /**
  63259. * Disposes the component and the associated ressources
  63260. */
  63261. dispose(): void;
  63262. private _gatherRenderTargets;
  63263. }
  63264. }
  63265. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63266. import { Nullable } from "babylonjs/types";
  63267. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63268. import { Camera } from "babylonjs/Cameras/camera";
  63269. import { IDisposable } from "babylonjs/scene";
  63270. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63271. import { Scene } from "babylonjs/scene";
  63272. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63273. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63274. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63275. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63276. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63277. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63278. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63279. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63280. import { Animation } from "babylonjs/Animations/animation";
  63281. /**
  63282. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63283. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63284. */
  63285. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63286. private _scene;
  63287. private _camerasToBeAttached;
  63288. /**
  63289. * ID of the sharpen post process,
  63290. */
  63291. private readonly SharpenPostProcessId;
  63292. /**
  63293. * @ignore
  63294. * ID of the image processing post process;
  63295. */
  63296. readonly ImageProcessingPostProcessId: string;
  63297. /**
  63298. * @ignore
  63299. * ID of the Fast Approximate Anti-Aliasing post process;
  63300. */
  63301. readonly FxaaPostProcessId: string;
  63302. /**
  63303. * ID of the chromatic aberration post process,
  63304. */
  63305. private readonly ChromaticAberrationPostProcessId;
  63306. /**
  63307. * ID of the grain post process
  63308. */
  63309. private readonly GrainPostProcessId;
  63310. /**
  63311. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63312. */
  63313. sharpen: SharpenPostProcess;
  63314. private _sharpenEffect;
  63315. private bloom;
  63316. /**
  63317. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63318. */
  63319. depthOfField: DepthOfFieldEffect;
  63320. /**
  63321. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63322. */
  63323. fxaa: FxaaPostProcess;
  63324. /**
  63325. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63326. */
  63327. imageProcessing: ImageProcessingPostProcess;
  63328. /**
  63329. * Chromatic aberration post process which will shift rgb colors in the image
  63330. */
  63331. chromaticAberration: ChromaticAberrationPostProcess;
  63332. private _chromaticAberrationEffect;
  63333. /**
  63334. * Grain post process which add noise to the image
  63335. */
  63336. grain: GrainPostProcess;
  63337. private _grainEffect;
  63338. /**
  63339. * Glow post process which adds a glow to emissive areas of the image
  63340. */
  63341. private _glowLayer;
  63342. /**
  63343. * Animations which can be used to tweak settings over a period of time
  63344. */
  63345. animations: Animation[];
  63346. private _imageProcessingConfigurationObserver;
  63347. private _sharpenEnabled;
  63348. private _bloomEnabled;
  63349. private _depthOfFieldEnabled;
  63350. private _depthOfFieldBlurLevel;
  63351. private _fxaaEnabled;
  63352. private _imageProcessingEnabled;
  63353. private _defaultPipelineTextureType;
  63354. private _bloomScale;
  63355. private _chromaticAberrationEnabled;
  63356. private _grainEnabled;
  63357. private _buildAllowed;
  63358. /**
  63359. * Gets active scene
  63360. */
  63361. readonly scene: Scene;
  63362. /**
  63363. * Enable or disable the sharpen process from the pipeline
  63364. */
  63365. sharpenEnabled: boolean;
  63366. private _resizeObserver;
  63367. private _hardwareScaleLevel;
  63368. private _bloomKernel;
  63369. /**
  63370. * Specifies the size of the bloom blur kernel, relative to the final output size
  63371. */
  63372. bloomKernel: number;
  63373. /**
  63374. * Specifies the weight of the bloom in the final rendering
  63375. */
  63376. private _bloomWeight;
  63377. /**
  63378. * Specifies the luma threshold for the area that will be blurred by the bloom
  63379. */
  63380. private _bloomThreshold;
  63381. private _hdr;
  63382. /**
  63383. * The strength of the bloom.
  63384. */
  63385. bloomWeight: number;
  63386. /**
  63387. * The strength of the bloom.
  63388. */
  63389. bloomThreshold: number;
  63390. /**
  63391. * The scale of the bloom, lower value will provide better performance.
  63392. */
  63393. bloomScale: number;
  63394. /**
  63395. * Enable or disable the bloom from the pipeline
  63396. */
  63397. bloomEnabled: boolean;
  63398. private _rebuildBloom;
  63399. /**
  63400. * If the depth of field is enabled.
  63401. */
  63402. depthOfFieldEnabled: boolean;
  63403. /**
  63404. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63405. */
  63406. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  63407. /**
  63408. * If the anti aliasing is enabled.
  63409. */
  63410. fxaaEnabled: boolean;
  63411. private _samples;
  63412. /**
  63413. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63414. */
  63415. samples: number;
  63416. /**
  63417. * If image processing is enabled.
  63418. */
  63419. imageProcessingEnabled: boolean;
  63420. /**
  63421. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63422. */
  63423. glowLayerEnabled: boolean;
  63424. /**
  63425. * Gets the glow layer (or null if not defined)
  63426. */
  63427. readonly glowLayer: Nullable<GlowLayer>;
  63428. /**
  63429. * Enable or disable the chromaticAberration process from the pipeline
  63430. */
  63431. chromaticAberrationEnabled: boolean;
  63432. /**
  63433. * Enable or disable the grain process from the pipeline
  63434. */
  63435. grainEnabled: boolean;
  63436. /**
  63437. * @constructor
  63438. * @param name - The rendering pipeline name (default: "")
  63439. * @param hdr - If high dynamic range textures should be used (default: true)
  63440. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63441. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63442. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63443. */
  63444. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63445. /**
  63446. * Get the class name
  63447. * @returns "DefaultRenderingPipeline"
  63448. */
  63449. getClassName(): string;
  63450. /**
  63451. * Force the compilation of the entire pipeline.
  63452. */
  63453. prepare(): void;
  63454. private _hasCleared;
  63455. private _prevPostProcess;
  63456. private _prevPrevPostProcess;
  63457. private _setAutoClearAndTextureSharing;
  63458. private _depthOfFieldSceneObserver;
  63459. private _buildPipeline;
  63460. private _disposePostProcesses;
  63461. /**
  63462. * Adds a camera to the pipeline
  63463. * @param camera the camera to be added
  63464. */
  63465. addCamera(camera: Camera): void;
  63466. /**
  63467. * Removes a camera from the pipeline
  63468. * @param camera the camera to remove
  63469. */
  63470. removeCamera(camera: Camera): void;
  63471. /**
  63472. * Dispose of the pipeline and stop all post processes
  63473. */
  63474. dispose(): void;
  63475. /**
  63476. * Serialize the rendering pipeline (Used when exporting)
  63477. * @returns the serialized object
  63478. */
  63479. serialize(): any;
  63480. /**
  63481. * Parse the serialized pipeline
  63482. * @param source Source pipeline.
  63483. * @param scene The scene to load the pipeline to.
  63484. * @param rootUrl The URL of the serialized pipeline.
  63485. * @returns An instantiated pipeline from the serialized object.
  63486. */
  63487. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63488. }
  63489. }
  63490. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  63491. /** @hidden */
  63492. export var lensHighlightsPixelShader: {
  63493. name: string;
  63494. shader: string;
  63495. };
  63496. }
  63497. declare module "babylonjs/Shaders/depthOfField.fragment" {
  63498. /** @hidden */
  63499. export var depthOfFieldPixelShader: {
  63500. name: string;
  63501. shader: string;
  63502. };
  63503. }
  63504. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  63505. import { Camera } from "babylonjs/Cameras/camera";
  63506. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63507. import { Scene } from "babylonjs/scene";
  63508. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63509. import "babylonjs/Shaders/chromaticAberration.fragment";
  63510. import "babylonjs/Shaders/lensHighlights.fragment";
  63511. import "babylonjs/Shaders/depthOfField.fragment";
  63512. /**
  63513. * BABYLON.JS Chromatic Aberration GLSL Shader
  63514. * Author: Olivier Guyot
  63515. * Separates very slightly R, G and B colors on the edges of the screen
  63516. * Inspired by Francois Tarlier & Martins Upitis
  63517. */
  63518. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63519. /**
  63520. * @ignore
  63521. * The chromatic aberration PostProcess id in the pipeline
  63522. */
  63523. LensChromaticAberrationEffect: string;
  63524. /**
  63525. * @ignore
  63526. * The highlights enhancing PostProcess id in the pipeline
  63527. */
  63528. HighlightsEnhancingEffect: string;
  63529. /**
  63530. * @ignore
  63531. * The depth-of-field PostProcess id in the pipeline
  63532. */
  63533. LensDepthOfFieldEffect: string;
  63534. private _scene;
  63535. private _depthTexture;
  63536. private _grainTexture;
  63537. private _chromaticAberrationPostProcess;
  63538. private _highlightsPostProcess;
  63539. private _depthOfFieldPostProcess;
  63540. private _edgeBlur;
  63541. private _grainAmount;
  63542. private _chromaticAberration;
  63543. private _distortion;
  63544. private _highlightsGain;
  63545. private _highlightsThreshold;
  63546. private _dofDistance;
  63547. private _dofAperture;
  63548. private _dofDarken;
  63549. private _dofPentagon;
  63550. private _blurNoise;
  63551. /**
  63552. * @constructor
  63553. *
  63554. * Effect parameters are as follow:
  63555. * {
  63556. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63557. * edge_blur: number; // from 0 to x (1 for realism)
  63558. * distortion: number; // from 0 to x (1 for realism)
  63559. * grain_amount: number; // from 0 to 1
  63560. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63561. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63562. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63563. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63564. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63565. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63566. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63567. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63568. * }
  63569. * Note: if an effect parameter is unset, effect is disabled
  63570. *
  63571. * @param name The rendering pipeline name
  63572. * @param parameters - An object containing all parameters (see above)
  63573. * @param scene The scene linked to this pipeline
  63574. * @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)
  63575. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63576. */
  63577. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63578. /**
  63579. * Get the class name
  63580. * @returns "LensRenderingPipeline"
  63581. */
  63582. getClassName(): string;
  63583. /**
  63584. * Gets associated scene
  63585. */
  63586. readonly scene: Scene;
  63587. /**
  63588. * Gets or sets the edge blur
  63589. */
  63590. edgeBlur: number;
  63591. /**
  63592. * Gets or sets the grain amount
  63593. */
  63594. grainAmount: number;
  63595. /**
  63596. * Gets or sets the chromatic aberration amount
  63597. */
  63598. chromaticAberration: number;
  63599. /**
  63600. * Gets or sets the depth of field aperture
  63601. */
  63602. dofAperture: number;
  63603. /**
  63604. * Gets or sets the edge distortion
  63605. */
  63606. edgeDistortion: number;
  63607. /**
  63608. * Gets or sets the depth of field distortion
  63609. */
  63610. dofDistortion: number;
  63611. /**
  63612. * Gets or sets the darken out of focus amount
  63613. */
  63614. darkenOutOfFocus: number;
  63615. /**
  63616. * Gets or sets a boolean indicating if blur noise is enabled
  63617. */
  63618. blurNoise: boolean;
  63619. /**
  63620. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63621. */
  63622. pentagonBokeh: boolean;
  63623. /**
  63624. * Gets or sets the highlight grain amount
  63625. */
  63626. highlightsGain: number;
  63627. /**
  63628. * Gets or sets the highlight threshold
  63629. */
  63630. highlightsThreshold: number;
  63631. /**
  63632. * Sets the amount of blur at the edges
  63633. * @param amount blur amount
  63634. */
  63635. setEdgeBlur(amount: number): void;
  63636. /**
  63637. * Sets edge blur to 0
  63638. */
  63639. disableEdgeBlur(): void;
  63640. /**
  63641. * Sets the amout of grain
  63642. * @param amount Amount of grain
  63643. */
  63644. setGrainAmount(amount: number): void;
  63645. /**
  63646. * Set grain amount to 0
  63647. */
  63648. disableGrain(): void;
  63649. /**
  63650. * Sets the chromatic aberration amount
  63651. * @param amount amount of chromatic aberration
  63652. */
  63653. setChromaticAberration(amount: number): void;
  63654. /**
  63655. * Sets chromatic aberration amount to 0
  63656. */
  63657. disableChromaticAberration(): void;
  63658. /**
  63659. * Sets the EdgeDistortion amount
  63660. * @param amount amount of EdgeDistortion
  63661. */
  63662. setEdgeDistortion(amount: number): void;
  63663. /**
  63664. * Sets edge distortion to 0
  63665. */
  63666. disableEdgeDistortion(): void;
  63667. /**
  63668. * Sets the FocusDistance amount
  63669. * @param amount amount of FocusDistance
  63670. */
  63671. setFocusDistance(amount: number): void;
  63672. /**
  63673. * Disables depth of field
  63674. */
  63675. disableDepthOfField(): void;
  63676. /**
  63677. * Sets the Aperture amount
  63678. * @param amount amount of Aperture
  63679. */
  63680. setAperture(amount: number): void;
  63681. /**
  63682. * Sets the DarkenOutOfFocus amount
  63683. * @param amount amount of DarkenOutOfFocus
  63684. */
  63685. setDarkenOutOfFocus(amount: number): void;
  63686. private _pentagonBokehIsEnabled;
  63687. /**
  63688. * Creates a pentagon bokeh effect
  63689. */
  63690. enablePentagonBokeh(): void;
  63691. /**
  63692. * Disables the pentagon bokeh effect
  63693. */
  63694. disablePentagonBokeh(): void;
  63695. /**
  63696. * Enables noise blur
  63697. */
  63698. enableNoiseBlur(): void;
  63699. /**
  63700. * Disables noise blur
  63701. */
  63702. disableNoiseBlur(): void;
  63703. /**
  63704. * Sets the HighlightsGain amount
  63705. * @param amount amount of HighlightsGain
  63706. */
  63707. setHighlightsGain(amount: number): void;
  63708. /**
  63709. * Sets the HighlightsThreshold amount
  63710. * @param amount amount of HighlightsThreshold
  63711. */
  63712. setHighlightsThreshold(amount: number): void;
  63713. /**
  63714. * Disables highlights
  63715. */
  63716. disableHighlights(): void;
  63717. /**
  63718. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63719. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63720. */
  63721. dispose(disableDepthRender?: boolean): void;
  63722. private _createChromaticAberrationPostProcess;
  63723. private _createHighlightsPostProcess;
  63724. private _createDepthOfFieldPostProcess;
  63725. private _createGrainTexture;
  63726. }
  63727. }
  63728. declare module "babylonjs/Shaders/ssao2.fragment" {
  63729. /** @hidden */
  63730. export var ssao2PixelShader: {
  63731. name: string;
  63732. shader: string;
  63733. };
  63734. }
  63735. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  63736. /** @hidden */
  63737. export var ssaoCombinePixelShader: {
  63738. name: string;
  63739. shader: string;
  63740. };
  63741. }
  63742. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  63743. import { Camera } from "babylonjs/Cameras/camera";
  63744. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63745. import { Scene } from "babylonjs/scene";
  63746. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63747. import "babylonjs/Shaders/ssao2.fragment";
  63748. import "babylonjs/Shaders/ssaoCombine.fragment";
  63749. /**
  63750. * Render pipeline to produce ssao effect
  63751. */
  63752. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63753. /**
  63754. * @ignore
  63755. * The PassPostProcess id in the pipeline that contains the original scene color
  63756. */
  63757. SSAOOriginalSceneColorEffect: string;
  63758. /**
  63759. * @ignore
  63760. * The SSAO PostProcess id in the pipeline
  63761. */
  63762. SSAORenderEffect: string;
  63763. /**
  63764. * @ignore
  63765. * The horizontal blur PostProcess id in the pipeline
  63766. */
  63767. SSAOBlurHRenderEffect: string;
  63768. /**
  63769. * @ignore
  63770. * The vertical blur PostProcess id in the pipeline
  63771. */
  63772. SSAOBlurVRenderEffect: string;
  63773. /**
  63774. * @ignore
  63775. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63776. */
  63777. SSAOCombineRenderEffect: string;
  63778. /**
  63779. * The output strength of the SSAO post-process. Default value is 1.0.
  63780. */
  63781. totalStrength: number;
  63782. /**
  63783. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63784. */
  63785. maxZ: number;
  63786. /**
  63787. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63788. */
  63789. minZAspect: number;
  63790. private _samples;
  63791. /**
  63792. * Number of samples used for the SSAO calculations. Default value is 8
  63793. */
  63794. samples: number;
  63795. private _textureSamples;
  63796. /**
  63797. * Number of samples to use for antialiasing
  63798. */
  63799. textureSamples: number;
  63800. /**
  63801. * Ratio object used for SSAO ratio and blur ratio
  63802. */
  63803. private _ratio;
  63804. /**
  63805. * Dynamically generated sphere sampler.
  63806. */
  63807. private _sampleSphere;
  63808. /**
  63809. * Blur filter offsets
  63810. */
  63811. private _samplerOffsets;
  63812. private _expensiveBlur;
  63813. /**
  63814. * If bilateral blur should be used
  63815. */
  63816. expensiveBlur: boolean;
  63817. /**
  63818. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63819. */
  63820. radius: number;
  63821. /**
  63822. * The base color of the SSAO post-process
  63823. * The final result is "base + ssao" between [0, 1]
  63824. */
  63825. base: number;
  63826. /**
  63827. * Support test.
  63828. */
  63829. static readonly IsSupported: boolean;
  63830. private _scene;
  63831. private _depthTexture;
  63832. private _normalTexture;
  63833. private _randomTexture;
  63834. private _originalColorPostProcess;
  63835. private _ssaoPostProcess;
  63836. private _blurHPostProcess;
  63837. private _blurVPostProcess;
  63838. private _ssaoCombinePostProcess;
  63839. private _firstUpdate;
  63840. /**
  63841. * Gets active scene
  63842. */
  63843. readonly scene: Scene;
  63844. /**
  63845. * @constructor
  63846. * @param name The rendering pipeline name
  63847. * @param scene The scene linked to this pipeline
  63848. * @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 }
  63849. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63850. */
  63851. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63852. /**
  63853. * Get the class name
  63854. * @returns "SSAO2RenderingPipeline"
  63855. */
  63856. getClassName(): string;
  63857. /**
  63858. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63859. */
  63860. dispose(disableGeometryBufferRenderer?: boolean): void;
  63861. private _createBlurPostProcess;
  63862. /** @hidden */
  63863. _rebuild(): void;
  63864. private _bits;
  63865. private _radicalInverse_VdC;
  63866. private _hammersley;
  63867. private _hemisphereSample_uniform;
  63868. private _generateHemisphere;
  63869. private _createSSAOPostProcess;
  63870. private _createSSAOCombinePostProcess;
  63871. private _createRandomTexture;
  63872. /**
  63873. * Serialize the rendering pipeline (Used when exporting)
  63874. * @returns the serialized object
  63875. */
  63876. serialize(): any;
  63877. /**
  63878. * Parse the serialized pipeline
  63879. * @param source Source pipeline.
  63880. * @param scene The scene to load the pipeline to.
  63881. * @param rootUrl The URL of the serialized pipeline.
  63882. * @returns An instantiated pipeline from the serialized object.
  63883. */
  63884. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63885. }
  63886. }
  63887. declare module "babylonjs/Shaders/ssao.fragment" {
  63888. /** @hidden */
  63889. export var ssaoPixelShader: {
  63890. name: string;
  63891. shader: string;
  63892. };
  63893. }
  63894. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  63895. import { Camera } from "babylonjs/Cameras/camera";
  63896. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63897. import { Scene } from "babylonjs/scene";
  63898. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63899. import "babylonjs/Shaders/ssao.fragment";
  63900. import "babylonjs/Shaders/ssaoCombine.fragment";
  63901. /**
  63902. * Render pipeline to produce ssao effect
  63903. */
  63904. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63905. /**
  63906. * @ignore
  63907. * The PassPostProcess id in the pipeline that contains the original scene color
  63908. */
  63909. SSAOOriginalSceneColorEffect: string;
  63910. /**
  63911. * @ignore
  63912. * The SSAO PostProcess id in the pipeline
  63913. */
  63914. SSAORenderEffect: string;
  63915. /**
  63916. * @ignore
  63917. * The horizontal blur PostProcess id in the pipeline
  63918. */
  63919. SSAOBlurHRenderEffect: string;
  63920. /**
  63921. * @ignore
  63922. * The vertical blur PostProcess id in the pipeline
  63923. */
  63924. SSAOBlurVRenderEffect: string;
  63925. /**
  63926. * @ignore
  63927. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63928. */
  63929. SSAOCombineRenderEffect: string;
  63930. /**
  63931. * The output strength of the SSAO post-process. Default value is 1.0.
  63932. */
  63933. totalStrength: number;
  63934. /**
  63935. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63936. */
  63937. radius: number;
  63938. /**
  63939. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63940. * Must not be equal to fallOff and superior to fallOff.
  63941. * Default value is 0.0075
  63942. */
  63943. area: number;
  63944. /**
  63945. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63946. * Must not be equal to area and inferior to area.
  63947. * Default value is 0.000001
  63948. */
  63949. fallOff: number;
  63950. /**
  63951. * The base color of the SSAO post-process
  63952. * The final result is "base + ssao" between [0, 1]
  63953. */
  63954. base: number;
  63955. private _scene;
  63956. private _depthTexture;
  63957. private _randomTexture;
  63958. private _originalColorPostProcess;
  63959. private _ssaoPostProcess;
  63960. private _blurHPostProcess;
  63961. private _blurVPostProcess;
  63962. private _ssaoCombinePostProcess;
  63963. private _firstUpdate;
  63964. /**
  63965. * Gets active scene
  63966. */
  63967. readonly scene: Scene;
  63968. /**
  63969. * @constructor
  63970. * @param name - The rendering pipeline name
  63971. * @param scene - The scene linked to this pipeline
  63972. * @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 }
  63973. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63974. */
  63975. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63976. /**
  63977. * Get the class name
  63978. * @returns "SSAORenderingPipeline"
  63979. */
  63980. getClassName(): string;
  63981. /**
  63982. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63983. */
  63984. dispose(disableDepthRender?: boolean): void;
  63985. private _createBlurPostProcess;
  63986. /** @hidden */
  63987. _rebuild(): void;
  63988. private _createSSAOPostProcess;
  63989. private _createSSAOCombinePostProcess;
  63990. private _createRandomTexture;
  63991. }
  63992. }
  63993. declare module "babylonjs/Shaders/standard.fragment" {
  63994. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63995. /** @hidden */
  63996. export var standardPixelShader: {
  63997. name: string;
  63998. shader: string;
  63999. };
  64000. }
  64001. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  64002. import { Nullable } from "babylonjs/types";
  64003. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64004. import { Camera } from "babylonjs/Cameras/camera";
  64005. import { Texture } from "babylonjs/Materials/Textures/texture";
  64006. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64007. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64008. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64009. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64010. import { IDisposable } from "babylonjs/scene";
  64011. import { SpotLight } from "babylonjs/Lights/spotLight";
  64012. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64013. import { Scene } from "babylonjs/scene";
  64014. import { Animation } from "babylonjs/Animations/animation";
  64015. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64016. import "babylonjs/Shaders/standard.fragment";
  64017. /**
  64018. * Standard rendering pipeline
  64019. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64020. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64021. */
  64022. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64023. /**
  64024. * Public members
  64025. */
  64026. /**
  64027. * Post-process which contains the original scene color before the pipeline applies all the effects
  64028. */
  64029. originalPostProcess: Nullable<PostProcess>;
  64030. /**
  64031. * Post-process used to down scale an image x4
  64032. */
  64033. downSampleX4PostProcess: Nullable<PostProcess>;
  64034. /**
  64035. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64036. */
  64037. brightPassPostProcess: Nullable<PostProcess>;
  64038. /**
  64039. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64040. */
  64041. blurHPostProcesses: PostProcess[];
  64042. /**
  64043. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64044. */
  64045. blurVPostProcesses: PostProcess[];
  64046. /**
  64047. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64048. */
  64049. textureAdderPostProcess: Nullable<PostProcess>;
  64050. /**
  64051. * Post-process used to create volumetric lighting effect
  64052. */
  64053. volumetricLightPostProcess: Nullable<PostProcess>;
  64054. /**
  64055. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64056. */
  64057. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64058. /**
  64059. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64060. */
  64061. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64062. /**
  64063. * Post-process used to merge the volumetric light effect and the real scene color
  64064. */
  64065. volumetricLightMergePostProces: Nullable<PostProcess>;
  64066. /**
  64067. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64068. */
  64069. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64070. /**
  64071. * Base post-process used to calculate the average luminance of the final image for HDR
  64072. */
  64073. luminancePostProcess: Nullable<PostProcess>;
  64074. /**
  64075. * Post-processes used to create down sample post-processes in order to get
  64076. * the average luminance of the final image for HDR
  64077. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64078. */
  64079. luminanceDownSamplePostProcesses: PostProcess[];
  64080. /**
  64081. * Post-process used to create a HDR effect (light adaptation)
  64082. */
  64083. hdrPostProcess: Nullable<PostProcess>;
  64084. /**
  64085. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64086. */
  64087. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64088. /**
  64089. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64090. */
  64091. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64092. /**
  64093. * Post-process used to merge the final HDR post-process and the real scene color
  64094. */
  64095. hdrFinalPostProcess: Nullable<PostProcess>;
  64096. /**
  64097. * Post-process used to create a lens flare effect
  64098. */
  64099. lensFlarePostProcess: Nullable<PostProcess>;
  64100. /**
  64101. * Post-process that merges the result of the lens flare post-process and the real scene color
  64102. */
  64103. lensFlareComposePostProcess: Nullable<PostProcess>;
  64104. /**
  64105. * Post-process used to create a motion blur effect
  64106. */
  64107. motionBlurPostProcess: Nullable<PostProcess>;
  64108. /**
  64109. * Post-process used to create a depth of field effect
  64110. */
  64111. depthOfFieldPostProcess: Nullable<PostProcess>;
  64112. /**
  64113. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64114. */
  64115. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64116. /**
  64117. * Represents the brightness threshold in order to configure the illuminated surfaces
  64118. */
  64119. brightThreshold: number;
  64120. /**
  64121. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64122. */
  64123. blurWidth: number;
  64124. /**
  64125. * Sets if the blur for highlighted surfaces must be only horizontal
  64126. */
  64127. horizontalBlur: boolean;
  64128. /**
  64129. * Gets the overall exposure used by the pipeline
  64130. */
  64131. /**
  64132. * Sets the overall exposure used by the pipeline
  64133. */
  64134. exposure: number;
  64135. /**
  64136. * Texture used typically to simulate "dirty" on camera lens
  64137. */
  64138. lensTexture: Nullable<Texture>;
  64139. /**
  64140. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64141. */
  64142. volumetricLightCoefficient: number;
  64143. /**
  64144. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64145. */
  64146. volumetricLightPower: number;
  64147. /**
  64148. * Used the set the blur intensity to smooth the volumetric lights
  64149. */
  64150. volumetricLightBlurScale: number;
  64151. /**
  64152. * Light (spot or directional) used to generate the volumetric lights rays
  64153. * The source light must have a shadow generate so the pipeline can get its
  64154. * depth map
  64155. */
  64156. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64157. /**
  64158. * For eye adaptation, represents the minimum luminance the eye can see
  64159. */
  64160. hdrMinimumLuminance: number;
  64161. /**
  64162. * For eye adaptation, represents the decrease luminance speed
  64163. */
  64164. hdrDecreaseRate: number;
  64165. /**
  64166. * For eye adaptation, represents the increase luminance speed
  64167. */
  64168. hdrIncreaseRate: number;
  64169. /**
  64170. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64171. */
  64172. /**
  64173. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64174. */
  64175. hdrAutoExposure: boolean;
  64176. /**
  64177. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64178. */
  64179. lensColorTexture: Nullable<Texture>;
  64180. /**
  64181. * The overall strengh for the lens flare effect
  64182. */
  64183. lensFlareStrength: number;
  64184. /**
  64185. * Dispersion coefficient for lens flare ghosts
  64186. */
  64187. lensFlareGhostDispersal: number;
  64188. /**
  64189. * Main lens flare halo width
  64190. */
  64191. lensFlareHaloWidth: number;
  64192. /**
  64193. * Based on the lens distortion effect, defines how much the lens flare result
  64194. * is distorted
  64195. */
  64196. lensFlareDistortionStrength: number;
  64197. /**
  64198. * Configures the blur intensity used for for lens flare (halo)
  64199. */
  64200. lensFlareBlurWidth: number;
  64201. /**
  64202. * Lens star texture must be used to simulate rays on the flares and is available
  64203. * in the documentation
  64204. */
  64205. lensStarTexture: Nullable<Texture>;
  64206. /**
  64207. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64208. * flare effect by taking account of the dirt texture
  64209. */
  64210. lensFlareDirtTexture: Nullable<Texture>;
  64211. /**
  64212. * Represents the focal length for the depth of field effect
  64213. */
  64214. depthOfFieldDistance: number;
  64215. /**
  64216. * Represents the blur intensity for the blurred part of the depth of field effect
  64217. */
  64218. depthOfFieldBlurWidth: number;
  64219. /**
  64220. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64221. */
  64222. /**
  64223. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64224. */
  64225. motionStrength: number;
  64226. /**
  64227. * Gets wether or not the motion blur post-process is object based or screen based.
  64228. */
  64229. /**
  64230. * Sets wether or not the motion blur post-process should be object based or screen based
  64231. */
  64232. objectBasedMotionBlur: boolean;
  64233. /**
  64234. * List of animations for the pipeline (IAnimatable implementation)
  64235. */
  64236. animations: Animation[];
  64237. /**
  64238. * Private members
  64239. */
  64240. private _scene;
  64241. private _currentDepthOfFieldSource;
  64242. private _basePostProcess;
  64243. private _fixedExposure;
  64244. private _currentExposure;
  64245. private _hdrAutoExposure;
  64246. private _hdrCurrentLuminance;
  64247. private _motionStrength;
  64248. private _isObjectBasedMotionBlur;
  64249. private _floatTextureType;
  64250. private _camerasToBeAttached;
  64251. private _ratio;
  64252. private _bloomEnabled;
  64253. private _depthOfFieldEnabled;
  64254. private _vlsEnabled;
  64255. private _lensFlareEnabled;
  64256. private _hdrEnabled;
  64257. private _motionBlurEnabled;
  64258. private _fxaaEnabled;
  64259. private _motionBlurSamples;
  64260. private _volumetricLightStepsCount;
  64261. private _samples;
  64262. /**
  64263. * @ignore
  64264. * Specifies if the bloom pipeline is enabled
  64265. */
  64266. BloomEnabled: boolean;
  64267. /**
  64268. * @ignore
  64269. * Specifies if the depth of field pipeline is enabed
  64270. */
  64271. DepthOfFieldEnabled: boolean;
  64272. /**
  64273. * @ignore
  64274. * Specifies if the lens flare pipeline is enabed
  64275. */
  64276. LensFlareEnabled: boolean;
  64277. /**
  64278. * @ignore
  64279. * Specifies if the HDR pipeline is enabled
  64280. */
  64281. HDREnabled: boolean;
  64282. /**
  64283. * @ignore
  64284. * Specifies if the volumetric lights scattering effect is enabled
  64285. */
  64286. VLSEnabled: boolean;
  64287. /**
  64288. * @ignore
  64289. * Specifies if the motion blur effect is enabled
  64290. */
  64291. MotionBlurEnabled: boolean;
  64292. /**
  64293. * Specifies if anti-aliasing is enabled
  64294. */
  64295. fxaaEnabled: boolean;
  64296. /**
  64297. * Specifies the number of steps used to calculate the volumetric lights
  64298. * Typically in interval [50, 200]
  64299. */
  64300. volumetricLightStepsCount: number;
  64301. /**
  64302. * Specifies the number of samples used for the motion blur effect
  64303. * Typically in interval [16, 64]
  64304. */
  64305. motionBlurSamples: number;
  64306. /**
  64307. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64308. */
  64309. samples: number;
  64310. /**
  64311. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64312. * @constructor
  64313. * @param name The rendering pipeline name
  64314. * @param scene The scene linked to this pipeline
  64315. * @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)
  64316. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64317. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64318. */
  64319. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64320. private _buildPipeline;
  64321. private _createDownSampleX4PostProcess;
  64322. private _createBrightPassPostProcess;
  64323. private _createBlurPostProcesses;
  64324. private _createTextureAdderPostProcess;
  64325. private _createVolumetricLightPostProcess;
  64326. private _createLuminancePostProcesses;
  64327. private _createHdrPostProcess;
  64328. private _createLensFlarePostProcess;
  64329. private _createDepthOfFieldPostProcess;
  64330. private _createMotionBlurPostProcess;
  64331. private _getDepthTexture;
  64332. private _disposePostProcesses;
  64333. /**
  64334. * Dispose of the pipeline and stop all post processes
  64335. */
  64336. dispose(): void;
  64337. /**
  64338. * Serialize the rendering pipeline (Used when exporting)
  64339. * @returns the serialized object
  64340. */
  64341. serialize(): any;
  64342. /**
  64343. * Parse the serialized pipeline
  64344. * @param source Source pipeline.
  64345. * @param scene The scene to load the pipeline to.
  64346. * @param rootUrl The URL of the serialized pipeline.
  64347. * @returns An instantiated pipeline from the serialized object.
  64348. */
  64349. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64350. /**
  64351. * Luminance steps
  64352. */
  64353. static LuminanceSteps: number;
  64354. }
  64355. }
  64356. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64357. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64358. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64359. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64360. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64361. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64362. }
  64363. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64364. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64365. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64366. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64367. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64368. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64369. }
  64370. declare module "babylonjs/Shaders/tonemap.fragment" {
  64371. /** @hidden */
  64372. export var tonemapPixelShader: {
  64373. name: string;
  64374. shader: string;
  64375. };
  64376. }
  64377. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64378. import { Camera } from "babylonjs/Cameras/camera";
  64379. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64380. import "babylonjs/Shaders/tonemap.fragment";
  64381. import { Engine } from "babylonjs/Engines/engine";
  64382. /** Defines operator used for tonemapping */
  64383. export enum TonemappingOperator {
  64384. /** Hable */
  64385. Hable = 0,
  64386. /** Reinhard */
  64387. Reinhard = 1,
  64388. /** HejiDawson */
  64389. HejiDawson = 2,
  64390. /** Photographic */
  64391. Photographic = 3
  64392. }
  64393. /**
  64394. * Defines a post process to apply tone mapping
  64395. */
  64396. export class TonemapPostProcess extends PostProcess {
  64397. private _operator;
  64398. /** Defines the required exposure adjustement */
  64399. exposureAdjustment: number;
  64400. /**
  64401. * Creates a new TonemapPostProcess
  64402. * @param name defines the name of the postprocess
  64403. * @param _operator defines the operator to use
  64404. * @param exposureAdjustment defines the required exposure adjustement
  64405. * @param camera defines the camera to use (can be null)
  64406. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64407. * @param engine defines the hosting engine (can be ignore if camera is set)
  64408. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64409. */
  64410. constructor(name: string, _operator: TonemappingOperator,
  64411. /** Defines the required exposure adjustement */
  64412. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64413. }
  64414. }
  64415. declare module "babylonjs/Shaders/depth.vertex" {
  64416. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64417. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64418. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64419. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64420. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64421. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64422. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64423. /** @hidden */
  64424. export var depthVertexShader: {
  64425. name: string;
  64426. shader: string;
  64427. };
  64428. }
  64429. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  64430. /** @hidden */
  64431. export var volumetricLightScatteringPixelShader: {
  64432. name: string;
  64433. shader: string;
  64434. };
  64435. }
  64436. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  64437. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64438. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64439. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64440. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64441. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64442. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64443. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64444. /** @hidden */
  64445. export var volumetricLightScatteringPassVertexShader: {
  64446. name: string;
  64447. shader: string;
  64448. };
  64449. }
  64450. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  64451. /** @hidden */
  64452. export var volumetricLightScatteringPassPixelShader: {
  64453. name: string;
  64454. shader: string;
  64455. };
  64456. }
  64457. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  64458. import { Vector3 } from "babylonjs/Maths/math.vector";
  64459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64460. import { Mesh } from "babylonjs/Meshes/mesh";
  64461. import { Camera } from "babylonjs/Cameras/camera";
  64462. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64463. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64464. import { Scene } from "babylonjs/scene";
  64465. import "babylonjs/Meshes/Builders/planeBuilder";
  64466. import "babylonjs/Shaders/depth.vertex";
  64467. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  64468. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  64469. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  64470. import { Engine } from "babylonjs/Engines/engine";
  64471. /**
  64472. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64473. */
  64474. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64475. private _volumetricLightScatteringPass;
  64476. private _volumetricLightScatteringRTT;
  64477. private _viewPort;
  64478. private _screenCoordinates;
  64479. private _cachedDefines;
  64480. /**
  64481. * If not undefined, the mesh position is computed from the attached node position
  64482. */
  64483. attachedNode: {
  64484. position: Vector3;
  64485. };
  64486. /**
  64487. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64488. */
  64489. customMeshPosition: Vector3;
  64490. /**
  64491. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64492. */
  64493. useCustomMeshPosition: boolean;
  64494. /**
  64495. * If the post-process should inverse the light scattering direction
  64496. */
  64497. invert: boolean;
  64498. /**
  64499. * The internal mesh used by the post-process
  64500. */
  64501. mesh: Mesh;
  64502. /**
  64503. * @hidden
  64504. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64505. */
  64506. useDiffuseColor: boolean;
  64507. /**
  64508. * Array containing the excluded meshes not rendered in the internal pass
  64509. */
  64510. excludedMeshes: AbstractMesh[];
  64511. /**
  64512. * Controls the overall intensity of the post-process
  64513. */
  64514. exposure: number;
  64515. /**
  64516. * Dissipates each sample's contribution in range [0, 1]
  64517. */
  64518. decay: number;
  64519. /**
  64520. * Controls the overall intensity of each sample
  64521. */
  64522. weight: number;
  64523. /**
  64524. * Controls the density of each sample
  64525. */
  64526. density: number;
  64527. /**
  64528. * @constructor
  64529. * @param name The post-process name
  64530. * @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)
  64531. * @param camera The camera that the post-process will be attached to
  64532. * @param mesh The mesh used to create the light scattering
  64533. * @param samples The post-process quality, default 100
  64534. * @param samplingModeThe post-process filtering mode
  64535. * @param engine The babylon engine
  64536. * @param reusable If the post-process is reusable
  64537. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64538. */
  64539. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64540. /**
  64541. * Returns the string "VolumetricLightScatteringPostProcess"
  64542. * @returns "VolumetricLightScatteringPostProcess"
  64543. */
  64544. getClassName(): string;
  64545. private _isReady;
  64546. /**
  64547. * Sets the new light position for light scattering effect
  64548. * @param position The new custom light position
  64549. */
  64550. setCustomMeshPosition(position: Vector3): void;
  64551. /**
  64552. * Returns the light position for light scattering effect
  64553. * @return Vector3 The custom light position
  64554. */
  64555. getCustomMeshPosition(): Vector3;
  64556. /**
  64557. * Disposes the internal assets and detaches the post-process from the camera
  64558. */
  64559. dispose(camera: Camera): void;
  64560. /**
  64561. * Returns the render target texture used by the post-process
  64562. * @return the render target texture used by the post-process
  64563. */
  64564. getPass(): RenderTargetTexture;
  64565. private _meshExcluded;
  64566. private _createPass;
  64567. private _updateMeshScreenCoordinates;
  64568. /**
  64569. * Creates a default mesh for the Volumeric Light Scattering post-process
  64570. * @param name The mesh name
  64571. * @param scene The scene where to create the mesh
  64572. * @return the default mesh
  64573. */
  64574. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64575. }
  64576. }
  64577. declare module "babylonjs/PostProcesses/index" {
  64578. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  64579. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  64580. export * from "babylonjs/PostProcesses/bloomEffect";
  64581. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  64582. export * from "babylonjs/PostProcesses/blurPostProcess";
  64583. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64584. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  64585. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  64586. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  64587. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64588. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  64589. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  64590. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  64591. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64592. export * from "babylonjs/PostProcesses/filterPostProcess";
  64593. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  64594. export * from "babylonjs/PostProcesses/grainPostProcess";
  64595. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  64596. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64597. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  64598. export * from "babylonjs/PostProcesses/passPostProcess";
  64599. export * from "babylonjs/PostProcesses/postProcess";
  64600. export * from "babylonjs/PostProcesses/postProcessManager";
  64601. export * from "babylonjs/PostProcesses/refractionPostProcess";
  64602. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  64603. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  64604. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  64605. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  64606. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  64607. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  64608. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  64609. }
  64610. declare module "babylonjs/Probes/index" {
  64611. export * from "babylonjs/Probes/reflectionProbe";
  64612. }
  64613. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  64614. import { Scene } from "babylonjs/scene";
  64615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64616. import { SmartArray } from "babylonjs/Misc/smartArray";
  64617. import { ISceneComponent } from "babylonjs/sceneComponent";
  64618. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  64619. import "babylonjs/Meshes/Builders/boxBuilder";
  64620. import "babylonjs/Shaders/color.fragment";
  64621. import "babylonjs/Shaders/color.vertex";
  64622. import { Color3 } from "babylonjs/Maths/math.color";
  64623. module "babylonjs/scene" {
  64624. interface Scene {
  64625. /** @hidden (Backing field) */
  64626. _boundingBoxRenderer: BoundingBoxRenderer;
  64627. /** @hidden (Backing field) */
  64628. _forceShowBoundingBoxes: boolean;
  64629. /**
  64630. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64631. */
  64632. forceShowBoundingBoxes: boolean;
  64633. /**
  64634. * Gets the bounding box renderer associated with the scene
  64635. * @returns a BoundingBoxRenderer
  64636. */
  64637. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64638. }
  64639. }
  64640. module "babylonjs/Meshes/abstractMesh" {
  64641. interface AbstractMesh {
  64642. /** @hidden (Backing field) */
  64643. _showBoundingBox: boolean;
  64644. /**
  64645. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64646. */
  64647. showBoundingBox: boolean;
  64648. }
  64649. }
  64650. /**
  64651. * Component responsible of rendering the bounding box of the meshes in a scene.
  64652. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64653. */
  64654. export class BoundingBoxRenderer implements ISceneComponent {
  64655. /**
  64656. * The component name helpfull to identify the component in the list of scene components.
  64657. */
  64658. readonly name: string;
  64659. /**
  64660. * The scene the component belongs to.
  64661. */
  64662. scene: Scene;
  64663. /**
  64664. * Color of the bounding box lines placed in front of an object
  64665. */
  64666. frontColor: Color3;
  64667. /**
  64668. * Color of the bounding box lines placed behind an object
  64669. */
  64670. backColor: Color3;
  64671. /**
  64672. * Defines if the renderer should show the back lines or not
  64673. */
  64674. showBackLines: boolean;
  64675. /**
  64676. * @hidden
  64677. */
  64678. renderList: SmartArray<BoundingBox>;
  64679. private _colorShader;
  64680. private _vertexBuffers;
  64681. private _indexBuffer;
  64682. private _fillIndexBuffer;
  64683. private _fillIndexData;
  64684. /**
  64685. * Instantiates a new bounding box renderer in a scene.
  64686. * @param scene the scene the renderer renders in
  64687. */
  64688. constructor(scene: Scene);
  64689. /**
  64690. * Registers the component in a given scene
  64691. */
  64692. register(): void;
  64693. private _evaluateSubMesh;
  64694. private _activeMesh;
  64695. private _prepareRessources;
  64696. private _createIndexBuffer;
  64697. /**
  64698. * Rebuilds the elements related to this component in case of
  64699. * context lost for instance.
  64700. */
  64701. rebuild(): void;
  64702. /**
  64703. * @hidden
  64704. */
  64705. reset(): void;
  64706. /**
  64707. * Render the bounding boxes of a specific rendering group
  64708. * @param renderingGroupId defines the rendering group to render
  64709. */
  64710. render(renderingGroupId: number): void;
  64711. /**
  64712. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64713. * @param mesh Define the mesh to render the occlusion bounding box for
  64714. */
  64715. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64716. /**
  64717. * Dispose and release the resources attached to this renderer.
  64718. */
  64719. dispose(): void;
  64720. }
  64721. }
  64722. declare module "babylonjs/Shaders/depth.fragment" {
  64723. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64724. /** @hidden */
  64725. export var depthPixelShader: {
  64726. name: string;
  64727. shader: string;
  64728. };
  64729. }
  64730. declare module "babylonjs/Rendering/depthRenderer" {
  64731. import { Nullable } from "babylonjs/types";
  64732. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64733. import { Scene } from "babylonjs/scene";
  64734. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64735. import { Camera } from "babylonjs/Cameras/camera";
  64736. import "babylonjs/Shaders/depth.fragment";
  64737. import "babylonjs/Shaders/depth.vertex";
  64738. /**
  64739. * This represents a depth renderer in Babylon.
  64740. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64741. */
  64742. export class DepthRenderer {
  64743. private _scene;
  64744. private _depthMap;
  64745. private _effect;
  64746. private readonly _storeNonLinearDepth;
  64747. private readonly _clearColor;
  64748. /** Get if the depth renderer is using packed depth or not */
  64749. readonly isPacked: boolean;
  64750. private _cachedDefines;
  64751. private _camera;
  64752. /**
  64753. * Specifiess that the depth renderer will only be used within
  64754. * the camera it is created for.
  64755. * This can help forcing its rendering during the camera processing.
  64756. */
  64757. useOnlyInActiveCamera: boolean;
  64758. /** @hidden */
  64759. static _SceneComponentInitialization: (scene: Scene) => void;
  64760. /**
  64761. * Instantiates a depth renderer
  64762. * @param scene The scene the renderer belongs to
  64763. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64764. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64765. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64766. */
  64767. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64768. /**
  64769. * Creates the depth rendering effect and checks if the effect is ready.
  64770. * @param subMesh The submesh to be used to render the depth map of
  64771. * @param useInstances If multiple world instances should be used
  64772. * @returns if the depth renderer is ready to render the depth map
  64773. */
  64774. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64775. /**
  64776. * Gets the texture which the depth map will be written to.
  64777. * @returns The depth map texture
  64778. */
  64779. getDepthMap(): RenderTargetTexture;
  64780. /**
  64781. * Disposes of the depth renderer.
  64782. */
  64783. dispose(): void;
  64784. }
  64785. }
  64786. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  64787. import { Nullable } from "babylonjs/types";
  64788. import { Scene } from "babylonjs/scene";
  64789. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64790. import { Camera } from "babylonjs/Cameras/camera";
  64791. import { ISceneComponent } from "babylonjs/sceneComponent";
  64792. module "babylonjs/scene" {
  64793. interface Scene {
  64794. /** @hidden (Backing field) */
  64795. _depthRenderer: {
  64796. [id: string]: DepthRenderer;
  64797. };
  64798. /**
  64799. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64800. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64801. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64802. * @returns the created depth renderer
  64803. */
  64804. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64805. /**
  64806. * Disables a depth renderer for a given camera
  64807. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64808. */
  64809. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64810. }
  64811. }
  64812. /**
  64813. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64814. * in several rendering techniques.
  64815. */
  64816. export class DepthRendererSceneComponent implements ISceneComponent {
  64817. /**
  64818. * The component name helpfull to identify the component in the list of scene components.
  64819. */
  64820. readonly name: string;
  64821. /**
  64822. * The scene the component belongs to.
  64823. */
  64824. scene: Scene;
  64825. /**
  64826. * Creates a new instance of the component for the given scene
  64827. * @param scene Defines the scene to register the component in
  64828. */
  64829. constructor(scene: Scene);
  64830. /**
  64831. * Registers the component in a given scene
  64832. */
  64833. register(): void;
  64834. /**
  64835. * Rebuilds the elements related to this component in case of
  64836. * context lost for instance.
  64837. */
  64838. rebuild(): void;
  64839. /**
  64840. * Disposes the component and the associated ressources
  64841. */
  64842. dispose(): void;
  64843. private _gatherRenderTargets;
  64844. private _gatherActiveCameraRenderTargets;
  64845. }
  64846. }
  64847. declare module "babylonjs/Shaders/outline.fragment" {
  64848. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64849. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  64850. /** @hidden */
  64851. export var outlinePixelShader: {
  64852. name: string;
  64853. shader: string;
  64854. };
  64855. }
  64856. declare module "babylonjs/Shaders/outline.vertex" {
  64857. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64858. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64859. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64860. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64861. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64862. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64863. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64864. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64865. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  64866. /** @hidden */
  64867. export var outlineVertexShader: {
  64868. name: string;
  64869. shader: string;
  64870. };
  64871. }
  64872. declare module "babylonjs/Rendering/outlineRenderer" {
  64873. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64874. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  64875. import { Scene } from "babylonjs/scene";
  64876. import { ISceneComponent } from "babylonjs/sceneComponent";
  64877. import "babylonjs/Shaders/outline.fragment";
  64878. import "babylonjs/Shaders/outline.vertex";
  64879. module "babylonjs/scene" {
  64880. interface Scene {
  64881. /** @hidden */
  64882. _outlineRenderer: OutlineRenderer;
  64883. /**
  64884. * Gets the outline renderer associated with the scene
  64885. * @returns a OutlineRenderer
  64886. */
  64887. getOutlineRenderer(): OutlineRenderer;
  64888. }
  64889. }
  64890. module "babylonjs/Meshes/abstractMesh" {
  64891. interface AbstractMesh {
  64892. /** @hidden (Backing field) */
  64893. _renderOutline: boolean;
  64894. /**
  64895. * Gets or sets a boolean indicating if the outline must be rendered as well
  64896. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64897. */
  64898. renderOutline: boolean;
  64899. /** @hidden (Backing field) */
  64900. _renderOverlay: boolean;
  64901. /**
  64902. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64903. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64904. */
  64905. renderOverlay: boolean;
  64906. }
  64907. }
  64908. /**
  64909. * This class is responsible to draw bothe outline/overlay of meshes.
  64910. * It should not be used directly but through the available method on mesh.
  64911. */
  64912. export class OutlineRenderer implements ISceneComponent {
  64913. /**
  64914. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64915. */
  64916. private static _StencilReference;
  64917. /**
  64918. * The name of the component. Each component must have a unique name.
  64919. */
  64920. name: string;
  64921. /**
  64922. * The scene the component belongs to.
  64923. */
  64924. scene: Scene;
  64925. /**
  64926. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64927. */
  64928. zOffset: number;
  64929. private _engine;
  64930. private _effect;
  64931. private _cachedDefines;
  64932. private _savedDepthWrite;
  64933. /**
  64934. * Instantiates a new outline renderer. (There could be only one per scene).
  64935. * @param scene Defines the scene it belongs to
  64936. */
  64937. constructor(scene: Scene);
  64938. /**
  64939. * Register the component to one instance of a scene.
  64940. */
  64941. register(): void;
  64942. /**
  64943. * Rebuilds the elements related to this component in case of
  64944. * context lost for instance.
  64945. */
  64946. rebuild(): void;
  64947. /**
  64948. * Disposes the component and the associated ressources.
  64949. */
  64950. dispose(): void;
  64951. /**
  64952. * Renders the outline in the canvas.
  64953. * @param subMesh Defines the sumesh to render
  64954. * @param batch Defines the batch of meshes in case of instances
  64955. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64956. */
  64957. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64958. /**
  64959. * Returns whether or not the outline renderer is ready for a given submesh.
  64960. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64961. * @param subMesh Defines the submesh to check readyness for
  64962. * @param useInstances Defines wheter wee are trying to render instances or not
  64963. * @returns true if ready otherwise false
  64964. */
  64965. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64966. private _beforeRenderingMesh;
  64967. private _afterRenderingMesh;
  64968. }
  64969. }
  64970. declare module "babylonjs/Rendering/index" {
  64971. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64972. export * from "babylonjs/Rendering/depthRenderer";
  64973. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64974. export * from "babylonjs/Rendering/edgesRenderer";
  64975. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64976. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64977. export * from "babylonjs/Rendering/outlineRenderer";
  64978. export * from "babylonjs/Rendering/renderingGroup";
  64979. export * from "babylonjs/Rendering/renderingManager";
  64980. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64981. }
  64982. declare module "babylonjs/Sprites/spritePackedManager" {
  64983. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64984. import { Scene } from "babylonjs/scene";
  64985. /**
  64986. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64987. * @see http://doc.babylonjs.com/babylon101/sprites
  64988. */
  64989. export class SpritePackedManager extends SpriteManager {
  64990. /** defines the packed manager's name */
  64991. name: string;
  64992. /**
  64993. * Creates a new sprite manager from a packed sprite sheet
  64994. * @param name defines the manager's name
  64995. * @param imgUrl defines the sprite sheet url
  64996. * @param capacity defines the maximum allowed number of sprites
  64997. * @param scene defines the hosting scene
  64998. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64999. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65000. * @param samplingMode defines the smapling mode to use with spritesheet
  65001. * @param fromPacked set to true; do not alter
  65002. */
  65003. constructor(
  65004. /** defines the packed manager's name */
  65005. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65006. }
  65007. }
  65008. declare module "babylonjs/Sprites/index" {
  65009. export * from "babylonjs/Sprites/sprite";
  65010. export * from "babylonjs/Sprites/spriteManager";
  65011. export * from "babylonjs/Sprites/spritePackedManager";
  65012. export * from "babylonjs/Sprites/spriteSceneComponent";
  65013. }
  65014. declare module "babylonjs/States/index" {
  65015. export * from "babylonjs/States/alphaCullingState";
  65016. export * from "babylonjs/States/depthCullingState";
  65017. export * from "babylonjs/States/stencilState";
  65018. }
  65019. declare module "babylonjs/Misc/assetsManager" {
  65020. import { Scene } from "babylonjs/scene";
  65021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65022. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65023. import { Skeleton } from "babylonjs/Bones/skeleton";
  65024. import { Observable } from "babylonjs/Misc/observable";
  65025. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65026. import { Texture } from "babylonjs/Materials/Textures/texture";
  65027. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65028. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  65029. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65030. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  65031. /**
  65032. * Defines the list of states available for a task inside a AssetsManager
  65033. */
  65034. export enum AssetTaskState {
  65035. /**
  65036. * Initialization
  65037. */
  65038. INIT = 0,
  65039. /**
  65040. * Running
  65041. */
  65042. RUNNING = 1,
  65043. /**
  65044. * Done
  65045. */
  65046. DONE = 2,
  65047. /**
  65048. * Error
  65049. */
  65050. ERROR = 3
  65051. }
  65052. /**
  65053. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65054. */
  65055. export abstract class AbstractAssetTask {
  65056. /**
  65057. * Task name
  65058. */ name: string;
  65059. /**
  65060. * Callback called when the task is successful
  65061. */
  65062. onSuccess: (task: any) => void;
  65063. /**
  65064. * Callback called when the task is not successful
  65065. */
  65066. onError: (task: any, message?: string, exception?: any) => void;
  65067. /**
  65068. * Creates a new AssetsManager
  65069. * @param name defines the name of the task
  65070. */
  65071. constructor(
  65072. /**
  65073. * Task name
  65074. */ name: string);
  65075. private _isCompleted;
  65076. private _taskState;
  65077. private _errorObject;
  65078. /**
  65079. * Get if the task is completed
  65080. */
  65081. readonly isCompleted: boolean;
  65082. /**
  65083. * Gets the current state of the task
  65084. */
  65085. readonly taskState: AssetTaskState;
  65086. /**
  65087. * Gets the current error object (if task is in error)
  65088. */
  65089. readonly errorObject: {
  65090. message?: string;
  65091. exception?: any;
  65092. };
  65093. /**
  65094. * Internal only
  65095. * @hidden
  65096. */
  65097. _setErrorObject(message?: string, exception?: any): void;
  65098. /**
  65099. * Execute the current task
  65100. * @param scene defines the scene where you want your assets to be loaded
  65101. * @param onSuccess is a callback called when the task is successfully executed
  65102. * @param onError is a callback called if an error occurs
  65103. */
  65104. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65105. /**
  65106. * Execute the current task
  65107. * @param scene defines the scene where you want your assets to be loaded
  65108. * @param onSuccess is a callback called when the task is successfully executed
  65109. * @param onError is a callback called if an error occurs
  65110. */
  65111. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65112. /**
  65113. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65114. * This can be used with failed tasks that have the reason for failure fixed.
  65115. */
  65116. reset(): void;
  65117. private onErrorCallback;
  65118. private onDoneCallback;
  65119. }
  65120. /**
  65121. * Define the interface used by progress events raised during assets loading
  65122. */
  65123. export interface IAssetsProgressEvent {
  65124. /**
  65125. * Defines the number of remaining tasks to process
  65126. */
  65127. remainingCount: number;
  65128. /**
  65129. * Defines the total number of tasks
  65130. */
  65131. totalCount: number;
  65132. /**
  65133. * Defines the task that was just processed
  65134. */
  65135. task: AbstractAssetTask;
  65136. }
  65137. /**
  65138. * Class used to share progress information about assets loading
  65139. */
  65140. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65141. /**
  65142. * Defines the number of remaining tasks to process
  65143. */
  65144. remainingCount: number;
  65145. /**
  65146. * Defines the total number of tasks
  65147. */
  65148. totalCount: number;
  65149. /**
  65150. * Defines the task that was just processed
  65151. */
  65152. task: AbstractAssetTask;
  65153. /**
  65154. * Creates a AssetsProgressEvent
  65155. * @param remainingCount defines the number of remaining tasks to process
  65156. * @param totalCount defines the total number of tasks
  65157. * @param task defines the task that was just processed
  65158. */
  65159. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65160. }
  65161. /**
  65162. * Define a task used by AssetsManager to load meshes
  65163. */
  65164. export class MeshAssetTask extends AbstractAssetTask {
  65165. /**
  65166. * Defines the name of the task
  65167. */
  65168. name: string;
  65169. /**
  65170. * Defines the list of mesh's names you want to load
  65171. */
  65172. meshesNames: any;
  65173. /**
  65174. * Defines the root url to use as a base to load your meshes and associated resources
  65175. */
  65176. rootUrl: string;
  65177. /**
  65178. * Defines the filename of the scene to load from
  65179. */
  65180. sceneFilename: string;
  65181. /**
  65182. * Gets the list of loaded meshes
  65183. */
  65184. loadedMeshes: Array<AbstractMesh>;
  65185. /**
  65186. * Gets the list of loaded particle systems
  65187. */
  65188. loadedParticleSystems: Array<IParticleSystem>;
  65189. /**
  65190. * Gets the list of loaded skeletons
  65191. */
  65192. loadedSkeletons: Array<Skeleton>;
  65193. /**
  65194. * Gets the list of loaded animation groups
  65195. */
  65196. loadedAnimationGroups: Array<AnimationGroup>;
  65197. /**
  65198. * Callback called when the task is successful
  65199. */
  65200. onSuccess: (task: MeshAssetTask) => void;
  65201. /**
  65202. * Callback called when the task is successful
  65203. */
  65204. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65205. /**
  65206. * Creates a new MeshAssetTask
  65207. * @param name defines the name of the task
  65208. * @param meshesNames defines the list of mesh's names you want to load
  65209. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65210. * @param sceneFilename defines the filename of the scene to load from
  65211. */
  65212. constructor(
  65213. /**
  65214. * Defines the name of the task
  65215. */
  65216. name: string,
  65217. /**
  65218. * Defines the list of mesh's names you want to load
  65219. */
  65220. meshesNames: any,
  65221. /**
  65222. * Defines the root url to use as a base to load your meshes and associated resources
  65223. */
  65224. rootUrl: string,
  65225. /**
  65226. * Defines the filename of the scene to load from
  65227. */
  65228. sceneFilename: string);
  65229. /**
  65230. * Execute the current task
  65231. * @param scene defines the scene where you want your assets to be loaded
  65232. * @param onSuccess is a callback called when the task is successfully executed
  65233. * @param onError is a callback called if an error occurs
  65234. */
  65235. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65236. }
  65237. /**
  65238. * Define a task used by AssetsManager to load text content
  65239. */
  65240. export class TextFileAssetTask extends AbstractAssetTask {
  65241. /**
  65242. * Defines the name of the task
  65243. */
  65244. name: string;
  65245. /**
  65246. * Defines the location of the file to load
  65247. */
  65248. url: string;
  65249. /**
  65250. * Gets the loaded text string
  65251. */
  65252. text: string;
  65253. /**
  65254. * Callback called when the task is successful
  65255. */
  65256. onSuccess: (task: TextFileAssetTask) => void;
  65257. /**
  65258. * Callback called when the task is successful
  65259. */
  65260. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65261. /**
  65262. * Creates a new TextFileAssetTask object
  65263. * @param name defines the name of the task
  65264. * @param url defines the location of the file to load
  65265. */
  65266. constructor(
  65267. /**
  65268. * Defines the name of the task
  65269. */
  65270. name: string,
  65271. /**
  65272. * Defines the location of the file to load
  65273. */
  65274. url: string);
  65275. /**
  65276. * Execute the current task
  65277. * @param scene defines the scene where you want your assets to be loaded
  65278. * @param onSuccess is a callback called when the task is successfully executed
  65279. * @param onError is a callback called if an error occurs
  65280. */
  65281. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65282. }
  65283. /**
  65284. * Define a task used by AssetsManager to load binary data
  65285. */
  65286. export class BinaryFileAssetTask extends AbstractAssetTask {
  65287. /**
  65288. * Defines the name of the task
  65289. */
  65290. name: string;
  65291. /**
  65292. * Defines the location of the file to load
  65293. */
  65294. url: string;
  65295. /**
  65296. * Gets the lodaded data (as an array buffer)
  65297. */
  65298. data: ArrayBuffer;
  65299. /**
  65300. * Callback called when the task is successful
  65301. */
  65302. onSuccess: (task: BinaryFileAssetTask) => void;
  65303. /**
  65304. * Callback called when the task is successful
  65305. */
  65306. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65307. /**
  65308. * Creates a new BinaryFileAssetTask object
  65309. * @param name defines the name of the new task
  65310. * @param url defines the location of the file to load
  65311. */
  65312. constructor(
  65313. /**
  65314. * Defines the name of the task
  65315. */
  65316. name: string,
  65317. /**
  65318. * Defines the location of the file to load
  65319. */
  65320. url: string);
  65321. /**
  65322. * Execute the current task
  65323. * @param scene defines the scene where you want your assets to be loaded
  65324. * @param onSuccess is a callback called when the task is successfully executed
  65325. * @param onError is a callback called if an error occurs
  65326. */
  65327. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65328. }
  65329. /**
  65330. * Define a task used by AssetsManager to load images
  65331. */
  65332. export class ImageAssetTask extends AbstractAssetTask {
  65333. /**
  65334. * Defines the name of the task
  65335. */
  65336. name: string;
  65337. /**
  65338. * Defines the location of the image to load
  65339. */
  65340. url: string;
  65341. /**
  65342. * Gets the loaded images
  65343. */
  65344. image: HTMLImageElement;
  65345. /**
  65346. * Callback called when the task is successful
  65347. */
  65348. onSuccess: (task: ImageAssetTask) => void;
  65349. /**
  65350. * Callback called when the task is successful
  65351. */
  65352. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65353. /**
  65354. * Creates a new ImageAssetTask
  65355. * @param name defines the name of the task
  65356. * @param url defines the location of the image to load
  65357. */
  65358. constructor(
  65359. /**
  65360. * Defines the name of the task
  65361. */
  65362. name: string,
  65363. /**
  65364. * Defines the location of the image to load
  65365. */
  65366. url: string);
  65367. /**
  65368. * Execute the current task
  65369. * @param scene defines the scene where you want your assets to be loaded
  65370. * @param onSuccess is a callback called when the task is successfully executed
  65371. * @param onError is a callback called if an error occurs
  65372. */
  65373. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65374. }
  65375. /**
  65376. * Defines the interface used by texture loading tasks
  65377. */
  65378. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65379. /**
  65380. * Gets the loaded texture
  65381. */
  65382. texture: TEX;
  65383. }
  65384. /**
  65385. * Define a task used by AssetsManager to load 2D textures
  65386. */
  65387. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65388. /**
  65389. * Defines the name of the task
  65390. */
  65391. name: string;
  65392. /**
  65393. * Defines the location of the file to load
  65394. */
  65395. url: string;
  65396. /**
  65397. * Defines if mipmap should not be generated (default is false)
  65398. */
  65399. noMipmap?: boolean | undefined;
  65400. /**
  65401. * Defines if texture must be inverted on Y axis (default is false)
  65402. */
  65403. invertY?: boolean | undefined;
  65404. /**
  65405. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65406. */
  65407. samplingMode: number;
  65408. /**
  65409. * Gets the loaded texture
  65410. */
  65411. texture: Texture;
  65412. /**
  65413. * Callback called when the task is successful
  65414. */
  65415. onSuccess: (task: TextureAssetTask) => void;
  65416. /**
  65417. * Callback called when the task is successful
  65418. */
  65419. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65420. /**
  65421. * Creates a new TextureAssetTask object
  65422. * @param name defines the name of the task
  65423. * @param url defines the location of the file to load
  65424. * @param noMipmap defines if mipmap should not be generated (default is false)
  65425. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65426. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65427. */
  65428. constructor(
  65429. /**
  65430. * Defines the name of the task
  65431. */
  65432. name: string,
  65433. /**
  65434. * Defines the location of the file to load
  65435. */
  65436. url: string,
  65437. /**
  65438. * Defines if mipmap should not be generated (default is false)
  65439. */
  65440. noMipmap?: boolean | undefined,
  65441. /**
  65442. * Defines if texture must be inverted on Y axis (default is false)
  65443. */
  65444. invertY?: boolean | undefined,
  65445. /**
  65446. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65447. */
  65448. samplingMode?: number);
  65449. /**
  65450. * Execute the current task
  65451. * @param scene defines the scene where you want your assets to be loaded
  65452. * @param onSuccess is a callback called when the task is successfully executed
  65453. * @param onError is a callback called if an error occurs
  65454. */
  65455. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65456. }
  65457. /**
  65458. * Define a task used by AssetsManager to load cube textures
  65459. */
  65460. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65461. /**
  65462. * Defines the name of the task
  65463. */
  65464. name: string;
  65465. /**
  65466. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65467. */
  65468. url: string;
  65469. /**
  65470. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65471. */
  65472. extensions?: string[] | undefined;
  65473. /**
  65474. * Defines if mipmaps should not be generated (default is false)
  65475. */
  65476. noMipmap?: boolean | undefined;
  65477. /**
  65478. * Defines the explicit list of files (undefined by default)
  65479. */
  65480. files?: string[] | undefined;
  65481. /**
  65482. * Gets the loaded texture
  65483. */
  65484. texture: CubeTexture;
  65485. /**
  65486. * Callback called when the task is successful
  65487. */
  65488. onSuccess: (task: CubeTextureAssetTask) => void;
  65489. /**
  65490. * Callback called when the task is successful
  65491. */
  65492. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65493. /**
  65494. * Creates a new CubeTextureAssetTask
  65495. * @param name defines the name of the task
  65496. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65497. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65498. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65499. * @param files defines the explicit list of files (undefined by default)
  65500. */
  65501. constructor(
  65502. /**
  65503. * Defines the name of the task
  65504. */
  65505. name: string,
  65506. /**
  65507. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65508. */
  65509. url: string,
  65510. /**
  65511. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65512. */
  65513. extensions?: string[] | undefined,
  65514. /**
  65515. * Defines if mipmaps should not be generated (default is false)
  65516. */
  65517. noMipmap?: boolean | undefined,
  65518. /**
  65519. * Defines the explicit list of files (undefined by default)
  65520. */
  65521. files?: string[] | undefined);
  65522. /**
  65523. * Execute the current task
  65524. * @param scene defines the scene where you want your assets to be loaded
  65525. * @param onSuccess is a callback called when the task is successfully executed
  65526. * @param onError is a callback called if an error occurs
  65527. */
  65528. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65529. }
  65530. /**
  65531. * Define a task used by AssetsManager to load HDR cube textures
  65532. */
  65533. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65534. /**
  65535. * Defines the name of the task
  65536. */
  65537. name: string;
  65538. /**
  65539. * Defines the location of the file to load
  65540. */
  65541. url: string;
  65542. /**
  65543. * Defines the desired size (the more it increases the longer the generation will be)
  65544. */
  65545. size: number;
  65546. /**
  65547. * Defines if mipmaps should not be generated (default is false)
  65548. */
  65549. noMipmap: boolean;
  65550. /**
  65551. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65552. */
  65553. generateHarmonics: boolean;
  65554. /**
  65555. * 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)
  65556. */
  65557. gammaSpace: boolean;
  65558. /**
  65559. * Internal Use Only
  65560. */
  65561. reserved: boolean;
  65562. /**
  65563. * Gets the loaded texture
  65564. */
  65565. texture: HDRCubeTexture;
  65566. /**
  65567. * Callback called when the task is successful
  65568. */
  65569. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65570. /**
  65571. * Callback called when the task is successful
  65572. */
  65573. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65574. /**
  65575. * Creates a new HDRCubeTextureAssetTask object
  65576. * @param name defines the name of the task
  65577. * @param url defines the location of the file to load
  65578. * @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.
  65579. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65580. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65581. * @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)
  65582. * @param reserved Internal use only
  65583. */
  65584. constructor(
  65585. /**
  65586. * Defines the name of the task
  65587. */
  65588. name: string,
  65589. /**
  65590. * Defines the location of the file to load
  65591. */
  65592. url: string,
  65593. /**
  65594. * Defines the desired size (the more it increases the longer the generation will be)
  65595. */
  65596. size: number,
  65597. /**
  65598. * Defines if mipmaps should not be generated (default is false)
  65599. */
  65600. noMipmap?: boolean,
  65601. /**
  65602. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65603. */
  65604. generateHarmonics?: boolean,
  65605. /**
  65606. * 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)
  65607. */
  65608. gammaSpace?: boolean,
  65609. /**
  65610. * Internal Use Only
  65611. */
  65612. reserved?: boolean);
  65613. /**
  65614. * Execute the current task
  65615. * @param scene defines the scene where you want your assets to be loaded
  65616. * @param onSuccess is a callback called when the task is successfully executed
  65617. * @param onError is a callback called if an error occurs
  65618. */
  65619. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65620. }
  65621. /**
  65622. * Define a task used by AssetsManager to load Equirectangular cube textures
  65623. */
  65624. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65625. /**
  65626. * Defines the name of the task
  65627. */
  65628. name: string;
  65629. /**
  65630. * Defines the location of the file to load
  65631. */
  65632. url: string;
  65633. /**
  65634. * Defines the desired size (the more it increases the longer the generation will be)
  65635. */
  65636. size: number;
  65637. /**
  65638. * Defines if mipmaps should not be generated (default is false)
  65639. */
  65640. noMipmap: boolean;
  65641. /**
  65642. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65643. * but the standard material would require them in Gamma space) (default is true)
  65644. */
  65645. gammaSpace: boolean;
  65646. /**
  65647. * Gets the loaded texture
  65648. */
  65649. texture: EquiRectangularCubeTexture;
  65650. /**
  65651. * Callback called when the task is successful
  65652. */
  65653. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65654. /**
  65655. * Callback called when the task is successful
  65656. */
  65657. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65658. /**
  65659. * Creates a new EquiRectangularCubeTextureAssetTask object
  65660. * @param name defines the name of the task
  65661. * @param url defines the location of the file to load
  65662. * @param size defines the desired size (the more it increases the longer the generation will be)
  65663. * If the size is omitted this implies you are using a preprocessed cubemap.
  65664. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65665. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65666. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65667. * (default is true)
  65668. */
  65669. constructor(
  65670. /**
  65671. * Defines the name of the task
  65672. */
  65673. name: string,
  65674. /**
  65675. * Defines the location of the file to load
  65676. */
  65677. url: string,
  65678. /**
  65679. * Defines the desired size (the more it increases the longer the generation will be)
  65680. */
  65681. size: number,
  65682. /**
  65683. * Defines if mipmaps should not be generated (default is false)
  65684. */
  65685. noMipmap?: boolean,
  65686. /**
  65687. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65688. * but the standard material would require them in Gamma space) (default is true)
  65689. */
  65690. gammaSpace?: boolean);
  65691. /**
  65692. * Execute the current task
  65693. * @param scene defines the scene where you want your assets to be loaded
  65694. * @param onSuccess is a callback called when the task is successfully executed
  65695. * @param onError is a callback called if an error occurs
  65696. */
  65697. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65698. }
  65699. /**
  65700. * This class can be used to easily import assets into a scene
  65701. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65702. */
  65703. export class AssetsManager {
  65704. private _scene;
  65705. private _isLoading;
  65706. protected _tasks: AbstractAssetTask[];
  65707. protected _waitingTasksCount: number;
  65708. protected _totalTasksCount: number;
  65709. /**
  65710. * Callback called when all tasks are processed
  65711. */
  65712. onFinish: (tasks: AbstractAssetTask[]) => void;
  65713. /**
  65714. * Callback called when a task is successful
  65715. */
  65716. onTaskSuccess: (task: AbstractAssetTask) => void;
  65717. /**
  65718. * Callback called when a task had an error
  65719. */
  65720. onTaskError: (task: AbstractAssetTask) => void;
  65721. /**
  65722. * Callback called when a task is done (whatever the result is)
  65723. */
  65724. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65725. /**
  65726. * Observable called when all tasks are processed
  65727. */
  65728. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65729. /**
  65730. * Observable called when a task had an error
  65731. */
  65732. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65733. /**
  65734. * Observable called when all tasks were executed
  65735. */
  65736. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65737. /**
  65738. * Observable called when a task is done (whatever the result is)
  65739. */
  65740. onProgressObservable: Observable<IAssetsProgressEvent>;
  65741. /**
  65742. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65743. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65744. */
  65745. useDefaultLoadingScreen: boolean;
  65746. /**
  65747. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65748. * when all assets have been downloaded.
  65749. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65750. */
  65751. autoHideLoadingUI: boolean;
  65752. /**
  65753. * Creates a new AssetsManager
  65754. * @param scene defines the scene to work on
  65755. */
  65756. constructor(scene: Scene);
  65757. /**
  65758. * Add a MeshAssetTask to the list of active tasks
  65759. * @param taskName defines the name of the new task
  65760. * @param meshesNames defines the name of meshes to load
  65761. * @param rootUrl defines the root url to use to locate files
  65762. * @param sceneFilename defines the filename of the scene file
  65763. * @returns a new MeshAssetTask object
  65764. */
  65765. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65766. /**
  65767. * Add a TextFileAssetTask to the list of active tasks
  65768. * @param taskName defines the name of the new task
  65769. * @param url defines the url of the file to load
  65770. * @returns a new TextFileAssetTask object
  65771. */
  65772. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65773. /**
  65774. * Add a BinaryFileAssetTask to the list of active tasks
  65775. * @param taskName defines the name of the new task
  65776. * @param url defines the url of the file to load
  65777. * @returns a new BinaryFileAssetTask object
  65778. */
  65779. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65780. /**
  65781. * Add a ImageAssetTask to the list of active tasks
  65782. * @param taskName defines the name of the new task
  65783. * @param url defines the url of the file to load
  65784. * @returns a new ImageAssetTask object
  65785. */
  65786. addImageTask(taskName: string, url: string): ImageAssetTask;
  65787. /**
  65788. * Add a TextureAssetTask to the list of active tasks
  65789. * @param taskName defines the name of the new task
  65790. * @param url defines the url of the file to load
  65791. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65792. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65793. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65794. * @returns a new TextureAssetTask object
  65795. */
  65796. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65797. /**
  65798. * Add a CubeTextureAssetTask to the list of active tasks
  65799. * @param taskName defines the name of the new task
  65800. * @param url defines the url of the file to load
  65801. * @param extensions defines the extension to use to load the cube map (can be null)
  65802. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65803. * @param files defines the list of files to load (can be null)
  65804. * @returns a new CubeTextureAssetTask object
  65805. */
  65806. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65807. /**
  65808. *
  65809. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65810. * @param taskName defines the name of the new task
  65811. * @param url defines the url of the file to load
  65812. * @param size defines the size you want for the cubemap (can be null)
  65813. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65814. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65815. * @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)
  65816. * @param reserved Internal use only
  65817. * @returns a new HDRCubeTextureAssetTask object
  65818. */
  65819. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65820. /**
  65821. *
  65822. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65823. * @param taskName defines the name of the new task
  65824. * @param url defines the url of the file to load
  65825. * @param size defines the size you want for the cubemap (can be null)
  65826. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65827. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65828. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65829. * @returns a new EquiRectangularCubeTextureAssetTask object
  65830. */
  65831. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65832. /**
  65833. * Remove a task from the assets manager.
  65834. * @param task the task to remove
  65835. */
  65836. removeTask(task: AbstractAssetTask): void;
  65837. private _decreaseWaitingTasksCount;
  65838. private _runTask;
  65839. /**
  65840. * Reset the AssetsManager and remove all tasks
  65841. * @return the current instance of the AssetsManager
  65842. */
  65843. reset(): AssetsManager;
  65844. /**
  65845. * Start the loading process
  65846. * @return the current instance of the AssetsManager
  65847. */
  65848. load(): AssetsManager;
  65849. /**
  65850. * Start the loading process as an async operation
  65851. * @return a promise returning the list of failed tasks
  65852. */
  65853. loadAsync(): Promise<void>;
  65854. }
  65855. }
  65856. declare module "babylonjs/Misc/deferred" {
  65857. /**
  65858. * Wrapper class for promise with external resolve and reject.
  65859. */
  65860. export class Deferred<T> {
  65861. /**
  65862. * The promise associated with this deferred object.
  65863. */
  65864. readonly promise: Promise<T>;
  65865. private _resolve;
  65866. private _reject;
  65867. /**
  65868. * The resolve method of the promise associated with this deferred object.
  65869. */
  65870. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65871. /**
  65872. * The reject method of the promise associated with this deferred object.
  65873. */
  65874. readonly reject: (reason?: any) => void;
  65875. /**
  65876. * Constructor for this deferred object.
  65877. */
  65878. constructor();
  65879. }
  65880. }
  65881. declare module "babylonjs/Misc/meshExploder" {
  65882. import { Mesh } from "babylonjs/Meshes/mesh";
  65883. /**
  65884. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65885. */
  65886. export class MeshExploder {
  65887. private _centerMesh;
  65888. private _meshes;
  65889. private _meshesOrigins;
  65890. private _toCenterVectors;
  65891. private _scaledDirection;
  65892. private _newPosition;
  65893. private _centerPosition;
  65894. /**
  65895. * Explodes meshes from a center mesh.
  65896. * @param meshes The meshes to explode.
  65897. * @param centerMesh The mesh to be center of explosion.
  65898. */
  65899. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65900. private _setCenterMesh;
  65901. /**
  65902. * Get class name
  65903. * @returns "MeshExploder"
  65904. */
  65905. getClassName(): string;
  65906. /**
  65907. * "Exploded meshes"
  65908. * @returns Array of meshes with the centerMesh at index 0.
  65909. */
  65910. getMeshes(): Array<Mesh>;
  65911. /**
  65912. * Explodes meshes giving a specific direction
  65913. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65914. */
  65915. explode(direction?: number): void;
  65916. }
  65917. }
  65918. declare module "babylonjs/Misc/filesInput" {
  65919. import { Engine } from "babylonjs/Engines/engine";
  65920. import { Scene } from "babylonjs/scene";
  65921. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  65922. /**
  65923. * Class used to help managing file picking and drag'n'drop
  65924. */
  65925. export class FilesInput {
  65926. /**
  65927. * List of files ready to be loaded
  65928. */
  65929. static readonly FilesToLoad: {
  65930. [key: string]: File;
  65931. };
  65932. /**
  65933. * Callback called when a file is processed
  65934. */
  65935. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65936. private _engine;
  65937. private _currentScene;
  65938. private _sceneLoadedCallback;
  65939. private _progressCallback;
  65940. private _additionalRenderLoopLogicCallback;
  65941. private _textureLoadingCallback;
  65942. private _startingProcessingFilesCallback;
  65943. private _onReloadCallback;
  65944. private _errorCallback;
  65945. private _elementToMonitor;
  65946. private _sceneFileToLoad;
  65947. private _filesToLoad;
  65948. /**
  65949. * Creates a new FilesInput
  65950. * @param engine defines the rendering engine
  65951. * @param scene defines the hosting scene
  65952. * @param sceneLoadedCallback callback called when scene is loaded
  65953. * @param progressCallback callback called to track progress
  65954. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65955. * @param textureLoadingCallback callback called when a texture is loading
  65956. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65957. * @param onReloadCallback callback called when a reload is requested
  65958. * @param errorCallback callback call if an error occurs
  65959. */
  65960. 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);
  65961. private _dragEnterHandler;
  65962. private _dragOverHandler;
  65963. private _dropHandler;
  65964. /**
  65965. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65966. * @param elementToMonitor defines the DOM element to track
  65967. */
  65968. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65969. /**
  65970. * Release all associated resources
  65971. */
  65972. dispose(): void;
  65973. private renderFunction;
  65974. private drag;
  65975. private drop;
  65976. private _traverseFolder;
  65977. private _processFiles;
  65978. /**
  65979. * Load files from a drop event
  65980. * @param event defines the drop event to use as source
  65981. */
  65982. loadFiles(event: any): void;
  65983. private _processReload;
  65984. /**
  65985. * Reload the current scene from the loaded files
  65986. */
  65987. reload(): void;
  65988. }
  65989. }
  65990. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65991. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65992. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65993. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65994. }
  65995. declare module "babylonjs/Misc/sceneOptimizer" {
  65996. import { Scene, IDisposable } from "babylonjs/scene";
  65997. import { Observable } from "babylonjs/Misc/observable";
  65998. /**
  65999. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66000. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66001. */
  66002. export class SceneOptimization {
  66003. /**
  66004. * Defines the priority of this optimization (0 by default which means first in the list)
  66005. */
  66006. priority: number;
  66007. /**
  66008. * Gets a string describing the action executed by the current optimization
  66009. * @returns description string
  66010. */
  66011. getDescription(): string;
  66012. /**
  66013. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66014. * @param scene defines the current scene where to apply this optimization
  66015. * @param optimizer defines the current optimizer
  66016. * @returns true if everything that can be done was applied
  66017. */
  66018. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66019. /**
  66020. * Creates the SceneOptimization object
  66021. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66022. * @param desc defines the description associated with the optimization
  66023. */
  66024. constructor(
  66025. /**
  66026. * Defines the priority of this optimization (0 by default which means first in the list)
  66027. */
  66028. priority?: number);
  66029. }
  66030. /**
  66031. * Defines an optimization used to reduce the size of render target textures
  66032. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66033. */
  66034. export class TextureOptimization extends SceneOptimization {
  66035. /**
  66036. * Defines the priority of this optimization (0 by default which means first in the list)
  66037. */
  66038. priority: number;
  66039. /**
  66040. * 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
  66041. */
  66042. maximumSize: number;
  66043. /**
  66044. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66045. */
  66046. step: number;
  66047. /**
  66048. * Gets a string describing the action executed by the current optimization
  66049. * @returns description string
  66050. */
  66051. getDescription(): string;
  66052. /**
  66053. * Creates the TextureOptimization object
  66054. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66055. * @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
  66056. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66057. */
  66058. constructor(
  66059. /**
  66060. * Defines the priority of this optimization (0 by default which means first in the list)
  66061. */
  66062. priority?: number,
  66063. /**
  66064. * 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
  66065. */
  66066. maximumSize?: number,
  66067. /**
  66068. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66069. */
  66070. step?: number);
  66071. /**
  66072. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66073. * @param scene defines the current scene where to apply this optimization
  66074. * @param optimizer defines the current optimizer
  66075. * @returns true if everything that can be done was applied
  66076. */
  66077. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66078. }
  66079. /**
  66080. * Defines an optimization used to increase or decrease the rendering resolution
  66081. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66082. */
  66083. export class HardwareScalingOptimization extends SceneOptimization {
  66084. /**
  66085. * Defines the priority of this optimization (0 by default which means first in the list)
  66086. */
  66087. priority: number;
  66088. /**
  66089. * Defines the maximum scale to use (2 by default)
  66090. */
  66091. maximumScale: number;
  66092. /**
  66093. * Defines the step to use between two passes (0.5 by default)
  66094. */
  66095. step: number;
  66096. private _currentScale;
  66097. private _directionOffset;
  66098. /**
  66099. * Gets a string describing the action executed by the current optimization
  66100. * @return description string
  66101. */
  66102. getDescription(): string;
  66103. /**
  66104. * Creates the HardwareScalingOptimization object
  66105. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66106. * @param maximumScale defines the maximum scale to use (2 by default)
  66107. * @param step defines the step to use between two passes (0.5 by default)
  66108. */
  66109. constructor(
  66110. /**
  66111. * Defines the priority of this optimization (0 by default which means first in the list)
  66112. */
  66113. priority?: number,
  66114. /**
  66115. * Defines the maximum scale to use (2 by default)
  66116. */
  66117. maximumScale?: number,
  66118. /**
  66119. * Defines the step to use between two passes (0.5 by default)
  66120. */
  66121. step?: number);
  66122. /**
  66123. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66124. * @param scene defines the current scene where to apply this optimization
  66125. * @param optimizer defines the current optimizer
  66126. * @returns true if everything that can be done was applied
  66127. */
  66128. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66129. }
  66130. /**
  66131. * Defines an optimization used to remove shadows
  66132. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66133. */
  66134. export class ShadowsOptimization extends SceneOptimization {
  66135. /**
  66136. * Gets a string describing the action executed by the current optimization
  66137. * @return description string
  66138. */
  66139. getDescription(): string;
  66140. /**
  66141. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66142. * @param scene defines the current scene where to apply this optimization
  66143. * @param optimizer defines the current optimizer
  66144. * @returns true if everything that can be done was applied
  66145. */
  66146. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66147. }
  66148. /**
  66149. * Defines an optimization used to turn post-processes off
  66150. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66151. */
  66152. export class PostProcessesOptimization extends SceneOptimization {
  66153. /**
  66154. * Gets a string describing the action executed by the current optimization
  66155. * @return description string
  66156. */
  66157. getDescription(): string;
  66158. /**
  66159. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66160. * @param scene defines the current scene where to apply this optimization
  66161. * @param optimizer defines the current optimizer
  66162. * @returns true if everything that can be done was applied
  66163. */
  66164. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66165. }
  66166. /**
  66167. * Defines an optimization used to turn lens flares off
  66168. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66169. */
  66170. export class LensFlaresOptimization extends SceneOptimization {
  66171. /**
  66172. * Gets a string describing the action executed by the current optimization
  66173. * @return description string
  66174. */
  66175. getDescription(): string;
  66176. /**
  66177. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66178. * @param scene defines the current scene where to apply this optimization
  66179. * @param optimizer defines the current optimizer
  66180. * @returns true if everything that can be done was applied
  66181. */
  66182. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66183. }
  66184. /**
  66185. * Defines an optimization based on user defined callback.
  66186. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66187. */
  66188. export class CustomOptimization extends SceneOptimization {
  66189. /**
  66190. * Callback called to apply the custom optimization.
  66191. */
  66192. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66193. /**
  66194. * Callback called to get custom description
  66195. */
  66196. onGetDescription: () => string;
  66197. /**
  66198. * Gets a string describing the action executed by the current optimization
  66199. * @returns description string
  66200. */
  66201. getDescription(): string;
  66202. /**
  66203. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66204. * @param scene defines the current scene where to apply this optimization
  66205. * @param optimizer defines the current optimizer
  66206. * @returns true if everything that can be done was applied
  66207. */
  66208. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66209. }
  66210. /**
  66211. * Defines an optimization used to turn particles off
  66212. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66213. */
  66214. export class ParticlesOptimization extends SceneOptimization {
  66215. /**
  66216. * Gets a string describing the action executed by the current optimization
  66217. * @return description string
  66218. */
  66219. getDescription(): string;
  66220. /**
  66221. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66222. * @param scene defines the current scene where to apply this optimization
  66223. * @param optimizer defines the current optimizer
  66224. * @returns true if everything that can be done was applied
  66225. */
  66226. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66227. }
  66228. /**
  66229. * Defines an optimization used to turn render targets off
  66230. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66231. */
  66232. export class RenderTargetsOptimization extends SceneOptimization {
  66233. /**
  66234. * Gets a string describing the action executed by the current optimization
  66235. * @return description string
  66236. */
  66237. getDescription(): string;
  66238. /**
  66239. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66240. * @param scene defines the current scene where to apply this optimization
  66241. * @param optimizer defines the current optimizer
  66242. * @returns true if everything that can be done was applied
  66243. */
  66244. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66245. }
  66246. /**
  66247. * Defines an optimization used to merge meshes with compatible materials
  66248. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66249. */
  66250. export class MergeMeshesOptimization extends SceneOptimization {
  66251. private static _UpdateSelectionTree;
  66252. /**
  66253. * Gets or sets a boolean which defines if optimization octree has to be updated
  66254. */
  66255. /**
  66256. * Gets or sets a boolean which defines if optimization octree has to be updated
  66257. */
  66258. static UpdateSelectionTree: boolean;
  66259. /**
  66260. * Gets a string describing the action executed by the current optimization
  66261. * @return description string
  66262. */
  66263. getDescription(): string;
  66264. private _canBeMerged;
  66265. /**
  66266. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66267. * @param scene defines the current scene where to apply this optimization
  66268. * @param optimizer defines the current optimizer
  66269. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66270. * @returns true if everything that can be done was applied
  66271. */
  66272. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66273. }
  66274. /**
  66275. * Defines a list of options used by SceneOptimizer
  66276. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66277. */
  66278. export class SceneOptimizerOptions {
  66279. /**
  66280. * Defines the target frame rate to reach (60 by default)
  66281. */
  66282. targetFrameRate: number;
  66283. /**
  66284. * Defines the interval between two checkes (2000ms by default)
  66285. */
  66286. trackerDuration: number;
  66287. /**
  66288. * Gets the list of optimizations to apply
  66289. */
  66290. optimizations: SceneOptimization[];
  66291. /**
  66292. * Creates a new list of options used by SceneOptimizer
  66293. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66294. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66295. */
  66296. constructor(
  66297. /**
  66298. * Defines the target frame rate to reach (60 by default)
  66299. */
  66300. targetFrameRate?: number,
  66301. /**
  66302. * Defines the interval between two checkes (2000ms by default)
  66303. */
  66304. trackerDuration?: number);
  66305. /**
  66306. * Add a new optimization
  66307. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66308. * @returns the current SceneOptimizerOptions
  66309. */
  66310. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66311. /**
  66312. * Add a new custom optimization
  66313. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66314. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66315. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66316. * @returns the current SceneOptimizerOptions
  66317. */
  66318. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66319. /**
  66320. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66321. * @param targetFrameRate defines the target frame rate (60 by default)
  66322. * @returns a SceneOptimizerOptions object
  66323. */
  66324. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66325. /**
  66326. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66327. * @param targetFrameRate defines the target frame rate (60 by default)
  66328. * @returns a SceneOptimizerOptions object
  66329. */
  66330. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66331. /**
  66332. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66333. * @param targetFrameRate defines the target frame rate (60 by default)
  66334. * @returns a SceneOptimizerOptions object
  66335. */
  66336. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66337. }
  66338. /**
  66339. * Class used to run optimizations in order to reach a target frame rate
  66340. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66341. */
  66342. export class SceneOptimizer implements IDisposable {
  66343. private _isRunning;
  66344. private _options;
  66345. private _scene;
  66346. private _currentPriorityLevel;
  66347. private _targetFrameRate;
  66348. private _trackerDuration;
  66349. private _currentFrameRate;
  66350. private _sceneDisposeObserver;
  66351. private _improvementMode;
  66352. /**
  66353. * Defines an observable called when the optimizer reaches the target frame rate
  66354. */
  66355. onSuccessObservable: Observable<SceneOptimizer>;
  66356. /**
  66357. * Defines an observable called when the optimizer enables an optimization
  66358. */
  66359. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66360. /**
  66361. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66362. */
  66363. onFailureObservable: Observable<SceneOptimizer>;
  66364. /**
  66365. * Gets a boolean indicating if the optimizer is in improvement mode
  66366. */
  66367. readonly isInImprovementMode: boolean;
  66368. /**
  66369. * Gets the current priority level (0 at start)
  66370. */
  66371. readonly currentPriorityLevel: number;
  66372. /**
  66373. * Gets the current frame rate checked by the SceneOptimizer
  66374. */
  66375. readonly currentFrameRate: number;
  66376. /**
  66377. * Gets or sets the current target frame rate (60 by default)
  66378. */
  66379. /**
  66380. * Gets or sets the current target frame rate (60 by default)
  66381. */
  66382. targetFrameRate: number;
  66383. /**
  66384. * Gets or sets the current interval between two checks (every 2000ms by default)
  66385. */
  66386. /**
  66387. * Gets or sets the current interval between two checks (every 2000ms by default)
  66388. */
  66389. trackerDuration: number;
  66390. /**
  66391. * Gets the list of active optimizations
  66392. */
  66393. readonly optimizations: SceneOptimization[];
  66394. /**
  66395. * Creates a new SceneOptimizer
  66396. * @param scene defines the scene to work on
  66397. * @param options defines the options to use with the SceneOptimizer
  66398. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66399. * @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)
  66400. */
  66401. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66402. /**
  66403. * Stops the current optimizer
  66404. */
  66405. stop(): void;
  66406. /**
  66407. * Reset the optimizer to initial step (current priority level = 0)
  66408. */
  66409. reset(): void;
  66410. /**
  66411. * Start the optimizer. By default it will try to reach a specific framerate
  66412. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66413. */
  66414. start(): void;
  66415. private _checkCurrentState;
  66416. /**
  66417. * Release all resources
  66418. */
  66419. dispose(): void;
  66420. /**
  66421. * Helper function to create a SceneOptimizer with one single line of code
  66422. * @param scene defines the scene to work on
  66423. * @param options defines the options to use with the SceneOptimizer
  66424. * @param onSuccess defines a callback to call on success
  66425. * @param onFailure defines a callback to call on failure
  66426. * @returns the new SceneOptimizer object
  66427. */
  66428. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66429. }
  66430. }
  66431. declare module "babylonjs/Misc/sceneSerializer" {
  66432. import { Scene } from "babylonjs/scene";
  66433. /**
  66434. * Class used to serialize a scene into a string
  66435. */
  66436. export class SceneSerializer {
  66437. /**
  66438. * Clear cache used by a previous serialization
  66439. */
  66440. static ClearCache(): void;
  66441. /**
  66442. * Serialize a scene into a JSON compatible object
  66443. * @param scene defines the scene to serialize
  66444. * @returns a JSON compatible object
  66445. */
  66446. static Serialize(scene: Scene): any;
  66447. /**
  66448. * Serialize a mesh into a JSON compatible object
  66449. * @param toSerialize defines the mesh to serialize
  66450. * @param withParents defines if parents must be serialized as well
  66451. * @param withChildren defines if children must be serialized as well
  66452. * @returns a JSON compatible object
  66453. */
  66454. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66455. }
  66456. }
  66457. declare module "babylonjs/Misc/textureTools" {
  66458. import { Texture } from "babylonjs/Materials/Textures/texture";
  66459. /**
  66460. * Class used to host texture specific utilities
  66461. */
  66462. export class TextureTools {
  66463. /**
  66464. * Uses the GPU to create a copy texture rescaled at a given size
  66465. * @param texture Texture to copy from
  66466. * @param width defines the desired width
  66467. * @param height defines the desired height
  66468. * @param useBilinearMode defines if bilinear mode has to be used
  66469. * @return the generated texture
  66470. */
  66471. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66472. }
  66473. }
  66474. declare module "babylonjs/Misc/videoRecorder" {
  66475. import { Nullable } from "babylonjs/types";
  66476. import { Engine } from "babylonjs/Engines/engine";
  66477. /**
  66478. * This represents the different options available for the video capture.
  66479. */
  66480. export interface VideoRecorderOptions {
  66481. /** Defines the mime type of the video. */
  66482. mimeType: string;
  66483. /** Defines the FPS the video should be recorded at. */
  66484. fps: number;
  66485. /** Defines the chunk size for the recording data. */
  66486. recordChunckSize: number;
  66487. /** The audio tracks to attach to the recording. */
  66488. audioTracks?: MediaStreamTrack[];
  66489. }
  66490. /**
  66491. * This can help with recording videos from BabylonJS.
  66492. * This is based on the available WebRTC functionalities of the browser.
  66493. *
  66494. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66495. */
  66496. export class VideoRecorder {
  66497. private static readonly _defaultOptions;
  66498. /**
  66499. * Returns whether or not the VideoRecorder is available in your browser.
  66500. * @param engine Defines the Babylon Engine.
  66501. * @returns true if supported otherwise false.
  66502. */
  66503. static IsSupported(engine: Engine): boolean;
  66504. private readonly _options;
  66505. private _canvas;
  66506. private _mediaRecorder;
  66507. private _recordedChunks;
  66508. private _fileName;
  66509. private _resolve;
  66510. private _reject;
  66511. /**
  66512. * True when a recording is already in progress.
  66513. */
  66514. readonly isRecording: boolean;
  66515. /**
  66516. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66517. * @param engine Defines the BabylonJS Engine you wish to record.
  66518. * @param options Defines options that can be used to customize the capture.
  66519. */
  66520. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66521. /**
  66522. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66523. */
  66524. stopRecording(): void;
  66525. /**
  66526. * Starts recording the canvas for a max duration specified in parameters.
  66527. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66528. * If null no automatic download will start and you can rely on the promise to get the data back.
  66529. * @param maxDuration Defines the maximum recording time in seconds.
  66530. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66531. * @return A promise callback at the end of the recording with the video data in Blob.
  66532. */
  66533. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66534. /**
  66535. * Releases internal resources used during the recording.
  66536. */
  66537. dispose(): void;
  66538. private _handleDataAvailable;
  66539. private _handleError;
  66540. private _handleStop;
  66541. }
  66542. }
  66543. declare module "babylonjs/Misc/screenshotTools" {
  66544. import { Camera } from "babylonjs/Cameras/camera";
  66545. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  66546. import { Engine } from "babylonjs/Engines/engine";
  66547. /**
  66548. * Class containing a set of static utilities functions for screenshots
  66549. */
  66550. export class ScreenshotTools {
  66551. /**
  66552. * Captures a screenshot of the current rendering
  66553. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66554. * @param engine defines the rendering engine
  66555. * @param camera defines the source camera
  66556. * @param size This parameter can be set to a single number or to an object with the
  66557. * following (optional) properties: precision, width, height. If a single number is passed,
  66558. * it will be used for both width and height. If an object is passed, the screenshot size
  66559. * will be derived from the parameters. The precision property is a multiplier allowing
  66560. * rendering at a higher or lower resolution
  66561. * @param successCallback defines the callback receives a single parameter which contains the
  66562. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66563. * src parameter of an <img> to display it
  66564. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66565. * Check your browser for supported MIME types
  66566. */
  66567. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66568. /**
  66569. * Captures a screenshot of the current rendering
  66570. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66571. * @param engine defines the rendering engine
  66572. * @param camera defines the source camera
  66573. * @param size This parameter can be set to a single number or to an object with the
  66574. * following (optional) properties: precision, width, height. If a single number is passed,
  66575. * it will be used for both width and height. If an object is passed, the screenshot size
  66576. * will be derived from the parameters. The precision property is a multiplier allowing
  66577. * rendering at a higher or lower resolution
  66578. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66579. * Check your browser for supported MIME types
  66580. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66581. * to the src parameter of an <img> to display it
  66582. */
  66583. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66584. /**
  66585. * Generates an image screenshot from the specified camera.
  66586. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66587. * @param engine The engine to use for rendering
  66588. * @param camera The camera to use for rendering
  66589. * @param size This parameter can be set to a single number or to an object with the
  66590. * following (optional) properties: precision, width, height. If a single number is passed,
  66591. * it will be used for both width and height. If an object is passed, the screenshot size
  66592. * will be derived from the parameters. The precision property is a multiplier allowing
  66593. * rendering at a higher or lower resolution
  66594. * @param successCallback The callback receives a single parameter which contains the
  66595. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66596. * src parameter of an <img> to display it
  66597. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66598. * Check your browser for supported MIME types
  66599. * @param samples Texture samples (default: 1)
  66600. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66601. * @param fileName A name for for the downloaded file.
  66602. */
  66603. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66604. /**
  66605. * Generates an image screenshot from the specified camera.
  66606. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66607. * @param engine The engine to use for rendering
  66608. * @param camera The camera to use for rendering
  66609. * @param size This parameter can be set to a single number or to an object with the
  66610. * following (optional) properties: precision, width, height. If a single number is passed,
  66611. * it will be used for both width and height. If an object is passed, the screenshot size
  66612. * will be derived from the parameters. The precision property is a multiplier allowing
  66613. * rendering at a higher or lower resolution
  66614. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66615. * Check your browser for supported MIME types
  66616. * @param samples Texture samples (default: 1)
  66617. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66618. * @param fileName A name for for the downloaded file.
  66619. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66620. * to the src parameter of an <img> to display it
  66621. */
  66622. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66623. /**
  66624. * Gets height and width for screenshot size
  66625. * @private
  66626. */
  66627. private static _getScreenshotSize;
  66628. }
  66629. }
  66630. declare module "babylonjs/Misc/index" {
  66631. export * from "babylonjs/Misc/andOrNotEvaluator";
  66632. export * from "babylonjs/Misc/assetsManager";
  66633. export * from "babylonjs/Misc/dds";
  66634. export * from "babylonjs/Misc/decorators";
  66635. export * from "babylonjs/Misc/deferred";
  66636. export * from "babylonjs/Misc/environmentTextureTools";
  66637. export * from "babylonjs/Misc/meshExploder";
  66638. export * from "babylonjs/Misc/filesInput";
  66639. export * from "babylonjs/Misc/HighDynamicRange/index";
  66640. export * from "babylonjs/Misc/khronosTextureContainer";
  66641. export * from "babylonjs/Misc/observable";
  66642. export * from "babylonjs/Misc/performanceMonitor";
  66643. export * from "babylonjs/Misc/promise";
  66644. export * from "babylonjs/Misc/sceneOptimizer";
  66645. export * from "babylonjs/Misc/sceneSerializer";
  66646. export * from "babylonjs/Misc/smartArray";
  66647. export * from "babylonjs/Misc/stringDictionary";
  66648. export * from "babylonjs/Misc/tags";
  66649. export * from "babylonjs/Misc/textureTools";
  66650. export * from "babylonjs/Misc/tga";
  66651. export * from "babylonjs/Misc/tools";
  66652. export * from "babylonjs/Misc/videoRecorder";
  66653. export * from "babylonjs/Misc/virtualJoystick";
  66654. export * from "babylonjs/Misc/workerPool";
  66655. export * from "babylonjs/Misc/logger";
  66656. export * from "babylonjs/Misc/typeStore";
  66657. export * from "babylonjs/Misc/filesInputStore";
  66658. export * from "babylonjs/Misc/deepCopier";
  66659. export * from "babylonjs/Misc/pivotTools";
  66660. export * from "babylonjs/Misc/precisionDate";
  66661. export * from "babylonjs/Misc/screenshotTools";
  66662. export * from "babylonjs/Misc/typeStore";
  66663. export * from "babylonjs/Misc/webRequest";
  66664. export * from "babylonjs/Misc/iInspectable";
  66665. export * from "babylonjs/Misc/brdfTextureTools";
  66666. export * from "babylonjs/Misc/rgbdTextureTools";
  66667. export * from "babylonjs/Misc/gradients";
  66668. export * from "babylonjs/Misc/perfCounter";
  66669. export * from "babylonjs/Misc/fileRequest";
  66670. export * from "babylonjs/Misc/customAnimationFrameRequester";
  66671. export * from "babylonjs/Misc/retryStrategy";
  66672. export * from "babylonjs/Misc/loadFileError";
  66673. export * from "babylonjs/Misc/interfaces/screenshotSize";
  66674. }
  66675. declare module "babylonjs/index" {
  66676. export * from "babylonjs/abstractScene";
  66677. export * from "babylonjs/Actions/index";
  66678. export * from "babylonjs/Animations/index";
  66679. export * from "babylonjs/assetContainer";
  66680. export * from "babylonjs/Audio/index";
  66681. export * from "babylonjs/Behaviors/index";
  66682. export * from "babylonjs/Bones/index";
  66683. export * from "babylonjs/Cameras/index";
  66684. export * from "babylonjs/Collisions/index";
  66685. export * from "babylonjs/Culling/index";
  66686. export * from "babylonjs/Debug/index";
  66687. export * from "babylonjs/Engines/index";
  66688. export * from "babylonjs/Events/index";
  66689. export * from "babylonjs/Gamepads/index";
  66690. export * from "babylonjs/Gizmos/index";
  66691. export * from "babylonjs/Helpers/index";
  66692. export * from "babylonjs/Instrumentation/index";
  66693. export * from "babylonjs/Layers/index";
  66694. export * from "babylonjs/LensFlares/index";
  66695. export * from "babylonjs/Lights/index";
  66696. export * from "babylonjs/Loading/index";
  66697. export * from "babylonjs/Materials/index";
  66698. export * from "babylonjs/Maths/index";
  66699. export * from "babylonjs/Meshes/index";
  66700. export * from "babylonjs/Morph/index";
  66701. export * from "babylonjs/Navigation/index";
  66702. export * from "babylonjs/node";
  66703. export * from "babylonjs/Offline/index";
  66704. export * from "babylonjs/Particles/index";
  66705. export * from "babylonjs/Physics/index";
  66706. export * from "babylonjs/PostProcesses/index";
  66707. export * from "babylonjs/Probes/index";
  66708. export * from "babylonjs/Rendering/index";
  66709. export * from "babylonjs/scene";
  66710. export * from "babylonjs/sceneComponent";
  66711. export * from "babylonjs/Sprites/index";
  66712. export * from "babylonjs/States/index";
  66713. export * from "babylonjs/Misc/index";
  66714. export * from "babylonjs/types";
  66715. }
  66716. declare module "babylonjs/Animations/pathCursor" {
  66717. import { Vector3 } from "babylonjs/Maths/math.vector";
  66718. import { Path2 } from "babylonjs/Maths/math.path";
  66719. /**
  66720. * A cursor which tracks a point on a path
  66721. */
  66722. export class PathCursor {
  66723. private path;
  66724. /**
  66725. * Stores path cursor callbacks for when an onchange event is triggered
  66726. */
  66727. private _onchange;
  66728. /**
  66729. * The value of the path cursor
  66730. */
  66731. value: number;
  66732. /**
  66733. * The animation array of the path cursor
  66734. */
  66735. animations: Animation[];
  66736. /**
  66737. * Initializes the path cursor
  66738. * @param path The path to track
  66739. */
  66740. constructor(path: Path2);
  66741. /**
  66742. * Gets the cursor point on the path
  66743. * @returns A point on the path cursor at the cursor location
  66744. */
  66745. getPoint(): Vector3;
  66746. /**
  66747. * Moves the cursor ahead by the step amount
  66748. * @param step The amount to move the cursor forward
  66749. * @returns This path cursor
  66750. */
  66751. moveAhead(step?: number): PathCursor;
  66752. /**
  66753. * Moves the cursor behind by the step amount
  66754. * @param step The amount to move the cursor back
  66755. * @returns This path cursor
  66756. */
  66757. moveBack(step?: number): PathCursor;
  66758. /**
  66759. * Moves the cursor by the step amount
  66760. * If the step amount is greater than one, an exception is thrown
  66761. * @param step The amount to move the cursor
  66762. * @returns This path cursor
  66763. */
  66764. move(step: number): PathCursor;
  66765. /**
  66766. * Ensures that the value is limited between zero and one
  66767. * @returns This path cursor
  66768. */
  66769. private ensureLimits;
  66770. /**
  66771. * Runs onchange callbacks on change (used by the animation engine)
  66772. * @returns This path cursor
  66773. */
  66774. private raiseOnChange;
  66775. /**
  66776. * Executes a function on change
  66777. * @param f A path cursor onchange callback
  66778. * @returns This path cursor
  66779. */
  66780. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66781. }
  66782. }
  66783. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  66784. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  66785. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  66786. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  66787. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  66788. }
  66789. declare module "babylonjs/Engines/Processors/Expressions/index" {
  66790. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  66791. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  66792. }
  66793. declare module "babylonjs/Engines/Processors/index" {
  66794. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  66795. export * from "babylonjs/Engines/Processors/Expressions/index";
  66796. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  66797. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  66798. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  66799. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  66800. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  66801. export * from "babylonjs/Engines/Processors/shaderProcessor";
  66802. }
  66803. declare module "babylonjs/Legacy/legacy" {
  66804. import * as Babylon from "babylonjs/index";
  66805. export * from "babylonjs/index";
  66806. }
  66807. declare module "babylonjs/Shaders/blur.fragment" {
  66808. /** @hidden */
  66809. export var blurPixelShader: {
  66810. name: string;
  66811. shader: string;
  66812. };
  66813. }
  66814. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  66815. /** @hidden */
  66816. export var pointCloudVertexDeclaration: {
  66817. name: string;
  66818. shader: string;
  66819. };
  66820. }
  66821. declare module "babylonjs" {
  66822. export * from "babylonjs/Legacy/legacy";
  66823. }
  66824. declare module BABYLON {
  66825. /** Alias type for value that can be null */
  66826. export type Nullable<T> = T | null;
  66827. /**
  66828. * Alias type for number that are floats
  66829. * @ignorenaming
  66830. */
  66831. export type float = number;
  66832. /**
  66833. * Alias type for number that are doubles.
  66834. * @ignorenaming
  66835. */
  66836. export type double = number;
  66837. /**
  66838. * Alias type for number that are integer
  66839. * @ignorenaming
  66840. */
  66841. export type int = number;
  66842. /** Alias type for number array or Float32Array */
  66843. export type FloatArray = number[] | Float32Array;
  66844. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  66845. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  66846. /**
  66847. * Alias for types that can be used by a Buffer or VertexBuffer.
  66848. */
  66849. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  66850. /**
  66851. * Alias type for primitive types
  66852. * @ignorenaming
  66853. */
  66854. type Primitive = undefined | null | boolean | string | number | Function;
  66855. /**
  66856. * Type modifier to make all the properties of an object Readonly
  66857. */
  66858. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  66859. /**
  66860. * Type modifier to make all the properties of an object Readonly recursively
  66861. */
  66862. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  66863. /**
  66864. * Type modifier to make object properties readonly.
  66865. */
  66866. export type DeepImmutableObject<T> = {
  66867. readonly [K in keyof T]: DeepImmutable<T[K]>;
  66868. };
  66869. /** @hidden */
  66870. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  66871. }
  66872. }
  66873. declare module BABYLON {
  66874. /**
  66875. * A class serves as a medium between the observable and its observers
  66876. */
  66877. export class EventState {
  66878. /**
  66879. * Create a new EventState
  66880. * @param mask defines the mask associated with this state
  66881. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66882. * @param target defines the original target of the state
  66883. * @param currentTarget defines the current target of the state
  66884. */
  66885. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66886. /**
  66887. * Initialize the current event state
  66888. * @param mask defines the mask associated with this state
  66889. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66890. * @param target defines the original target of the state
  66891. * @param currentTarget defines the current target of the state
  66892. * @returns the current event state
  66893. */
  66894. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66895. /**
  66896. * An Observer can set this property to true to prevent subsequent observers of being notified
  66897. */
  66898. skipNextObservers: boolean;
  66899. /**
  66900. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66901. */
  66902. mask: number;
  66903. /**
  66904. * The object that originally notified the event
  66905. */
  66906. target?: any;
  66907. /**
  66908. * The current object in the bubbling phase
  66909. */
  66910. currentTarget?: any;
  66911. /**
  66912. * This will be populated with the return value of the last function that was executed.
  66913. * If it is the first function in the callback chain it will be the event data.
  66914. */
  66915. lastReturnValue?: any;
  66916. }
  66917. /**
  66918. * Represent an Observer registered to a given Observable object.
  66919. */
  66920. export class Observer<T> {
  66921. /**
  66922. * Defines the callback to call when the observer is notified
  66923. */
  66924. callback: (eventData: T, eventState: EventState) => void;
  66925. /**
  66926. * Defines the mask of the observer (used to filter notifications)
  66927. */
  66928. mask: number;
  66929. /**
  66930. * Defines the current scope used to restore the JS context
  66931. */
  66932. scope: any;
  66933. /** @hidden */
  66934. _willBeUnregistered: boolean;
  66935. /**
  66936. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66937. */
  66938. unregisterOnNextCall: boolean;
  66939. /**
  66940. * Creates a new observer
  66941. * @param callback defines the callback to call when the observer is notified
  66942. * @param mask defines the mask of the observer (used to filter notifications)
  66943. * @param scope defines the current scope used to restore the JS context
  66944. */
  66945. constructor(
  66946. /**
  66947. * Defines the callback to call when the observer is notified
  66948. */
  66949. callback: (eventData: T, eventState: EventState) => void,
  66950. /**
  66951. * Defines the mask of the observer (used to filter notifications)
  66952. */
  66953. mask: number,
  66954. /**
  66955. * Defines the current scope used to restore the JS context
  66956. */
  66957. scope?: any);
  66958. }
  66959. /**
  66960. * Represent a list of observers registered to multiple Observables object.
  66961. */
  66962. export class MultiObserver<T> {
  66963. private _observers;
  66964. private _observables;
  66965. /**
  66966. * Release associated resources
  66967. */
  66968. dispose(): void;
  66969. /**
  66970. * Raise a callback when one of the observable will notify
  66971. * @param observables defines a list of observables to watch
  66972. * @param callback defines the callback to call on notification
  66973. * @param mask defines the mask used to filter notifications
  66974. * @param scope defines the current scope used to restore the JS context
  66975. * @returns the new MultiObserver
  66976. */
  66977. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66978. }
  66979. /**
  66980. * The Observable class is a simple implementation of the Observable pattern.
  66981. *
  66982. * 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.
  66983. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66984. * 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).
  66985. * 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.
  66986. */
  66987. export class Observable<T> {
  66988. private _observers;
  66989. private _eventState;
  66990. private _onObserverAdded;
  66991. /**
  66992. * Gets the list of observers
  66993. */
  66994. readonly observers: Array<Observer<T>>;
  66995. /**
  66996. * Creates a new observable
  66997. * @param onObserverAdded defines a callback to call when a new observer is added
  66998. */
  66999. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67000. /**
  67001. * Create a new Observer with the specified callback
  67002. * @param callback the callback that will be executed for that Observer
  67003. * @param mask the mask used to filter observers
  67004. * @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.
  67005. * @param scope optional scope for the callback to be called from
  67006. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67007. * @returns the new observer created for the callback
  67008. */
  67009. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67010. /**
  67011. * Create a new Observer with the specified callback and unregisters after the next notification
  67012. * @param callback the callback that will be executed for that Observer
  67013. * @returns the new observer created for the callback
  67014. */
  67015. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67016. /**
  67017. * Remove an Observer from the Observable object
  67018. * @param observer the instance of the Observer to remove
  67019. * @returns false if it doesn't belong to this Observable
  67020. */
  67021. remove(observer: Nullable<Observer<T>>): boolean;
  67022. /**
  67023. * Remove a callback from the Observable object
  67024. * @param callback the callback to remove
  67025. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67026. * @returns false if it doesn't belong to this Observable
  67027. */
  67028. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67029. private _deferUnregister;
  67030. private _remove;
  67031. /**
  67032. * Moves the observable to the top of the observer list making it get called first when notified
  67033. * @param observer the observer to move
  67034. */
  67035. makeObserverTopPriority(observer: Observer<T>): void;
  67036. /**
  67037. * Moves the observable to the bottom of the observer list making it get called last when notified
  67038. * @param observer the observer to move
  67039. */
  67040. makeObserverBottomPriority(observer: Observer<T>): void;
  67041. /**
  67042. * Notify all Observers by calling their respective callback with the given data
  67043. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67044. * @param eventData defines the data to send to all observers
  67045. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67046. * @param target defines the original target of the state
  67047. * @param currentTarget defines the current target of the state
  67048. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67049. */
  67050. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67051. /**
  67052. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67053. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67054. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67055. * and it is crucial that all callbacks will be executed.
  67056. * The order of the callbacks is kept, callbacks are not executed parallel.
  67057. *
  67058. * @param eventData The data to be sent to each callback
  67059. * @param mask is used to filter observers defaults to -1
  67060. * @param target defines the callback target (see EventState)
  67061. * @param currentTarget defines he current object in the bubbling phase
  67062. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67063. */
  67064. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67065. /**
  67066. * Notify a specific observer
  67067. * @param observer defines the observer to notify
  67068. * @param eventData defines the data to be sent to each callback
  67069. * @param mask is used to filter observers defaults to -1
  67070. */
  67071. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67072. /**
  67073. * Gets a boolean indicating if the observable has at least one observer
  67074. * @returns true is the Observable has at least one Observer registered
  67075. */
  67076. hasObservers(): boolean;
  67077. /**
  67078. * Clear the list of observers
  67079. */
  67080. clear(): void;
  67081. /**
  67082. * Clone the current observable
  67083. * @returns a new observable
  67084. */
  67085. clone(): Observable<T>;
  67086. /**
  67087. * Does this observable handles observer registered with a given mask
  67088. * @param mask defines the mask to be tested
  67089. * @return whether or not one observer registered with the given mask is handeled
  67090. **/
  67091. hasSpecificMask(mask?: number): boolean;
  67092. }
  67093. }
  67094. declare module BABYLON {
  67095. /**
  67096. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67097. * Babylon.js
  67098. */
  67099. export class DomManagement {
  67100. /**
  67101. * Checks if the window object exists
  67102. * @returns true if the window object exists
  67103. */
  67104. static IsWindowObjectExist(): boolean;
  67105. /**
  67106. * Checks if the navigator object exists
  67107. * @returns true if the navigator object exists
  67108. */
  67109. static IsNavigatorAvailable(): boolean;
  67110. /**
  67111. * Extracts text content from a DOM element hierarchy
  67112. * @param element defines the root element
  67113. * @returns a string
  67114. */
  67115. static GetDOMTextContent(element: HTMLElement): string;
  67116. }
  67117. }
  67118. declare module BABYLON {
  67119. /**
  67120. * Logger used througouht the application to allow configuration of
  67121. * the log level required for the messages.
  67122. */
  67123. export class Logger {
  67124. /**
  67125. * No log
  67126. */
  67127. static readonly NoneLogLevel: number;
  67128. /**
  67129. * Only message logs
  67130. */
  67131. static readonly MessageLogLevel: number;
  67132. /**
  67133. * Only warning logs
  67134. */
  67135. static readonly WarningLogLevel: number;
  67136. /**
  67137. * Only error logs
  67138. */
  67139. static readonly ErrorLogLevel: number;
  67140. /**
  67141. * All logs
  67142. */
  67143. static readonly AllLogLevel: number;
  67144. private static _LogCache;
  67145. /**
  67146. * Gets a value indicating the number of loading errors
  67147. * @ignorenaming
  67148. */
  67149. static errorsCount: number;
  67150. /**
  67151. * Callback called when a new log is added
  67152. */
  67153. static OnNewCacheEntry: (entry: string) => void;
  67154. private static _AddLogEntry;
  67155. private static _FormatMessage;
  67156. private static _LogDisabled;
  67157. private static _LogEnabled;
  67158. private static _WarnDisabled;
  67159. private static _WarnEnabled;
  67160. private static _ErrorDisabled;
  67161. private static _ErrorEnabled;
  67162. /**
  67163. * Log a message to the console
  67164. */
  67165. static Log: (message: string) => void;
  67166. /**
  67167. * Write a warning message to the console
  67168. */
  67169. static Warn: (message: string) => void;
  67170. /**
  67171. * Write an error message to the console
  67172. */
  67173. static Error: (message: string) => void;
  67174. /**
  67175. * Gets current log cache (list of logs)
  67176. */
  67177. static readonly LogCache: string;
  67178. /**
  67179. * Clears the log cache
  67180. */
  67181. static ClearLogCache(): void;
  67182. /**
  67183. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67184. */
  67185. static LogLevels: number;
  67186. }
  67187. }
  67188. declare module BABYLON {
  67189. /** @hidden */
  67190. export class _TypeStore {
  67191. /** @hidden */
  67192. static RegisteredTypes: {
  67193. [key: string]: Object;
  67194. };
  67195. /** @hidden */
  67196. static GetClass(fqdn: string): any;
  67197. }
  67198. }
  67199. declare module BABYLON {
  67200. /**
  67201. * Class containing a set of static utilities functions for deep copy.
  67202. */
  67203. export class DeepCopier {
  67204. /**
  67205. * Tries to copy an object by duplicating every property
  67206. * @param source defines the source object
  67207. * @param destination defines the target object
  67208. * @param doNotCopyList defines a list of properties to avoid
  67209. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67210. */
  67211. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67212. }
  67213. }
  67214. declare module BABYLON {
  67215. /**
  67216. * Class containing a set of static utilities functions for precision date
  67217. */
  67218. export class PrecisionDate {
  67219. /**
  67220. * Gets either window.performance.now() if supported or Date.now() else
  67221. */
  67222. static readonly Now: number;
  67223. }
  67224. }
  67225. declare module BABYLON {
  67226. /** @hidden */
  67227. export class _DevTools {
  67228. static WarnImport(name: string): string;
  67229. }
  67230. }
  67231. declare module BABYLON {
  67232. /**
  67233. * Interface used to define the mechanism to get data from the network
  67234. */
  67235. export interface IWebRequest {
  67236. /**
  67237. * Returns client's response url
  67238. */
  67239. responseURL: string;
  67240. /**
  67241. * Returns client's status
  67242. */
  67243. status: number;
  67244. /**
  67245. * Returns client's status as a text
  67246. */
  67247. statusText: string;
  67248. }
  67249. }
  67250. declare module BABYLON {
  67251. /**
  67252. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67253. */
  67254. export class WebRequest implements IWebRequest {
  67255. private _xhr;
  67256. /**
  67257. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67258. * i.e. when loading files, where the server/service expects an Authorization header
  67259. */
  67260. static CustomRequestHeaders: {
  67261. [key: string]: string;
  67262. };
  67263. /**
  67264. * Add callback functions in this array to update all the requests before they get sent to the network
  67265. */
  67266. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67267. private _injectCustomRequestHeaders;
  67268. /**
  67269. * Gets or sets a function to be called when loading progress changes
  67270. */
  67271. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67272. /**
  67273. * Returns client's state
  67274. */
  67275. readonly readyState: number;
  67276. /**
  67277. * Returns client's status
  67278. */
  67279. readonly status: number;
  67280. /**
  67281. * Returns client's status as a text
  67282. */
  67283. readonly statusText: string;
  67284. /**
  67285. * Returns client's response
  67286. */
  67287. readonly response: any;
  67288. /**
  67289. * Returns client's response url
  67290. */
  67291. readonly responseURL: string;
  67292. /**
  67293. * Returns client's response as text
  67294. */
  67295. readonly responseText: string;
  67296. /**
  67297. * Gets or sets the expected response type
  67298. */
  67299. responseType: XMLHttpRequestResponseType;
  67300. /** @hidden */
  67301. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67302. /** @hidden */
  67303. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67304. /**
  67305. * Cancels any network activity
  67306. */
  67307. abort(): void;
  67308. /**
  67309. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67310. * @param body defines an optional request body
  67311. */
  67312. send(body?: Document | BodyInit | null): void;
  67313. /**
  67314. * Sets the request method, request URL
  67315. * @param method defines the method to use (GET, POST, etc..)
  67316. * @param url defines the url to connect with
  67317. */
  67318. open(method: string, url: string): void;
  67319. }
  67320. }
  67321. declare module BABYLON {
  67322. /**
  67323. * File request interface
  67324. */
  67325. export interface IFileRequest {
  67326. /**
  67327. * Raised when the request is complete (success or error).
  67328. */
  67329. onCompleteObservable: Observable<IFileRequest>;
  67330. /**
  67331. * Aborts the request for a file.
  67332. */
  67333. abort: () => void;
  67334. }
  67335. }
  67336. declare module BABYLON {
  67337. /**
  67338. * Define options used to create a render target texture
  67339. */
  67340. export class RenderTargetCreationOptions {
  67341. /**
  67342. * Specifies is mipmaps must be generated
  67343. */
  67344. generateMipMaps?: boolean;
  67345. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  67346. generateDepthBuffer?: boolean;
  67347. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  67348. generateStencilBuffer?: boolean;
  67349. /** Defines texture type (int by default) */
  67350. type?: number;
  67351. /** Defines sampling mode (trilinear by default) */
  67352. samplingMode?: number;
  67353. /** Defines format (RGBA by default) */
  67354. format?: number;
  67355. }
  67356. }
  67357. declare module BABYLON {
  67358. /**
  67359. * @hidden
  67360. **/
  67361. export class _TimeToken {
  67362. _startTimeQuery: Nullable<WebGLQuery>;
  67363. _endTimeQuery: Nullable<WebGLQuery>;
  67364. _timeElapsedQuery: Nullable<WebGLQuery>;
  67365. _timeElapsedQueryEnded: boolean;
  67366. }
  67367. }
  67368. declare module BABYLON {
  67369. /** Defines the cross module used constants to avoid circular dependncies */
  67370. export class Constants {
  67371. /** Defines that alpha blending is disabled */
  67372. static readonly ALPHA_DISABLE: number;
  67373. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67374. static readonly ALPHA_ADD: number;
  67375. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67376. static readonly ALPHA_COMBINE: number;
  67377. /** Defines that alpha blending to DEST - SRC * DEST */
  67378. static readonly ALPHA_SUBTRACT: number;
  67379. /** Defines that alpha blending to SRC * DEST */
  67380. static readonly ALPHA_MULTIPLY: number;
  67381. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67382. static readonly ALPHA_MAXIMIZED: number;
  67383. /** Defines that alpha blending to SRC + DEST */
  67384. static readonly ALPHA_ONEONE: number;
  67385. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67386. static readonly ALPHA_PREMULTIPLIED: number;
  67387. /**
  67388. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67389. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67390. */
  67391. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67392. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67393. static readonly ALPHA_INTERPOLATE: number;
  67394. /**
  67395. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67396. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67397. */
  67398. static readonly ALPHA_SCREENMODE: number;
  67399. /**
  67400. * Defines that alpha blending to SRC + DST
  67401. * Alpha will be set to SRC ALPHA + DST ALPHA
  67402. */
  67403. static readonly ALPHA_ONEONE_ONEONE: number;
  67404. /**
  67405. * Defines that alpha blending to SRC * DST ALPHA + DST
  67406. * Alpha will be set to 0
  67407. */
  67408. static readonly ALPHA_ALPHATOCOLOR: number;
  67409. /**
  67410. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  67411. */
  67412. static readonly ALPHA_REVERSEONEMINUS: number;
  67413. /**
  67414. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  67415. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  67416. */
  67417. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  67418. /**
  67419. * Defines that alpha blending to SRC + DST
  67420. * Alpha will be set to SRC ALPHA
  67421. */
  67422. static readonly ALPHA_ONEONE_ONEZERO: number;
  67423. /** Defines that alpha blending equation a SUM */
  67424. static readonly ALPHA_EQUATION_ADD: number;
  67425. /** Defines that alpha blending equation a SUBSTRACTION */
  67426. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  67427. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  67428. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  67429. /** Defines that alpha blending equation a MAX operation */
  67430. static readonly ALPHA_EQUATION_MAX: number;
  67431. /** Defines that alpha blending equation a MIN operation */
  67432. static readonly ALPHA_EQUATION_MIN: number;
  67433. /**
  67434. * Defines that alpha blending equation a DARKEN operation:
  67435. * It takes the min of the src and sums the alpha channels.
  67436. */
  67437. static readonly ALPHA_EQUATION_DARKEN: number;
  67438. /** Defines that the ressource is not delayed*/
  67439. static readonly DELAYLOADSTATE_NONE: number;
  67440. /** Defines that the ressource was successfully delay loaded */
  67441. static readonly DELAYLOADSTATE_LOADED: number;
  67442. /** Defines that the ressource is currently delay loading */
  67443. static readonly DELAYLOADSTATE_LOADING: number;
  67444. /** Defines that the ressource is delayed and has not started loading */
  67445. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67446. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67447. static readonly NEVER: number;
  67448. /** 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 */
  67449. static readonly ALWAYS: number;
  67450. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67451. static readonly LESS: number;
  67452. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67453. static readonly EQUAL: number;
  67454. /** 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 */
  67455. static readonly LEQUAL: number;
  67456. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67457. static readonly GREATER: number;
  67458. /** 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 */
  67459. static readonly GEQUAL: number;
  67460. /** 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 */
  67461. static readonly NOTEQUAL: number;
  67462. /** Passed to stencilOperation to specify that stencil value must be kept */
  67463. static readonly KEEP: number;
  67464. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67465. static readonly REPLACE: number;
  67466. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67467. static readonly INCR: number;
  67468. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67469. static readonly DECR: number;
  67470. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67471. static readonly INVERT: number;
  67472. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67473. static readonly INCR_WRAP: number;
  67474. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67475. static readonly DECR_WRAP: number;
  67476. /** Texture is not repeating outside of 0..1 UVs */
  67477. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67478. /** Texture is repeating outside of 0..1 UVs */
  67479. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67480. /** Texture is repeating and mirrored */
  67481. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67482. /** ALPHA */
  67483. static readonly TEXTUREFORMAT_ALPHA: number;
  67484. /** LUMINANCE */
  67485. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67486. /** LUMINANCE_ALPHA */
  67487. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67488. /** RGB */
  67489. static readonly TEXTUREFORMAT_RGB: number;
  67490. /** RGBA */
  67491. static readonly TEXTUREFORMAT_RGBA: number;
  67492. /** RED */
  67493. static readonly TEXTUREFORMAT_RED: number;
  67494. /** RED (2nd reference) */
  67495. static readonly TEXTUREFORMAT_R: number;
  67496. /** RG */
  67497. static readonly TEXTUREFORMAT_RG: number;
  67498. /** RED_INTEGER */
  67499. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67500. /** RED_INTEGER (2nd reference) */
  67501. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67502. /** RG_INTEGER */
  67503. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67504. /** RGB_INTEGER */
  67505. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67506. /** RGBA_INTEGER */
  67507. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67508. /** UNSIGNED_BYTE */
  67509. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67510. /** UNSIGNED_BYTE (2nd reference) */
  67511. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67512. /** FLOAT */
  67513. static readonly TEXTURETYPE_FLOAT: number;
  67514. /** HALF_FLOAT */
  67515. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67516. /** BYTE */
  67517. static readonly TEXTURETYPE_BYTE: number;
  67518. /** SHORT */
  67519. static readonly TEXTURETYPE_SHORT: number;
  67520. /** UNSIGNED_SHORT */
  67521. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67522. /** INT */
  67523. static readonly TEXTURETYPE_INT: number;
  67524. /** UNSIGNED_INT */
  67525. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67526. /** UNSIGNED_SHORT_4_4_4_4 */
  67527. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67528. /** UNSIGNED_SHORT_5_5_5_1 */
  67529. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67530. /** UNSIGNED_SHORT_5_6_5 */
  67531. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67532. /** UNSIGNED_INT_2_10_10_10_REV */
  67533. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67534. /** UNSIGNED_INT_24_8 */
  67535. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67536. /** UNSIGNED_INT_10F_11F_11F_REV */
  67537. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67538. /** UNSIGNED_INT_5_9_9_9_REV */
  67539. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67540. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67541. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67542. /** nearest is mag = nearest and min = nearest and mip = linear */
  67543. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67544. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67545. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67546. /** Trilinear is mag = linear and min = linear and mip = linear */
  67547. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67548. /** nearest is mag = nearest and min = nearest and mip = linear */
  67549. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67550. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67551. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67552. /** Trilinear is mag = linear and min = linear and mip = linear */
  67553. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67554. /** mag = nearest and min = nearest and mip = nearest */
  67555. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67556. /** mag = nearest and min = linear and mip = nearest */
  67557. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67558. /** mag = nearest and min = linear and mip = linear */
  67559. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67560. /** mag = nearest and min = linear and mip = none */
  67561. static readonly TEXTURE_NEAREST_LINEAR: number;
  67562. /** mag = nearest and min = nearest and mip = none */
  67563. static readonly TEXTURE_NEAREST_NEAREST: number;
  67564. /** mag = linear and min = nearest and mip = nearest */
  67565. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67566. /** mag = linear and min = nearest and mip = linear */
  67567. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67568. /** mag = linear and min = linear and mip = none */
  67569. static readonly TEXTURE_LINEAR_LINEAR: number;
  67570. /** mag = linear and min = nearest and mip = none */
  67571. static readonly TEXTURE_LINEAR_NEAREST: number;
  67572. /** Explicit coordinates mode */
  67573. static readonly TEXTURE_EXPLICIT_MODE: number;
  67574. /** Spherical coordinates mode */
  67575. static readonly TEXTURE_SPHERICAL_MODE: number;
  67576. /** Planar coordinates mode */
  67577. static readonly TEXTURE_PLANAR_MODE: number;
  67578. /** Cubic coordinates mode */
  67579. static readonly TEXTURE_CUBIC_MODE: number;
  67580. /** Projection coordinates mode */
  67581. static readonly TEXTURE_PROJECTION_MODE: number;
  67582. /** Skybox coordinates mode */
  67583. static readonly TEXTURE_SKYBOX_MODE: number;
  67584. /** Inverse Cubic coordinates mode */
  67585. static readonly TEXTURE_INVCUBIC_MODE: number;
  67586. /** Equirectangular coordinates mode */
  67587. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67588. /** Equirectangular Fixed coordinates mode */
  67589. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67590. /** Equirectangular Fixed Mirrored coordinates mode */
  67591. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67592. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67593. static readonly SCALEMODE_FLOOR: number;
  67594. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67595. static readonly SCALEMODE_NEAREST: number;
  67596. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67597. static readonly SCALEMODE_CEILING: number;
  67598. /**
  67599. * The dirty texture flag value
  67600. */
  67601. static readonly MATERIAL_TextureDirtyFlag: number;
  67602. /**
  67603. * The dirty light flag value
  67604. */
  67605. static readonly MATERIAL_LightDirtyFlag: number;
  67606. /**
  67607. * The dirty fresnel flag value
  67608. */
  67609. static readonly MATERIAL_FresnelDirtyFlag: number;
  67610. /**
  67611. * The dirty attribute flag value
  67612. */
  67613. static readonly MATERIAL_AttributesDirtyFlag: number;
  67614. /**
  67615. * The dirty misc flag value
  67616. */
  67617. static readonly MATERIAL_MiscDirtyFlag: number;
  67618. /**
  67619. * The all dirty flag value
  67620. */
  67621. static readonly MATERIAL_AllDirtyFlag: number;
  67622. /**
  67623. * Returns the triangle fill mode
  67624. */
  67625. static readonly MATERIAL_TriangleFillMode: number;
  67626. /**
  67627. * Returns the wireframe mode
  67628. */
  67629. static readonly MATERIAL_WireFrameFillMode: number;
  67630. /**
  67631. * Returns the point fill mode
  67632. */
  67633. static readonly MATERIAL_PointFillMode: number;
  67634. /**
  67635. * Returns the point list draw mode
  67636. */
  67637. static readonly MATERIAL_PointListDrawMode: number;
  67638. /**
  67639. * Returns the line list draw mode
  67640. */
  67641. static readonly MATERIAL_LineListDrawMode: number;
  67642. /**
  67643. * Returns the line loop draw mode
  67644. */
  67645. static readonly MATERIAL_LineLoopDrawMode: number;
  67646. /**
  67647. * Returns the line strip draw mode
  67648. */
  67649. static readonly MATERIAL_LineStripDrawMode: number;
  67650. /**
  67651. * Returns the triangle strip draw mode
  67652. */
  67653. static readonly MATERIAL_TriangleStripDrawMode: number;
  67654. /**
  67655. * Returns the triangle fan draw mode
  67656. */
  67657. static readonly MATERIAL_TriangleFanDrawMode: number;
  67658. /**
  67659. * Stores the clock-wise side orientation
  67660. */
  67661. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67662. /**
  67663. * Stores the counter clock-wise side orientation
  67664. */
  67665. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67666. /**
  67667. * Nothing
  67668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67669. */
  67670. static readonly ACTION_NothingTrigger: number;
  67671. /**
  67672. * On pick
  67673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67674. */
  67675. static readonly ACTION_OnPickTrigger: number;
  67676. /**
  67677. * On left pick
  67678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67679. */
  67680. static readonly ACTION_OnLeftPickTrigger: number;
  67681. /**
  67682. * On right pick
  67683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67684. */
  67685. static readonly ACTION_OnRightPickTrigger: number;
  67686. /**
  67687. * On center pick
  67688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67689. */
  67690. static readonly ACTION_OnCenterPickTrigger: number;
  67691. /**
  67692. * On pick down
  67693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67694. */
  67695. static readonly ACTION_OnPickDownTrigger: number;
  67696. /**
  67697. * On double pick
  67698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67699. */
  67700. static readonly ACTION_OnDoublePickTrigger: number;
  67701. /**
  67702. * On pick up
  67703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67704. */
  67705. static readonly ACTION_OnPickUpTrigger: number;
  67706. /**
  67707. * On pick out.
  67708. * This trigger will only be raised if you also declared a OnPickDown
  67709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67710. */
  67711. static readonly ACTION_OnPickOutTrigger: number;
  67712. /**
  67713. * On long press
  67714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67715. */
  67716. static readonly ACTION_OnLongPressTrigger: number;
  67717. /**
  67718. * On pointer over
  67719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67720. */
  67721. static readonly ACTION_OnPointerOverTrigger: number;
  67722. /**
  67723. * On pointer out
  67724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67725. */
  67726. static readonly ACTION_OnPointerOutTrigger: number;
  67727. /**
  67728. * On every frame
  67729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67730. */
  67731. static readonly ACTION_OnEveryFrameTrigger: number;
  67732. /**
  67733. * On intersection enter
  67734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67735. */
  67736. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67737. /**
  67738. * On intersection exit
  67739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67740. */
  67741. static readonly ACTION_OnIntersectionExitTrigger: number;
  67742. /**
  67743. * On key down
  67744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67745. */
  67746. static readonly ACTION_OnKeyDownTrigger: number;
  67747. /**
  67748. * On key up
  67749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67750. */
  67751. static readonly ACTION_OnKeyUpTrigger: number;
  67752. /**
  67753. * Billboard mode will only apply to Y axis
  67754. */
  67755. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67756. /**
  67757. * Billboard mode will apply to all axes
  67758. */
  67759. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67760. /**
  67761. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67762. */
  67763. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67764. /**
  67765. * Gets or sets base Assets URL
  67766. */
  67767. static PARTICLES_BaseAssetsUrl: string;
  67768. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67769. * Test order :
  67770. * Is the bounding sphere outside the frustum ?
  67771. * If not, are the bounding box vertices outside the frustum ?
  67772. * It not, then the cullable object is in the frustum.
  67773. */
  67774. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67775. /** Culling strategy : Bounding Sphere Only.
  67776. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67777. * It's also less accurate than the standard because some not visible objects can still be selected.
  67778. * Test : is the bounding sphere outside the frustum ?
  67779. * If not, then the cullable object is in the frustum.
  67780. */
  67781. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67782. /** Culling strategy : Optimistic Inclusion.
  67783. * This in an inclusion test first, then the standard exclusion test.
  67784. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67785. * 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.
  67786. * Anyway, it's as accurate as the standard strategy.
  67787. * Test :
  67788. * Is the cullable object bounding sphere center in the frustum ?
  67789. * If not, apply the default culling strategy.
  67790. */
  67791. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67792. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67793. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67794. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67795. * 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.
  67796. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67797. * Test :
  67798. * Is the cullable object bounding sphere center in the frustum ?
  67799. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67800. */
  67801. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67802. /**
  67803. * No logging while loading
  67804. */
  67805. static readonly SCENELOADER_NO_LOGGING: number;
  67806. /**
  67807. * Minimal logging while loading
  67808. */
  67809. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67810. /**
  67811. * Summary logging while loading
  67812. */
  67813. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67814. /**
  67815. * Detailled logging while loading
  67816. */
  67817. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67818. }
  67819. }
  67820. declare module BABYLON {
  67821. /**
  67822. * This represents the required contract to create a new type of texture loader.
  67823. */
  67824. export interface IInternalTextureLoader {
  67825. /**
  67826. * Defines wether the loader supports cascade loading the different faces.
  67827. */
  67828. supportCascades: boolean;
  67829. /**
  67830. * This returns if the loader support the current file information.
  67831. * @param extension defines the file extension of the file being loaded
  67832. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67833. * @param fallback defines the fallback internal texture if any
  67834. * @param isBase64 defines whether the texture is encoded as a base64
  67835. * @param isBuffer defines whether the texture data are stored as a buffer
  67836. * @returns true if the loader can load the specified file
  67837. */
  67838. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  67839. /**
  67840. * Transform the url before loading if required.
  67841. * @param rootUrl the url of the texture
  67842. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67843. * @returns the transformed texture
  67844. */
  67845. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  67846. /**
  67847. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  67848. * @param rootUrl the url of the texture
  67849. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67850. * @returns the fallback texture
  67851. */
  67852. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  67853. /**
  67854. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  67855. * @param data contains the texture data
  67856. * @param texture defines the BabylonJS internal texture
  67857. * @param createPolynomials will be true if polynomials have been requested
  67858. * @param onLoad defines the callback to trigger once the texture is ready
  67859. * @param onError defines the callback to trigger in case of error
  67860. */
  67861. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  67862. /**
  67863. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  67864. * @param data contains the texture data
  67865. * @param texture defines the BabylonJS internal texture
  67866. * @param callback defines the method to call once ready to upload
  67867. */
  67868. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  67869. }
  67870. }
  67871. declare module BABYLON {
  67872. /**
  67873. * Class used to store and describe the pipeline context associated with an effect
  67874. */
  67875. export interface IPipelineContext {
  67876. /**
  67877. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67878. */
  67879. isAsync: boolean;
  67880. /**
  67881. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67882. */
  67883. isReady: boolean;
  67884. /** @hidden */
  67885. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67886. }
  67887. }
  67888. declare module BABYLON {
  67889. /**
  67890. * Class used to store gfx data (like WebGLBuffer)
  67891. */
  67892. export class DataBuffer {
  67893. /**
  67894. * Gets or sets the number of objects referencing this buffer
  67895. */
  67896. references: number;
  67897. /** Gets or sets the size of the underlying buffer */
  67898. capacity: number;
  67899. /**
  67900. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67901. */
  67902. is32Bits: boolean;
  67903. /**
  67904. * Gets the underlying buffer
  67905. */
  67906. readonly underlyingResource: any;
  67907. }
  67908. }
  67909. declare module BABYLON {
  67910. /** @hidden */
  67911. export interface IShaderProcessor {
  67912. attributeProcessor?: (attribute: string) => string;
  67913. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  67914. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  67915. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  67916. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  67917. lineProcessor?: (line: string, isFragment: boolean) => string;
  67918. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67919. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67920. }
  67921. }
  67922. declare module BABYLON {
  67923. /** @hidden */
  67924. export interface ProcessingOptions {
  67925. defines: string[];
  67926. indexParameters: any;
  67927. isFragment: boolean;
  67928. shouldUseHighPrecisionShader: boolean;
  67929. supportsUniformBuffers: boolean;
  67930. shadersRepository: string;
  67931. includesShadersStore: {
  67932. [key: string]: string;
  67933. };
  67934. processor?: IShaderProcessor;
  67935. version: string;
  67936. platformName: string;
  67937. lookForClosingBracketForUniformBuffer?: boolean;
  67938. }
  67939. }
  67940. declare module BABYLON {
  67941. /**
  67942. * Helper to manipulate strings
  67943. */
  67944. export class StringTools {
  67945. /**
  67946. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  67947. * @param str Source string
  67948. * @param suffix Suffix to search for in the source string
  67949. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  67950. */
  67951. static EndsWith(str: string, suffix: string): boolean;
  67952. /**
  67953. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  67954. * @param str Source string
  67955. * @param suffix Suffix to search for in the source string
  67956. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  67957. */
  67958. static StartsWith(str: string, suffix: string): boolean;
  67959. }
  67960. }
  67961. declare module BABYLON {
  67962. /** @hidden */
  67963. export class ShaderCodeNode {
  67964. line: string;
  67965. children: ShaderCodeNode[];
  67966. additionalDefineKey?: string;
  67967. additionalDefineValue?: string;
  67968. isValid(preprocessors: {
  67969. [key: string]: string;
  67970. }): boolean;
  67971. process(preprocessors: {
  67972. [key: string]: string;
  67973. }, options: ProcessingOptions): string;
  67974. }
  67975. }
  67976. declare module BABYLON {
  67977. /** @hidden */
  67978. export class ShaderCodeCursor {
  67979. private _lines;
  67980. lineIndex: number;
  67981. readonly currentLine: string;
  67982. readonly canRead: boolean;
  67983. lines: string[];
  67984. }
  67985. }
  67986. declare module BABYLON {
  67987. /** @hidden */
  67988. export class ShaderCodeConditionNode extends ShaderCodeNode {
  67989. process(preprocessors: {
  67990. [key: string]: string;
  67991. }, options: ProcessingOptions): string;
  67992. }
  67993. }
  67994. declare module BABYLON {
  67995. /** @hidden */
  67996. export class ShaderDefineExpression {
  67997. isTrue(preprocessors: {
  67998. [key: string]: string;
  67999. }): boolean;
  68000. }
  68001. }
  68002. declare module BABYLON {
  68003. /** @hidden */
  68004. export class ShaderCodeTestNode extends ShaderCodeNode {
  68005. testExpression: ShaderDefineExpression;
  68006. isValid(preprocessors: {
  68007. [key: string]: string;
  68008. }): boolean;
  68009. }
  68010. }
  68011. declare module BABYLON {
  68012. /** @hidden */
  68013. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68014. define: string;
  68015. not: boolean;
  68016. constructor(define: string, not?: boolean);
  68017. isTrue(preprocessors: {
  68018. [key: string]: string;
  68019. }): boolean;
  68020. }
  68021. }
  68022. declare module BABYLON {
  68023. /** @hidden */
  68024. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68025. leftOperand: ShaderDefineExpression;
  68026. rightOperand: ShaderDefineExpression;
  68027. isTrue(preprocessors: {
  68028. [key: string]: string;
  68029. }): boolean;
  68030. }
  68031. }
  68032. declare module BABYLON {
  68033. /** @hidden */
  68034. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68035. leftOperand: ShaderDefineExpression;
  68036. rightOperand: ShaderDefineExpression;
  68037. isTrue(preprocessors: {
  68038. [key: string]: string;
  68039. }): boolean;
  68040. }
  68041. }
  68042. declare module BABYLON {
  68043. /** @hidden */
  68044. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68045. define: string;
  68046. operand: string;
  68047. testValue: string;
  68048. constructor(define: string, operand: string, testValue: string);
  68049. isTrue(preprocessors: {
  68050. [key: string]: string;
  68051. }): boolean;
  68052. }
  68053. }
  68054. declare module BABYLON {
  68055. /**
  68056. * @ignore
  68057. * Application error to support additional information when loading a file
  68058. */
  68059. export class LoadFileError extends Error {
  68060. /** defines the optional web request */
  68061. request?: WebRequest | undefined;
  68062. private static _setPrototypeOf;
  68063. /**
  68064. * Creates a new LoadFileError
  68065. * @param message defines the message of the error
  68066. * @param request defines the optional web request
  68067. */
  68068. constructor(message: string,
  68069. /** defines the optional web request */
  68070. request?: WebRequest | undefined);
  68071. }
  68072. }
  68073. declare module BABYLON {
  68074. /**
  68075. * Class used to enable access to offline support
  68076. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68077. */
  68078. export interface IOfflineProvider {
  68079. /**
  68080. * Gets a boolean indicating if scene must be saved in the database
  68081. */
  68082. enableSceneOffline: boolean;
  68083. /**
  68084. * Gets a boolean indicating if textures must be saved in the database
  68085. */
  68086. enableTexturesOffline: boolean;
  68087. /**
  68088. * Open the offline support and make it available
  68089. * @param successCallback defines the callback to call on success
  68090. * @param errorCallback defines the callback to call on error
  68091. */
  68092. open(successCallback: () => void, errorCallback: () => void): void;
  68093. /**
  68094. * Loads an image from the offline support
  68095. * @param url defines the url to load from
  68096. * @param image defines the target DOM image
  68097. */
  68098. loadImage(url: string, image: HTMLImageElement): void;
  68099. /**
  68100. * Loads a file from offline support
  68101. * @param url defines the URL to load from
  68102. * @param sceneLoaded defines a callback to call on success
  68103. * @param progressCallBack defines a callback to call when progress changed
  68104. * @param errorCallback defines a callback to call on error
  68105. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68106. */
  68107. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68108. }
  68109. }
  68110. declare module BABYLON {
  68111. /**
  68112. * Class used to help managing file picking and drag'n'drop
  68113. * File Storage
  68114. */
  68115. export class FilesInputStore {
  68116. /**
  68117. * List of files ready to be loaded
  68118. */
  68119. static FilesToLoad: {
  68120. [key: string]: File;
  68121. };
  68122. }
  68123. }
  68124. declare module BABYLON {
  68125. /**
  68126. * Class used to define a retry strategy when error happens while loading assets
  68127. */
  68128. export class RetryStrategy {
  68129. /**
  68130. * Function used to defines an exponential back off strategy
  68131. * @param maxRetries defines the maximum number of retries (3 by default)
  68132. * @param baseInterval defines the interval between retries
  68133. * @returns the strategy function to use
  68134. */
  68135. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68136. }
  68137. }
  68138. declare module BABYLON {
  68139. /**
  68140. * @hidden
  68141. */
  68142. export class FileTools {
  68143. /**
  68144. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68145. */
  68146. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68147. /**
  68148. * Gets or sets the base URL to use to load assets
  68149. */
  68150. static BaseUrl: string;
  68151. /**
  68152. * Default behaviour for cors in the application.
  68153. * It can be a string if the expected behavior is identical in the entire app.
  68154. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68155. */
  68156. static CorsBehavior: string | ((url: string | string[]) => string);
  68157. /**
  68158. * Gets or sets a function used to pre-process url before using them to load assets
  68159. */
  68160. static PreprocessUrl: (url: string) => string;
  68161. /**
  68162. * Removes unwanted characters from an url
  68163. * @param url defines the url to clean
  68164. * @returns the cleaned url
  68165. */
  68166. private static _CleanUrl;
  68167. /**
  68168. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68169. * @param url define the url we are trying
  68170. * @param element define the dom element where to configure the cors policy
  68171. */
  68172. static SetCorsBehavior(url: string | string[], element: {
  68173. crossOrigin: string | null;
  68174. }): void;
  68175. /**
  68176. * Loads an image as an HTMLImageElement.
  68177. * @param input url string, ArrayBuffer, or Blob to load
  68178. * @param onLoad callback called when the image successfully loads
  68179. * @param onError callback called when the image fails to load
  68180. * @param offlineProvider offline provider for caching
  68181. * @returns the HTMLImageElement of the loaded image
  68182. */
  68183. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  68184. /**
  68185. * Loads a file
  68186. * @param fileToLoad defines the file to load
  68187. * @param callback defines the callback to call when data is loaded
  68188. * @param progressCallBack defines the callback to call during loading process
  68189. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68190. * @returns a file request object
  68191. */
  68192. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  68193. /**
  68194. * Loads a file
  68195. * @param url url string, ArrayBuffer, or Blob to load
  68196. * @param onSuccess callback called when the file successfully loads
  68197. * @param onProgress callback called while file is loading (if the server supports this mode)
  68198. * @param offlineProvider defines the offline provider for caching
  68199. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68200. * @param onError callback called when the file fails to load
  68201. * @returns a file request object
  68202. */
  68203. 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;
  68204. /**
  68205. * Checks if the loaded document was accessed via `file:`-Protocol.
  68206. * @returns boolean
  68207. */
  68208. static IsFileURL(): boolean;
  68209. }
  68210. }
  68211. declare module BABYLON {
  68212. /** @hidden */
  68213. export class ShaderProcessor {
  68214. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68215. private static _ProcessPrecision;
  68216. private static _ExtractOperation;
  68217. private static _BuildSubExpression;
  68218. private static _BuildExpression;
  68219. private static _MoveCursorWithinIf;
  68220. private static _MoveCursor;
  68221. private static _EvaluatePreProcessors;
  68222. private static _PreparePreProcessors;
  68223. private static _ProcessShaderConversion;
  68224. private static _ProcessIncludes;
  68225. }
  68226. }
  68227. declare module BABYLON {
  68228. /**
  68229. * @hidden
  68230. */
  68231. export interface IColor4Like {
  68232. r: float;
  68233. g: float;
  68234. b: float;
  68235. a: float;
  68236. }
  68237. /**
  68238. * @hidden
  68239. */
  68240. export interface IColor3Like {
  68241. r: float;
  68242. g: float;
  68243. b: float;
  68244. }
  68245. /**
  68246. * @hidden
  68247. */
  68248. export interface IVector4Like {
  68249. x: float;
  68250. y: float;
  68251. z: float;
  68252. w: float;
  68253. }
  68254. /**
  68255. * @hidden
  68256. */
  68257. export interface IVector3Like {
  68258. x: float;
  68259. y: float;
  68260. z: float;
  68261. }
  68262. /**
  68263. * @hidden
  68264. */
  68265. export interface IVector2Like {
  68266. x: float;
  68267. y: float;
  68268. }
  68269. /**
  68270. * @hidden
  68271. */
  68272. export interface IMatrixLike {
  68273. toArray(): DeepImmutable<Float32Array>;
  68274. updateFlag: int;
  68275. }
  68276. /**
  68277. * @hidden
  68278. */
  68279. export interface IViewportLike {
  68280. x: float;
  68281. y: float;
  68282. width: float;
  68283. height: float;
  68284. }
  68285. /**
  68286. * @hidden
  68287. */
  68288. export interface IPlaneLike {
  68289. normal: IVector3Like;
  68290. d: float;
  68291. normalize(): void;
  68292. }
  68293. }
  68294. declare module BABYLON {
  68295. /**
  68296. * Interface used to define common properties for effect fallbacks
  68297. */
  68298. export interface IEffectFallbacks {
  68299. /**
  68300. * Removes the defines that should be removed when falling back.
  68301. * @param currentDefines defines the current define statements for the shader.
  68302. * @param effect defines the current effect we try to compile
  68303. * @returns The resulting defines with defines of the current rank removed.
  68304. */
  68305. reduce(currentDefines: string, effect: Effect): string;
  68306. /**
  68307. * Removes the fallback from the bound mesh.
  68308. */
  68309. unBindMesh(): void;
  68310. /**
  68311. * Checks to see if more fallbacks are still availible.
  68312. */
  68313. hasMoreFallbacks: boolean;
  68314. }
  68315. }
  68316. declare module BABYLON {
  68317. /**
  68318. * Class used to evalaute queries containing `and` and `or` operators
  68319. */
  68320. export class AndOrNotEvaluator {
  68321. /**
  68322. * Evaluate a query
  68323. * @param query defines the query to evaluate
  68324. * @param evaluateCallback defines the callback used to filter result
  68325. * @returns true if the query matches
  68326. */
  68327. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  68328. private static _HandleParenthesisContent;
  68329. private static _SimplifyNegation;
  68330. }
  68331. }
  68332. declare module BABYLON {
  68333. /**
  68334. * Class used to store custom tags
  68335. */
  68336. export class Tags {
  68337. /**
  68338. * Adds support for tags on the given object
  68339. * @param obj defines the object to use
  68340. */
  68341. static EnableFor(obj: any): void;
  68342. /**
  68343. * Removes tags support
  68344. * @param obj defines the object to use
  68345. */
  68346. static DisableFor(obj: any): void;
  68347. /**
  68348. * Gets a boolean indicating if the given object has tags
  68349. * @param obj defines the object to use
  68350. * @returns a boolean
  68351. */
  68352. static HasTags(obj: any): boolean;
  68353. /**
  68354. * Gets the tags available on a given object
  68355. * @param obj defines the object to use
  68356. * @param asString defines if the tags must be returned as a string instead of an array of strings
  68357. * @returns the tags
  68358. */
  68359. static GetTags(obj: any, asString?: boolean): any;
  68360. /**
  68361. * Adds tags to an object
  68362. * @param obj defines the object to use
  68363. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  68364. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  68365. */
  68366. static AddTagsTo(obj: any, tagsString: string): void;
  68367. /**
  68368. * @hidden
  68369. */
  68370. static _AddTagTo(obj: any, tag: string): void;
  68371. /**
  68372. * Removes specific tags from a specific object
  68373. * @param obj defines the object to use
  68374. * @param tagsString defines the tags to remove
  68375. */
  68376. static RemoveTagsFrom(obj: any, tagsString: string): void;
  68377. /**
  68378. * @hidden
  68379. */
  68380. static _RemoveTagFrom(obj: any, tag: string): void;
  68381. /**
  68382. * Defines if tags hosted on an object match a given query
  68383. * @param obj defines the object to use
  68384. * @param tagsQuery defines the tag query
  68385. * @returns a boolean
  68386. */
  68387. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  68388. }
  68389. }
  68390. declare module BABYLON {
  68391. /**
  68392. * Scalar computation library
  68393. */
  68394. export class Scalar {
  68395. /**
  68396. * Two pi constants convenient for computation.
  68397. */
  68398. static TwoPi: number;
  68399. /**
  68400. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68401. * @param a number
  68402. * @param b number
  68403. * @param epsilon (default = 1.401298E-45)
  68404. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68405. */
  68406. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  68407. /**
  68408. * Returns a string : the upper case translation of the number i to hexadecimal.
  68409. * @param i number
  68410. * @returns the upper case translation of the number i to hexadecimal.
  68411. */
  68412. static ToHex(i: number): string;
  68413. /**
  68414. * Returns -1 if value is negative and +1 is value is positive.
  68415. * @param value the value
  68416. * @returns the value itself if it's equal to zero.
  68417. */
  68418. static Sign(value: number): number;
  68419. /**
  68420. * Returns the value itself if it's between min and max.
  68421. * Returns min if the value is lower than min.
  68422. * Returns max if the value is greater than max.
  68423. * @param value the value to clmap
  68424. * @param min the min value to clamp to (default: 0)
  68425. * @param max the max value to clamp to (default: 1)
  68426. * @returns the clamped value
  68427. */
  68428. static Clamp(value: number, min?: number, max?: number): number;
  68429. /**
  68430. * the log2 of value.
  68431. * @param value the value to compute log2 of
  68432. * @returns the log2 of value.
  68433. */
  68434. static Log2(value: number): number;
  68435. /**
  68436. * Loops the value, so that it is never larger than length and never smaller than 0.
  68437. *
  68438. * This is similar to the modulo operator but it works with floating point numbers.
  68439. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  68440. * With t = 5 and length = 2.5, the result would be 0.0.
  68441. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  68442. * @param value the value
  68443. * @param length the length
  68444. * @returns the looped value
  68445. */
  68446. static Repeat(value: number, length: number): number;
  68447. /**
  68448. * Normalize the value between 0.0 and 1.0 using min and max values
  68449. * @param value value to normalize
  68450. * @param min max to normalize between
  68451. * @param max min to normalize between
  68452. * @returns the normalized value
  68453. */
  68454. static Normalize(value: number, min: number, max: number): number;
  68455. /**
  68456. * Denormalize the value from 0.0 and 1.0 using min and max values
  68457. * @param normalized value to denormalize
  68458. * @param min max to denormalize between
  68459. * @param max min to denormalize between
  68460. * @returns the denormalized value
  68461. */
  68462. static Denormalize(normalized: number, min: number, max: number): number;
  68463. /**
  68464. * Calculates the shortest difference between two given angles given in degrees.
  68465. * @param current current angle in degrees
  68466. * @param target target angle in degrees
  68467. * @returns the delta
  68468. */
  68469. static DeltaAngle(current: number, target: number): number;
  68470. /**
  68471. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  68472. * @param tx value
  68473. * @param length length
  68474. * @returns The returned value will move back and forth between 0 and length
  68475. */
  68476. static PingPong(tx: number, length: number): number;
  68477. /**
  68478. * Interpolates between min and max with smoothing at the limits.
  68479. *
  68480. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  68481. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  68482. * @param from from
  68483. * @param to to
  68484. * @param tx value
  68485. * @returns the smooth stepped value
  68486. */
  68487. static SmoothStep(from: number, to: number, tx: number): number;
  68488. /**
  68489. * Moves a value current towards target.
  68490. *
  68491. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  68492. * Negative values of maxDelta pushes the value away from target.
  68493. * @param current current value
  68494. * @param target target value
  68495. * @param maxDelta max distance to move
  68496. * @returns resulting value
  68497. */
  68498. static MoveTowards(current: number, target: number, maxDelta: number): number;
  68499. /**
  68500. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68501. *
  68502. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  68503. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  68504. * @param current current value
  68505. * @param target target value
  68506. * @param maxDelta max distance to move
  68507. * @returns resulting angle
  68508. */
  68509. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  68510. /**
  68511. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  68512. * @param start start value
  68513. * @param end target value
  68514. * @param amount amount to lerp between
  68515. * @returns the lerped value
  68516. */
  68517. static Lerp(start: number, end: number, amount: number): number;
  68518. /**
  68519. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68520. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  68521. * @param start start value
  68522. * @param end target value
  68523. * @param amount amount to lerp between
  68524. * @returns the lerped value
  68525. */
  68526. static LerpAngle(start: number, end: number, amount: number): number;
  68527. /**
  68528. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  68529. * @param a start value
  68530. * @param b target value
  68531. * @param value value between a and b
  68532. * @returns the inverseLerp value
  68533. */
  68534. static InverseLerp(a: number, b: number, value: number): number;
  68535. /**
  68536. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  68537. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  68538. * @param value1 spline value
  68539. * @param tangent1 spline value
  68540. * @param value2 spline value
  68541. * @param tangent2 spline value
  68542. * @param amount input value
  68543. * @returns hermite result
  68544. */
  68545. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  68546. /**
  68547. * Returns a random float number between and min and max values
  68548. * @param min min value of random
  68549. * @param max max value of random
  68550. * @returns random value
  68551. */
  68552. static RandomRange(min: number, max: number): number;
  68553. /**
  68554. * This function returns percentage of a number in a given range.
  68555. *
  68556. * RangeToPercent(40,20,60) will return 0.5 (50%)
  68557. * RangeToPercent(34,0,100) will return 0.34 (34%)
  68558. * @param number to convert to percentage
  68559. * @param min min range
  68560. * @param max max range
  68561. * @returns the percentage
  68562. */
  68563. static RangeToPercent(number: number, min: number, max: number): number;
  68564. /**
  68565. * This function returns number that corresponds to the percentage in a given range.
  68566. *
  68567. * PercentToRange(0.34,0,100) will return 34.
  68568. * @param percent to convert to number
  68569. * @param min min range
  68570. * @param max max range
  68571. * @returns the number
  68572. */
  68573. static PercentToRange(percent: number, min: number, max: number): number;
  68574. /**
  68575. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  68576. * @param angle The angle to normalize in radian.
  68577. * @return The converted angle.
  68578. */
  68579. static NormalizeRadians(angle: number): number;
  68580. }
  68581. }
  68582. declare module BABYLON {
  68583. /**
  68584. * Constant used to convert a value to gamma space
  68585. * @ignorenaming
  68586. */
  68587. export const ToGammaSpace: number;
  68588. /**
  68589. * Constant used to convert a value to linear space
  68590. * @ignorenaming
  68591. */
  68592. export const ToLinearSpace = 2.2;
  68593. /**
  68594. * Constant used to define the minimal number value in Babylon.js
  68595. * @ignorenaming
  68596. */
  68597. let Epsilon: number;
  68598. }
  68599. declare module BABYLON {
  68600. /**
  68601. * Class used to represent a viewport on screen
  68602. */
  68603. export class Viewport {
  68604. /** viewport left coordinate */
  68605. x: number;
  68606. /** viewport top coordinate */
  68607. y: number;
  68608. /**viewport width */
  68609. width: number;
  68610. /** viewport height */
  68611. height: number;
  68612. /**
  68613. * Creates a Viewport object located at (x, y) and sized (width, height)
  68614. * @param x defines viewport left coordinate
  68615. * @param y defines viewport top coordinate
  68616. * @param width defines the viewport width
  68617. * @param height defines the viewport height
  68618. */
  68619. constructor(
  68620. /** viewport left coordinate */
  68621. x: number,
  68622. /** viewport top coordinate */
  68623. y: number,
  68624. /**viewport width */
  68625. width: number,
  68626. /** viewport height */
  68627. height: number);
  68628. /**
  68629. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  68630. * @param renderWidth defines the rendering width
  68631. * @param renderHeight defines the rendering height
  68632. * @returns a new Viewport
  68633. */
  68634. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  68635. /**
  68636. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  68637. * @param renderWidth defines the rendering width
  68638. * @param renderHeight defines the rendering height
  68639. * @param ref defines the target viewport
  68640. * @returns the current viewport
  68641. */
  68642. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  68643. /**
  68644. * Returns a new Viewport copied from the current one
  68645. * @returns a new Viewport
  68646. */
  68647. clone(): Viewport;
  68648. }
  68649. }
  68650. declare module BABYLON {
  68651. /**
  68652. * Class containing a set of static utilities functions for arrays.
  68653. */
  68654. export class ArrayTools {
  68655. /**
  68656. * Returns an array of the given size filled with element built from the given constructor and the paramters
  68657. * @param size the number of element to construct and put in the array
  68658. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  68659. * @returns a new array filled with new objects
  68660. */
  68661. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  68662. }
  68663. }
  68664. declare module BABYLON {
  68665. /**
  68666. * Class representing a vector containing 2 coordinates
  68667. */
  68668. export class Vector2 {
  68669. /** defines the first coordinate */
  68670. x: number;
  68671. /** defines the second coordinate */
  68672. y: number;
  68673. /**
  68674. * Creates a new Vector2 from the given x and y coordinates
  68675. * @param x defines the first coordinate
  68676. * @param y defines the second coordinate
  68677. */
  68678. constructor(
  68679. /** defines the first coordinate */
  68680. x?: number,
  68681. /** defines the second coordinate */
  68682. y?: number);
  68683. /**
  68684. * Gets a string with the Vector2 coordinates
  68685. * @returns a string with the Vector2 coordinates
  68686. */
  68687. toString(): string;
  68688. /**
  68689. * Gets class name
  68690. * @returns the string "Vector2"
  68691. */
  68692. getClassName(): string;
  68693. /**
  68694. * Gets current vector hash code
  68695. * @returns the Vector2 hash code as a number
  68696. */
  68697. getHashCode(): number;
  68698. /**
  68699. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  68700. * @param array defines the source array
  68701. * @param index defines the offset in source array
  68702. * @returns the current Vector2
  68703. */
  68704. toArray(array: FloatArray, index?: number): Vector2;
  68705. /**
  68706. * Copy the current vector to an array
  68707. * @returns a new array with 2 elements: the Vector2 coordinates.
  68708. */
  68709. asArray(): number[];
  68710. /**
  68711. * Sets the Vector2 coordinates with the given Vector2 coordinates
  68712. * @param source defines the source Vector2
  68713. * @returns the current updated Vector2
  68714. */
  68715. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  68716. /**
  68717. * Sets the Vector2 coordinates with the given floats
  68718. * @param x defines the first coordinate
  68719. * @param y defines the second coordinate
  68720. * @returns the current updated Vector2
  68721. */
  68722. copyFromFloats(x: number, y: number): Vector2;
  68723. /**
  68724. * Sets the Vector2 coordinates with the given floats
  68725. * @param x defines the first coordinate
  68726. * @param y defines the second coordinate
  68727. * @returns the current updated Vector2
  68728. */
  68729. set(x: number, y: number): Vector2;
  68730. /**
  68731. * Add another vector with the current one
  68732. * @param otherVector defines the other vector
  68733. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  68734. */
  68735. add(otherVector: DeepImmutable<Vector2>): Vector2;
  68736. /**
  68737. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  68738. * @param otherVector defines the other vector
  68739. * @param result defines the target vector
  68740. * @returns the unmodified current Vector2
  68741. */
  68742. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68743. /**
  68744. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  68745. * @param otherVector defines the other vector
  68746. * @returns the current updated Vector2
  68747. */
  68748. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68749. /**
  68750. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  68751. * @param otherVector defines the other vector
  68752. * @returns a new Vector2
  68753. */
  68754. addVector3(otherVector: Vector3): Vector2;
  68755. /**
  68756. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  68757. * @param otherVector defines the other vector
  68758. * @returns a new Vector2
  68759. */
  68760. subtract(otherVector: Vector2): Vector2;
  68761. /**
  68762. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  68763. * @param otherVector defines the other vector
  68764. * @param result defines the target vector
  68765. * @returns the unmodified current Vector2
  68766. */
  68767. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68768. /**
  68769. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  68770. * @param otherVector defines the other vector
  68771. * @returns the current updated Vector2
  68772. */
  68773. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68774. /**
  68775. * Multiplies in place the current Vector2 coordinates by the given ones
  68776. * @param otherVector defines the other vector
  68777. * @returns the current updated Vector2
  68778. */
  68779. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68780. /**
  68781. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  68782. * @param otherVector defines the other vector
  68783. * @returns a new Vector2
  68784. */
  68785. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  68786. /**
  68787. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  68788. * @param otherVector defines the other vector
  68789. * @param result defines the target vector
  68790. * @returns the unmodified current Vector2
  68791. */
  68792. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68793. /**
  68794. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  68795. * @param x defines the first coordinate
  68796. * @param y defines the second coordinate
  68797. * @returns a new Vector2
  68798. */
  68799. multiplyByFloats(x: number, y: number): Vector2;
  68800. /**
  68801. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  68802. * @param otherVector defines the other vector
  68803. * @returns a new Vector2
  68804. */
  68805. divide(otherVector: Vector2): Vector2;
  68806. /**
  68807. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  68808. * @param otherVector defines the other vector
  68809. * @param result defines the target vector
  68810. * @returns the unmodified current Vector2
  68811. */
  68812. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68813. /**
  68814. * Divides the current Vector2 coordinates by the given ones
  68815. * @param otherVector defines the other vector
  68816. * @returns the current updated Vector2
  68817. */
  68818. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68819. /**
  68820. * Gets a new Vector2 with current Vector2 negated coordinates
  68821. * @returns a new Vector2
  68822. */
  68823. negate(): Vector2;
  68824. /**
  68825. * Multiply the Vector2 coordinates by scale
  68826. * @param scale defines the scaling factor
  68827. * @returns the current updated Vector2
  68828. */
  68829. scaleInPlace(scale: number): Vector2;
  68830. /**
  68831. * Returns a new Vector2 scaled by "scale" from the current Vector2
  68832. * @param scale defines the scaling factor
  68833. * @returns a new Vector2
  68834. */
  68835. scale(scale: number): Vector2;
  68836. /**
  68837. * Scale the current Vector2 values by a factor to a given Vector2
  68838. * @param scale defines the scale factor
  68839. * @param result defines the Vector2 object where to store the result
  68840. * @returns the unmodified current Vector2
  68841. */
  68842. scaleToRef(scale: number, result: Vector2): Vector2;
  68843. /**
  68844. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  68845. * @param scale defines the scale factor
  68846. * @param result defines the Vector2 object where to store the result
  68847. * @returns the unmodified current Vector2
  68848. */
  68849. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  68850. /**
  68851. * Gets a boolean if two vectors are equals
  68852. * @param otherVector defines the other vector
  68853. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  68854. */
  68855. equals(otherVector: DeepImmutable<Vector2>): boolean;
  68856. /**
  68857. * Gets a boolean if two vectors are equals (using an epsilon value)
  68858. * @param otherVector defines the other vector
  68859. * @param epsilon defines the minimal distance to consider equality
  68860. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  68861. */
  68862. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  68863. /**
  68864. * Gets a new Vector2 from current Vector2 floored values
  68865. * @returns a new Vector2
  68866. */
  68867. floor(): Vector2;
  68868. /**
  68869. * Gets a new Vector2 from current Vector2 floored values
  68870. * @returns a new Vector2
  68871. */
  68872. fract(): Vector2;
  68873. /**
  68874. * Gets the length of the vector
  68875. * @returns the vector length (float)
  68876. */
  68877. length(): number;
  68878. /**
  68879. * Gets the vector squared length
  68880. * @returns the vector squared length (float)
  68881. */
  68882. lengthSquared(): number;
  68883. /**
  68884. * Normalize the vector
  68885. * @returns the current updated Vector2
  68886. */
  68887. normalize(): Vector2;
  68888. /**
  68889. * Gets a new Vector2 copied from the Vector2
  68890. * @returns a new Vector2
  68891. */
  68892. clone(): Vector2;
  68893. /**
  68894. * Gets a new Vector2(0, 0)
  68895. * @returns a new Vector2
  68896. */
  68897. static Zero(): Vector2;
  68898. /**
  68899. * Gets a new Vector2(1, 1)
  68900. * @returns a new Vector2
  68901. */
  68902. static One(): Vector2;
  68903. /**
  68904. * Gets a new Vector2 set from the given index element of the given array
  68905. * @param array defines the data source
  68906. * @param offset defines the offset in the data source
  68907. * @returns a new Vector2
  68908. */
  68909. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  68910. /**
  68911. * Sets "result" from the given index element of the given array
  68912. * @param array defines the data source
  68913. * @param offset defines the offset in the data source
  68914. * @param result defines the target vector
  68915. */
  68916. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  68917. /**
  68918. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  68919. * @param value1 defines 1st point of control
  68920. * @param value2 defines 2nd point of control
  68921. * @param value3 defines 3rd point of control
  68922. * @param value4 defines 4th point of control
  68923. * @param amount defines the interpolation factor
  68924. * @returns a new Vector2
  68925. */
  68926. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  68927. /**
  68928. * 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".
  68929. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  68930. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  68931. * @param value defines the value to clamp
  68932. * @param min defines the lower limit
  68933. * @param max defines the upper limit
  68934. * @returns a new Vector2
  68935. */
  68936. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  68937. /**
  68938. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  68939. * @param value1 defines the 1st control point
  68940. * @param tangent1 defines the outgoing tangent
  68941. * @param value2 defines the 2nd control point
  68942. * @param tangent2 defines the incoming tangent
  68943. * @param amount defines the interpolation factor
  68944. * @returns a new Vector2
  68945. */
  68946. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  68947. /**
  68948. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  68949. * @param start defines the start vector
  68950. * @param end defines the end vector
  68951. * @param amount defines the interpolation factor
  68952. * @returns a new Vector2
  68953. */
  68954. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  68955. /**
  68956. * Gets the dot product of the vector "left" and the vector "right"
  68957. * @param left defines first vector
  68958. * @param right defines second vector
  68959. * @returns the dot product (float)
  68960. */
  68961. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  68962. /**
  68963. * Returns a new Vector2 equal to the normalized given vector
  68964. * @param vector defines the vector to normalize
  68965. * @returns a new Vector2
  68966. */
  68967. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  68968. /**
  68969. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  68970. * @param left defines 1st vector
  68971. * @param right defines 2nd vector
  68972. * @returns a new Vector2
  68973. */
  68974. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  68975. /**
  68976. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  68977. * @param left defines 1st vector
  68978. * @param right defines 2nd vector
  68979. * @returns a new Vector2
  68980. */
  68981. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  68982. /**
  68983. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  68984. * @param vector defines the vector to transform
  68985. * @param transformation defines the matrix to apply
  68986. * @returns a new Vector2
  68987. */
  68988. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  68989. /**
  68990. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  68991. * @param vector defines the vector to transform
  68992. * @param transformation defines the matrix to apply
  68993. * @param result defines the target vector
  68994. */
  68995. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  68996. /**
  68997. * Determines if a given vector is included in a triangle
  68998. * @param p defines the vector to test
  68999. * @param p0 defines 1st triangle point
  69000. * @param p1 defines 2nd triangle point
  69001. * @param p2 defines 3rd triangle point
  69002. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  69003. */
  69004. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  69005. /**
  69006. * Gets the distance between the vectors "value1" and "value2"
  69007. * @param value1 defines first vector
  69008. * @param value2 defines second vector
  69009. * @returns the distance between vectors
  69010. */
  69011. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69012. /**
  69013. * Returns the squared distance between the vectors "value1" and "value2"
  69014. * @param value1 defines first vector
  69015. * @param value2 defines second vector
  69016. * @returns the squared distance between vectors
  69017. */
  69018. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69019. /**
  69020. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69021. * @param value1 defines first vector
  69022. * @param value2 defines second vector
  69023. * @returns a new Vector2
  69024. */
  69025. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  69026. /**
  69027. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69028. * @param p defines the middle point
  69029. * @param segA defines one point of the segment
  69030. * @param segB defines the other point of the segment
  69031. * @returns the shortest distance
  69032. */
  69033. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  69034. }
  69035. /**
  69036. * Classed used to store (x,y,z) vector representation
  69037. * A Vector3 is the main object used in 3D geometry
  69038. * It can represent etiher the coordinates of a point the space, either a direction
  69039. * Reminder: js uses a left handed forward facing system
  69040. */
  69041. export class Vector3 {
  69042. /**
  69043. * Defines the first coordinates (on X axis)
  69044. */
  69045. x: number;
  69046. /**
  69047. * Defines the second coordinates (on Y axis)
  69048. */
  69049. y: number;
  69050. /**
  69051. * Defines the third coordinates (on Z axis)
  69052. */
  69053. z: number;
  69054. private static _UpReadOnly;
  69055. private static _ZeroReadOnly;
  69056. /**
  69057. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69058. * @param x defines the first coordinates (on X axis)
  69059. * @param y defines the second coordinates (on Y axis)
  69060. * @param z defines the third coordinates (on Z axis)
  69061. */
  69062. constructor(
  69063. /**
  69064. * Defines the first coordinates (on X axis)
  69065. */
  69066. x?: number,
  69067. /**
  69068. * Defines the second coordinates (on Y axis)
  69069. */
  69070. y?: number,
  69071. /**
  69072. * Defines the third coordinates (on Z axis)
  69073. */
  69074. z?: number);
  69075. /**
  69076. * Creates a string representation of the Vector3
  69077. * @returns a string with the Vector3 coordinates.
  69078. */
  69079. toString(): string;
  69080. /**
  69081. * Gets the class name
  69082. * @returns the string "Vector3"
  69083. */
  69084. getClassName(): string;
  69085. /**
  69086. * Creates the Vector3 hash code
  69087. * @returns a number which tends to be unique between Vector3 instances
  69088. */
  69089. getHashCode(): number;
  69090. /**
  69091. * Creates an array containing three elements : the coordinates of the Vector3
  69092. * @returns a new array of numbers
  69093. */
  69094. asArray(): number[];
  69095. /**
  69096. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69097. * @param array defines the destination array
  69098. * @param index defines the offset in the destination array
  69099. * @returns the current Vector3
  69100. */
  69101. toArray(array: FloatArray, index?: number): Vector3;
  69102. /**
  69103. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69104. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69105. */
  69106. toQuaternion(): Quaternion;
  69107. /**
  69108. * Adds the given vector to the current Vector3
  69109. * @param otherVector defines the second operand
  69110. * @returns the current updated Vector3
  69111. */
  69112. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69113. /**
  69114. * Adds the given coordinates to the current Vector3
  69115. * @param x defines the x coordinate of the operand
  69116. * @param y defines the y coordinate of the operand
  69117. * @param z defines the z coordinate of the operand
  69118. * @returns the current updated Vector3
  69119. */
  69120. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69121. /**
  69122. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69123. * @param otherVector defines the second operand
  69124. * @returns the resulting Vector3
  69125. */
  69126. add(otherVector: DeepImmutable<Vector3>): Vector3;
  69127. /**
  69128. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69129. * @param otherVector defines the second operand
  69130. * @param result defines the Vector3 object where to store the result
  69131. * @returns the current Vector3
  69132. */
  69133. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69134. /**
  69135. * Subtract the given vector from the current Vector3
  69136. * @param otherVector defines the second operand
  69137. * @returns the current updated Vector3
  69138. */
  69139. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69140. /**
  69141. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69142. * @param otherVector defines the second operand
  69143. * @returns the resulting Vector3
  69144. */
  69145. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  69146. /**
  69147. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69148. * @param otherVector defines the second operand
  69149. * @param result defines the Vector3 object where to store the result
  69150. * @returns the current Vector3
  69151. */
  69152. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69153. /**
  69154. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69155. * @param x defines the x coordinate of the operand
  69156. * @param y defines the y coordinate of the operand
  69157. * @param z defines the z coordinate of the operand
  69158. * @returns the resulting Vector3
  69159. */
  69160. subtractFromFloats(x: number, y: number, z: number): Vector3;
  69161. /**
  69162. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69163. * @param x defines the x coordinate of the operand
  69164. * @param y defines the y coordinate of the operand
  69165. * @param z defines the z coordinate of the operand
  69166. * @param result defines the Vector3 object where to store the result
  69167. * @returns the current Vector3
  69168. */
  69169. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  69170. /**
  69171. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69172. * @returns a new Vector3
  69173. */
  69174. negate(): Vector3;
  69175. /**
  69176. * Multiplies the Vector3 coordinates by the float "scale"
  69177. * @param scale defines the multiplier factor
  69178. * @returns the current updated Vector3
  69179. */
  69180. scaleInPlace(scale: number): Vector3;
  69181. /**
  69182. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69183. * @param scale defines the multiplier factor
  69184. * @returns a new Vector3
  69185. */
  69186. scale(scale: number): Vector3;
  69187. /**
  69188. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69189. * @param scale defines the multiplier factor
  69190. * @param result defines the Vector3 object where to store the result
  69191. * @returns the current Vector3
  69192. */
  69193. scaleToRef(scale: number, result: Vector3): Vector3;
  69194. /**
  69195. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69196. * @param scale defines the scale factor
  69197. * @param result defines the Vector3 object where to store the result
  69198. * @returns the unmodified current Vector3
  69199. */
  69200. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  69201. /**
  69202. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69203. * @param otherVector defines the second operand
  69204. * @returns true if both vectors are equals
  69205. */
  69206. equals(otherVector: DeepImmutable<Vector3>): boolean;
  69207. /**
  69208. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69209. * @param otherVector defines the second operand
  69210. * @param epsilon defines the minimal distance to define values as equals
  69211. * @returns true if both vectors are distant less than epsilon
  69212. */
  69213. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  69214. /**
  69215. * Returns true if the current Vector3 coordinates equals the given floats
  69216. * @param x defines the x coordinate of the operand
  69217. * @param y defines the y coordinate of the operand
  69218. * @param z defines the z coordinate of the operand
  69219. * @returns true if both vectors are equals
  69220. */
  69221. equalsToFloats(x: number, y: number, z: number): boolean;
  69222. /**
  69223. * Multiplies the current Vector3 coordinates by the given ones
  69224. * @param otherVector defines the second operand
  69225. * @returns the current updated Vector3
  69226. */
  69227. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69228. /**
  69229. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69230. * @param otherVector defines the second operand
  69231. * @returns the new Vector3
  69232. */
  69233. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  69234. /**
  69235. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69236. * @param otherVector defines the second operand
  69237. * @param result defines the Vector3 object where to store the result
  69238. * @returns the current Vector3
  69239. */
  69240. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69241. /**
  69242. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69243. * @param x defines the x coordinate of the operand
  69244. * @param y defines the y coordinate of the operand
  69245. * @param z defines the z coordinate of the operand
  69246. * @returns the new Vector3
  69247. */
  69248. multiplyByFloats(x: number, y: number, z: number): Vector3;
  69249. /**
  69250. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69251. * @param otherVector defines the second operand
  69252. * @returns the new Vector3
  69253. */
  69254. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  69255. /**
  69256. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69257. * @param otherVector defines the second operand
  69258. * @param result defines the Vector3 object where to store the result
  69259. * @returns the current Vector3
  69260. */
  69261. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69262. /**
  69263. * Divides the current Vector3 coordinates by the given ones.
  69264. * @param otherVector defines the second operand
  69265. * @returns the current updated Vector3
  69266. */
  69267. divideInPlace(otherVector: Vector3): Vector3;
  69268. /**
  69269. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  69270. * @param other defines the second operand
  69271. * @returns the current updated Vector3
  69272. */
  69273. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69274. /**
  69275. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  69276. * @param other defines the second operand
  69277. * @returns the current updated Vector3
  69278. */
  69279. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69280. /**
  69281. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  69282. * @param x defines the x coordinate of the operand
  69283. * @param y defines the y coordinate of the operand
  69284. * @param z defines the z coordinate of the operand
  69285. * @returns the current updated Vector3
  69286. */
  69287. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69288. /**
  69289. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  69290. * @param x defines the x coordinate of the operand
  69291. * @param y defines the y coordinate of the operand
  69292. * @param z defines the z coordinate of the operand
  69293. * @returns the current updated Vector3
  69294. */
  69295. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69296. /**
  69297. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  69298. * Check if is non uniform within a certain amount of decimal places to account for this
  69299. * @param epsilon the amount the values can differ
  69300. * @returns if the the vector is non uniform to a certain number of decimal places
  69301. */
  69302. isNonUniformWithinEpsilon(epsilon: number): boolean;
  69303. /**
  69304. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  69305. */
  69306. readonly isNonUniform: boolean;
  69307. /**
  69308. * Gets a new Vector3 from current Vector3 floored values
  69309. * @returns a new Vector3
  69310. */
  69311. floor(): Vector3;
  69312. /**
  69313. * Gets a new Vector3 from current Vector3 floored values
  69314. * @returns a new Vector3
  69315. */
  69316. fract(): Vector3;
  69317. /**
  69318. * Gets the length of the Vector3
  69319. * @returns the length of the Vector3
  69320. */
  69321. length(): number;
  69322. /**
  69323. * Gets the squared length of the Vector3
  69324. * @returns squared length of the Vector3
  69325. */
  69326. lengthSquared(): number;
  69327. /**
  69328. * Normalize the current Vector3.
  69329. * Please note that this is an in place operation.
  69330. * @returns the current updated Vector3
  69331. */
  69332. normalize(): Vector3;
  69333. /**
  69334. * Reorders the x y z properties of the vector in place
  69335. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  69336. * @returns the current updated vector
  69337. */
  69338. reorderInPlace(order: string): this;
  69339. /**
  69340. * Rotates the vector around 0,0,0 by a quaternion
  69341. * @param quaternion the rotation quaternion
  69342. * @param result vector to store the result
  69343. * @returns the resulting vector
  69344. */
  69345. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  69346. /**
  69347. * Rotates a vector around a given point
  69348. * @param quaternion the rotation quaternion
  69349. * @param point the point to rotate around
  69350. * @param result vector to store the result
  69351. * @returns the resulting vector
  69352. */
  69353. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  69354. /**
  69355. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  69356. * The cross product is then orthogonal to both current and "other"
  69357. * @param other defines the right operand
  69358. * @returns the cross product
  69359. */
  69360. cross(other: Vector3): Vector3;
  69361. /**
  69362. * Normalize the current Vector3 with the given input length.
  69363. * Please note that this is an in place operation.
  69364. * @param len the length of the vector
  69365. * @returns the current updated Vector3
  69366. */
  69367. normalizeFromLength(len: number): Vector3;
  69368. /**
  69369. * Normalize the current Vector3 to a new vector
  69370. * @returns the new Vector3
  69371. */
  69372. normalizeToNew(): Vector3;
  69373. /**
  69374. * Normalize the current Vector3 to the reference
  69375. * @param reference define the Vector3 to update
  69376. * @returns the updated Vector3
  69377. */
  69378. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  69379. /**
  69380. * Creates a new Vector3 copied from the current Vector3
  69381. * @returns the new Vector3
  69382. */
  69383. clone(): Vector3;
  69384. /**
  69385. * Copies the given vector coordinates to the current Vector3 ones
  69386. * @param source defines the source Vector3
  69387. * @returns the current updated Vector3
  69388. */
  69389. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  69390. /**
  69391. * Copies the given floats to the current Vector3 coordinates
  69392. * @param x defines the x coordinate of the operand
  69393. * @param y defines the y coordinate of the operand
  69394. * @param z defines the z coordinate of the operand
  69395. * @returns the current updated Vector3
  69396. */
  69397. copyFromFloats(x: number, y: number, z: number): Vector3;
  69398. /**
  69399. * Copies the given floats to the current Vector3 coordinates
  69400. * @param x defines the x coordinate of the operand
  69401. * @param y defines the y coordinate of the operand
  69402. * @param z defines the z coordinate of the operand
  69403. * @returns the current updated Vector3
  69404. */
  69405. set(x: number, y: number, z: number): Vector3;
  69406. /**
  69407. * Copies the given float to the current Vector3 coordinates
  69408. * @param v defines the x, y and z coordinates of the operand
  69409. * @returns the current updated Vector3
  69410. */
  69411. setAll(v: number): Vector3;
  69412. /**
  69413. * Get the clip factor between two vectors
  69414. * @param vector0 defines the first operand
  69415. * @param vector1 defines the second operand
  69416. * @param axis defines the axis to use
  69417. * @param size defines the size along the axis
  69418. * @returns the clip factor
  69419. */
  69420. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  69421. /**
  69422. * Get angle between two vectors
  69423. * @param vector0 angle between vector0 and vector1
  69424. * @param vector1 angle between vector0 and vector1
  69425. * @param normal direction of the normal
  69426. * @return the angle between vector0 and vector1
  69427. */
  69428. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  69429. /**
  69430. * Returns a new Vector3 set from the index "offset" of the given array
  69431. * @param array defines the source array
  69432. * @param offset defines the offset in the source array
  69433. * @returns the new Vector3
  69434. */
  69435. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  69436. /**
  69437. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  69438. * This function is deprecated. Use FromArray instead
  69439. * @param array defines the source array
  69440. * @param offset defines the offset in the source array
  69441. * @returns the new Vector3
  69442. */
  69443. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  69444. /**
  69445. * Sets the given vector "result" with the element values from the index "offset" of the given array
  69446. * @param array defines the source array
  69447. * @param offset defines the offset in the source array
  69448. * @param result defines the Vector3 where to store the result
  69449. */
  69450. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  69451. /**
  69452. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  69453. * This function is deprecated. Use FromArrayToRef instead.
  69454. * @param array defines the source array
  69455. * @param offset defines the offset in the source array
  69456. * @param result defines the Vector3 where to store the result
  69457. */
  69458. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  69459. /**
  69460. * Sets the given vector "result" with the given floats.
  69461. * @param x defines the x coordinate of the source
  69462. * @param y defines the y coordinate of the source
  69463. * @param z defines the z coordinate of the source
  69464. * @param result defines the Vector3 where to store the result
  69465. */
  69466. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  69467. /**
  69468. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  69469. * @returns a new empty Vector3
  69470. */
  69471. static Zero(): Vector3;
  69472. /**
  69473. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  69474. * @returns a new unit Vector3
  69475. */
  69476. static One(): Vector3;
  69477. /**
  69478. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  69479. * @returns a new up Vector3
  69480. */
  69481. static Up(): Vector3;
  69482. /**
  69483. * Gets a up Vector3 that must not be updated
  69484. */
  69485. static readonly UpReadOnly: DeepImmutable<Vector3>;
  69486. /**
  69487. * Gets a zero Vector3 that must not be updated
  69488. */
  69489. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  69490. /**
  69491. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  69492. * @returns a new down Vector3
  69493. */
  69494. static Down(): Vector3;
  69495. /**
  69496. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  69497. * @returns a new forward Vector3
  69498. */
  69499. static Forward(): Vector3;
  69500. /**
  69501. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  69502. * @returns a new forward Vector3
  69503. */
  69504. static Backward(): Vector3;
  69505. /**
  69506. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  69507. * @returns a new right Vector3
  69508. */
  69509. static Right(): Vector3;
  69510. /**
  69511. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  69512. * @returns a new left Vector3
  69513. */
  69514. static Left(): Vector3;
  69515. /**
  69516. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  69517. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69518. * @param vector defines the Vector3 to transform
  69519. * @param transformation defines the transformation matrix
  69520. * @returns the transformed Vector3
  69521. */
  69522. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  69523. /**
  69524. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  69525. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69526. * @param vector defines the Vector3 to transform
  69527. * @param transformation defines the transformation matrix
  69528. * @param result defines the Vector3 where to store the result
  69529. */
  69530. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69531. /**
  69532. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  69533. * This method computes tranformed coordinates only, not transformed direction vectors
  69534. * @param x define the x coordinate of the source vector
  69535. * @param y define the y coordinate of the source vector
  69536. * @param z define the z coordinate of the source vector
  69537. * @param transformation defines the transformation matrix
  69538. * @param result defines the Vector3 where to store the result
  69539. */
  69540. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69541. /**
  69542. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  69543. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69544. * @param vector defines the Vector3 to transform
  69545. * @param transformation defines the transformation matrix
  69546. * @returns the new Vector3
  69547. */
  69548. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  69549. /**
  69550. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  69551. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69552. * @param vector defines the Vector3 to transform
  69553. * @param transformation defines the transformation matrix
  69554. * @param result defines the Vector3 where to store the result
  69555. */
  69556. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69557. /**
  69558. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  69559. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69560. * @param x define the x coordinate of the source vector
  69561. * @param y define the y coordinate of the source vector
  69562. * @param z define the z coordinate of the source vector
  69563. * @param transformation defines the transformation matrix
  69564. * @param result defines the Vector3 where to store the result
  69565. */
  69566. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69567. /**
  69568. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  69569. * @param value1 defines the first control point
  69570. * @param value2 defines the second control point
  69571. * @param value3 defines the third control point
  69572. * @param value4 defines the fourth control point
  69573. * @param amount defines the amount on the spline to use
  69574. * @returns the new Vector3
  69575. */
  69576. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  69577. /**
  69578. * 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"
  69579. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69580. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69581. * @param value defines the current value
  69582. * @param min defines the lower range value
  69583. * @param max defines the upper range value
  69584. * @returns the new Vector3
  69585. */
  69586. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  69587. /**
  69588. * 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"
  69589. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69590. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69591. * @param value defines the current value
  69592. * @param min defines the lower range value
  69593. * @param max defines the upper range value
  69594. * @param result defines the Vector3 where to store the result
  69595. */
  69596. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  69597. /**
  69598. * Checks if a given vector is inside a specific range
  69599. * @param v defines the vector to test
  69600. * @param min defines the minimum range
  69601. * @param max defines the maximum range
  69602. */
  69603. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  69604. /**
  69605. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  69606. * @param value1 defines the first control point
  69607. * @param tangent1 defines the first tangent vector
  69608. * @param value2 defines the second control point
  69609. * @param tangent2 defines the second tangent vector
  69610. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  69611. * @returns the new Vector3
  69612. */
  69613. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  69614. /**
  69615. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  69616. * @param start defines the start value
  69617. * @param end defines the end value
  69618. * @param amount max defines amount between both (between 0 and 1)
  69619. * @returns the new Vector3
  69620. */
  69621. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  69622. /**
  69623. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  69624. * @param start defines the start value
  69625. * @param end defines the end value
  69626. * @param amount max defines amount between both (between 0 and 1)
  69627. * @param result defines the Vector3 where to store the result
  69628. */
  69629. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  69630. /**
  69631. * Returns the dot product (float) between the vectors "left" and "right"
  69632. * @param left defines the left operand
  69633. * @param right defines the right operand
  69634. * @returns the dot product
  69635. */
  69636. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  69637. /**
  69638. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  69639. * The cross product is then orthogonal to both "left" and "right"
  69640. * @param left defines the left operand
  69641. * @param right defines the right operand
  69642. * @returns the cross product
  69643. */
  69644. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  69645. /**
  69646. * Sets the given vector "result" with the cross product of "left" and "right"
  69647. * The cross product is then orthogonal to both "left" and "right"
  69648. * @param left defines the left operand
  69649. * @param right defines the right operand
  69650. * @param result defines the Vector3 where to store the result
  69651. */
  69652. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  69653. /**
  69654. * Returns a new Vector3 as the normalization of the given vector
  69655. * @param vector defines the Vector3 to normalize
  69656. * @returns the new Vector3
  69657. */
  69658. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  69659. /**
  69660. * Sets the given vector "result" with the normalization of the given first vector
  69661. * @param vector defines the Vector3 to normalize
  69662. * @param result defines the Vector3 where to store the result
  69663. */
  69664. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  69665. /**
  69666. * Project a Vector3 onto screen space
  69667. * @param vector defines the Vector3 to project
  69668. * @param world defines the world matrix to use
  69669. * @param transform defines the transform (view x projection) matrix to use
  69670. * @param viewport defines the screen viewport to use
  69671. * @returns the new Vector3
  69672. */
  69673. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  69674. /** @hidden */
  69675. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  69676. /**
  69677. * Unproject from screen space to object space
  69678. * @param source defines the screen space Vector3 to use
  69679. * @param viewportWidth defines the current width of the viewport
  69680. * @param viewportHeight defines the current height of the viewport
  69681. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69682. * @param transform defines the transform (view x projection) matrix to use
  69683. * @returns the new Vector3
  69684. */
  69685. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  69686. /**
  69687. * Unproject from screen space to object space
  69688. * @param source defines the screen space Vector3 to use
  69689. * @param viewportWidth defines the current width of the viewport
  69690. * @param viewportHeight defines the current height of the viewport
  69691. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69692. * @param view defines the view matrix to use
  69693. * @param projection defines the projection matrix to use
  69694. * @returns the new Vector3
  69695. */
  69696. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  69697. /**
  69698. * Unproject from screen space to object space
  69699. * @param source defines the screen space Vector3 to use
  69700. * @param viewportWidth defines the current width of the viewport
  69701. * @param viewportHeight defines the current height of the viewport
  69702. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69703. * @param view defines the view matrix to use
  69704. * @param projection defines the projection matrix to use
  69705. * @param result defines the Vector3 where to store the result
  69706. */
  69707. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  69708. /**
  69709. * Unproject from screen space to object space
  69710. * @param sourceX defines the screen space x coordinate to use
  69711. * @param sourceY defines the screen space y coordinate to use
  69712. * @param sourceZ defines the screen space z coordinate to use
  69713. * @param viewportWidth defines the current width of the viewport
  69714. * @param viewportHeight defines the current height of the viewport
  69715. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69716. * @param view defines the view matrix to use
  69717. * @param projection defines the projection matrix to use
  69718. * @param result defines the Vector3 where to store the result
  69719. */
  69720. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  69721. /**
  69722. * Gets the minimal coordinate values between two Vector3
  69723. * @param left defines the first operand
  69724. * @param right defines the second operand
  69725. * @returns the new Vector3
  69726. */
  69727. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  69728. /**
  69729. * Gets the maximal coordinate values between two Vector3
  69730. * @param left defines the first operand
  69731. * @param right defines the second operand
  69732. * @returns the new Vector3
  69733. */
  69734. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  69735. /**
  69736. * Returns the distance between the vectors "value1" and "value2"
  69737. * @param value1 defines the first operand
  69738. * @param value2 defines the second operand
  69739. * @returns the distance
  69740. */
  69741. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  69742. /**
  69743. * Returns the squared distance between the vectors "value1" and "value2"
  69744. * @param value1 defines the first operand
  69745. * @param value2 defines the second operand
  69746. * @returns the squared distance
  69747. */
  69748. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  69749. /**
  69750. * Returns a new Vector3 located at the center between "value1" and "value2"
  69751. * @param value1 defines the first operand
  69752. * @param value2 defines the second operand
  69753. * @returns the new Vector3
  69754. */
  69755. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  69756. /**
  69757. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  69758. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  69759. * to something in order to rotate it from its local system to the given target system
  69760. * Note: axis1, axis2 and axis3 are normalized during this operation
  69761. * @param axis1 defines the first axis
  69762. * @param axis2 defines the second axis
  69763. * @param axis3 defines the third axis
  69764. * @returns a new Vector3
  69765. */
  69766. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  69767. /**
  69768. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  69769. * @param axis1 defines the first axis
  69770. * @param axis2 defines the second axis
  69771. * @param axis3 defines the third axis
  69772. * @param ref defines the Vector3 where to store the result
  69773. */
  69774. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  69775. }
  69776. /**
  69777. * Vector4 class created for EulerAngle class conversion to Quaternion
  69778. */
  69779. export class Vector4 {
  69780. /** x value of the vector */
  69781. x: number;
  69782. /** y value of the vector */
  69783. y: number;
  69784. /** z value of the vector */
  69785. z: number;
  69786. /** w value of the vector */
  69787. w: number;
  69788. /**
  69789. * Creates a Vector4 object from the given floats.
  69790. * @param x x value of the vector
  69791. * @param y y value of the vector
  69792. * @param z z value of the vector
  69793. * @param w w value of the vector
  69794. */
  69795. constructor(
  69796. /** x value of the vector */
  69797. x: number,
  69798. /** y value of the vector */
  69799. y: number,
  69800. /** z value of the vector */
  69801. z: number,
  69802. /** w value of the vector */
  69803. w: number);
  69804. /**
  69805. * Returns the string with the Vector4 coordinates.
  69806. * @returns a string containing all the vector values
  69807. */
  69808. toString(): string;
  69809. /**
  69810. * Returns the string "Vector4".
  69811. * @returns "Vector4"
  69812. */
  69813. getClassName(): string;
  69814. /**
  69815. * Returns the Vector4 hash code.
  69816. * @returns a unique hash code
  69817. */
  69818. getHashCode(): number;
  69819. /**
  69820. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  69821. * @returns the resulting array
  69822. */
  69823. asArray(): number[];
  69824. /**
  69825. * Populates the given array from the given index with the Vector4 coordinates.
  69826. * @param array array to populate
  69827. * @param index index of the array to start at (default: 0)
  69828. * @returns the Vector4.
  69829. */
  69830. toArray(array: FloatArray, index?: number): Vector4;
  69831. /**
  69832. * Adds the given vector to the current Vector4.
  69833. * @param otherVector the vector to add
  69834. * @returns the updated Vector4.
  69835. */
  69836. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  69837. /**
  69838. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  69839. * @param otherVector the vector to add
  69840. * @returns the resulting vector
  69841. */
  69842. add(otherVector: DeepImmutable<Vector4>): Vector4;
  69843. /**
  69844. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  69845. * @param otherVector the vector to add
  69846. * @param result the vector to store the result
  69847. * @returns the current Vector4.
  69848. */
  69849. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69850. /**
  69851. * Subtract in place the given vector from the current Vector4.
  69852. * @param otherVector the vector to subtract
  69853. * @returns the updated Vector4.
  69854. */
  69855. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  69856. /**
  69857. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  69858. * @param otherVector the vector to add
  69859. * @returns the new vector with the result
  69860. */
  69861. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  69862. /**
  69863. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  69864. * @param otherVector the vector to subtract
  69865. * @param result the vector to store the result
  69866. * @returns the current Vector4.
  69867. */
  69868. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69869. /**
  69870. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69871. */
  69872. /**
  69873. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69874. * @param x value to subtract
  69875. * @param y value to subtract
  69876. * @param z value to subtract
  69877. * @param w value to subtract
  69878. * @returns new vector containing the result
  69879. */
  69880. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  69881. /**
  69882. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69883. * @param x value to subtract
  69884. * @param y value to subtract
  69885. * @param z value to subtract
  69886. * @param w value to subtract
  69887. * @param result the vector to store the result in
  69888. * @returns the current Vector4.
  69889. */
  69890. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  69891. /**
  69892. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  69893. * @returns a new vector with the negated values
  69894. */
  69895. negate(): Vector4;
  69896. /**
  69897. * Multiplies the current Vector4 coordinates by scale (float).
  69898. * @param scale the number to scale with
  69899. * @returns the updated Vector4.
  69900. */
  69901. scaleInPlace(scale: number): Vector4;
  69902. /**
  69903. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  69904. * @param scale the number to scale with
  69905. * @returns a new vector with the result
  69906. */
  69907. scale(scale: number): Vector4;
  69908. /**
  69909. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  69910. * @param scale the number to scale with
  69911. * @param result a vector to store the result in
  69912. * @returns the current Vector4.
  69913. */
  69914. scaleToRef(scale: number, result: Vector4): Vector4;
  69915. /**
  69916. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  69917. * @param scale defines the scale factor
  69918. * @param result defines the Vector4 object where to store the result
  69919. * @returns the unmodified current Vector4
  69920. */
  69921. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  69922. /**
  69923. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  69924. * @param otherVector the vector to compare against
  69925. * @returns true if they are equal
  69926. */
  69927. equals(otherVector: DeepImmutable<Vector4>): boolean;
  69928. /**
  69929. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  69930. * @param otherVector vector to compare against
  69931. * @param epsilon (Default: very small number)
  69932. * @returns true if they are equal
  69933. */
  69934. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  69935. /**
  69936. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  69937. * @param x x value to compare against
  69938. * @param y y value to compare against
  69939. * @param z z value to compare against
  69940. * @param w w value to compare against
  69941. * @returns true if equal
  69942. */
  69943. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  69944. /**
  69945. * Multiplies in place the current Vector4 by the given one.
  69946. * @param otherVector vector to multiple with
  69947. * @returns the updated Vector4.
  69948. */
  69949. multiplyInPlace(otherVector: Vector4): Vector4;
  69950. /**
  69951. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  69952. * @param otherVector vector to multiple with
  69953. * @returns resulting new vector
  69954. */
  69955. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  69956. /**
  69957. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  69958. * @param otherVector vector to multiple with
  69959. * @param result vector to store the result
  69960. * @returns the current Vector4.
  69961. */
  69962. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69963. /**
  69964. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  69965. * @param x x value multiply with
  69966. * @param y y value multiply with
  69967. * @param z z value multiply with
  69968. * @param w w value multiply with
  69969. * @returns resulting new vector
  69970. */
  69971. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  69972. /**
  69973. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  69974. * @param otherVector vector to devide with
  69975. * @returns resulting new vector
  69976. */
  69977. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  69978. /**
  69979. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  69980. * @param otherVector vector to devide with
  69981. * @param result vector to store the result
  69982. * @returns the current Vector4.
  69983. */
  69984. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69985. /**
  69986. * Divides the current Vector3 coordinates by the given ones.
  69987. * @param otherVector vector to devide with
  69988. * @returns the updated Vector3.
  69989. */
  69990. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  69991. /**
  69992. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  69993. * @param other defines the second operand
  69994. * @returns the current updated Vector4
  69995. */
  69996. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  69997. /**
  69998. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  69999. * @param other defines the second operand
  70000. * @returns the current updated Vector4
  70001. */
  70002. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70003. /**
  70004. * Gets a new Vector4 from current Vector4 floored values
  70005. * @returns a new Vector4
  70006. */
  70007. floor(): Vector4;
  70008. /**
  70009. * Gets a new Vector4 from current Vector3 floored values
  70010. * @returns a new Vector4
  70011. */
  70012. fract(): Vector4;
  70013. /**
  70014. * Returns the Vector4 length (float).
  70015. * @returns the length
  70016. */
  70017. length(): number;
  70018. /**
  70019. * Returns the Vector4 squared length (float).
  70020. * @returns the length squared
  70021. */
  70022. lengthSquared(): number;
  70023. /**
  70024. * Normalizes in place the Vector4.
  70025. * @returns the updated Vector4.
  70026. */
  70027. normalize(): Vector4;
  70028. /**
  70029. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70030. * @returns this converted to a new vector3
  70031. */
  70032. toVector3(): Vector3;
  70033. /**
  70034. * Returns a new Vector4 copied from the current one.
  70035. * @returns the new cloned vector
  70036. */
  70037. clone(): Vector4;
  70038. /**
  70039. * Updates the current Vector4 with the given one coordinates.
  70040. * @param source the source vector to copy from
  70041. * @returns the updated Vector4.
  70042. */
  70043. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  70044. /**
  70045. * Updates the current Vector4 coordinates with the given floats.
  70046. * @param x float to copy from
  70047. * @param y float to copy from
  70048. * @param z float to copy from
  70049. * @param w float to copy from
  70050. * @returns the updated Vector4.
  70051. */
  70052. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70053. /**
  70054. * Updates the current Vector4 coordinates with the given floats.
  70055. * @param x float to set from
  70056. * @param y float to set from
  70057. * @param z float to set from
  70058. * @param w float to set from
  70059. * @returns the updated Vector4.
  70060. */
  70061. set(x: number, y: number, z: number, w: number): Vector4;
  70062. /**
  70063. * Copies the given float to the current Vector3 coordinates
  70064. * @param v defines the x, y, z and w coordinates of the operand
  70065. * @returns the current updated Vector3
  70066. */
  70067. setAll(v: number): Vector4;
  70068. /**
  70069. * Returns a new Vector4 set from the starting index of the given array.
  70070. * @param array the array to pull values from
  70071. * @param offset the offset into the array to start at
  70072. * @returns the new vector
  70073. */
  70074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  70075. /**
  70076. * Updates the given vector "result" from the starting index of the given array.
  70077. * @param array the array to pull values from
  70078. * @param offset the offset into the array to start at
  70079. * @param result the vector to store the result in
  70080. */
  70081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  70082. /**
  70083. * Updates the given vector "result" from the starting index of the given Float32Array.
  70084. * @param array the array to pull values from
  70085. * @param offset the offset into the array to start at
  70086. * @param result the vector to store the result in
  70087. */
  70088. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  70089. /**
  70090. * Updates the given vector "result" coordinates from the given floats.
  70091. * @param x float to set from
  70092. * @param y float to set from
  70093. * @param z float to set from
  70094. * @param w float to set from
  70095. * @param result the vector to the floats in
  70096. */
  70097. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  70098. /**
  70099. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70100. * @returns the new vector
  70101. */
  70102. static Zero(): Vector4;
  70103. /**
  70104. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70105. * @returns the new vector
  70106. */
  70107. static One(): Vector4;
  70108. /**
  70109. * Returns a new normalized Vector4 from the given one.
  70110. * @param vector the vector to normalize
  70111. * @returns the vector
  70112. */
  70113. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  70114. /**
  70115. * Updates the given vector "result" from the normalization of the given one.
  70116. * @param vector the vector to normalize
  70117. * @param result the vector to store the result in
  70118. */
  70119. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  70120. /**
  70121. * Returns a vector with the minimum values from the left and right vectors
  70122. * @param left left vector to minimize
  70123. * @param right right vector to minimize
  70124. * @returns a new vector with the minimum of the left and right vector values
  70125. */
  70126. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70127. /**
  70128. * Returns a vector with the maximum values from the left and right vectors
  70129. * @param left left vector to maximize
  70130. * @param right right vector to maximize
  70131. * @returns a new vector with the maximum of the left and right vector values
  70132. */
  70133. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70134. /**
  70135. * Returns the distance (float) between the vectors "value1" and "value2".
  70136. * @param value1 value to calulate the distance between
  70137. * @param value2 value to calulate the distance between
  70138. * @return the distance between the two vectors
  70139. */
  70140. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70141. /**
  70142. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70143. * @param value1 value to calulate the distance between
  70144. * @param value2 value to calulate the distance between
  70145. * @return the distance between the two vectors squared
  70146. */
  70147. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70148. /**
  70149. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70150. * @param value1 value to calulate the center between
  70151. * @param value2 value to calulate the center between
  70152. * @return the center between the two vectors
  70153. */
  70154. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  70155. /**
  70156. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70157. * This methods computes transformed normalized direction vectors only.
  70158. * @param vector the vector to transform
  70159. * @param transformation the transformation matrix to apply
  70160. * @returns the new vector
  70161. */
  70162. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  70163. /**
  70164. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70165. * This methods computes transformed normalized direction vectors only.
  70166. * @param vector the vector to transform
  70167. * @param transformation the transformation matrix to apply
  70168. * @param result the vector to store the result in
  70169. */
  70170. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70171. /**
  70172. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  70173. * This methods computes transformed normalized direction vectors only.
  70174. * @param x value to transform
  70175. * @param y value to transform
  70176. * @param z value to transform
  70177. * @param w value to transform
  70178. * @param transformation the transformation matrix to apply
  70179. * @param result the vector to store the results in
  70180. */
  70181. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70182. /**
  70183. * Creates a new Vector4 from a Vector3
  70184. * @param source defines the source data
  70185. * @param w defines the 4th component (default is 0)
  70186. * @returns a new Vector4
  70187. */
  70188. static FromVector3(source: Vector3, w?: number): Vector4;
  70189. }
  70190. /**
  70191. * Class used to store quaternion data
  70192. * @see https://en.wikipedia.org/wiki/Quaternion
  70193. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  70194. */
  70195. export class Quaternion {
  70196. /** defines the first component (0 by default) */
  70197. x: number;
  70198. /** defines the second component (0 by default) */
  70199. y: number;
  70200. /** defines the third component (0 by default) */
  70201. z: number;
  70202. /** defines the fourth component (1.0 by default) */
  70203. w: number;
  70204. /**
  70205. * Creates a new Quaternion from the given floats
  70206. * @param x defines the first component (0 by default)
  70207. * @param y defines the second component (0 by default)
  70208. * @param z defines the third component (0 by default)
  70209. * @param w defines the fourth component (1.0 by default)
  70210. */
  70211. constructor(
  70212. /** defines the first component (0 by default) */
  70213. x?: number,
  70214. /** defines the second component (0 by default) */
  70215. y?: number,
  70216. /** defines the third component (0 by default) */
  70217. z?: number,
  70218. /** defines the fourth component (1.0 by default) */
  70219. w?: number);
  70220. /**
  70221. * Gets a string representation for the current quaternion
  70222. * @returns a string with the Quaternion coordinates
  70223. */
  70224. toString(): string;
  70225. /**
  70226. * Gets the class name of the quaternion
  70227. * @returns the string "Quaternion"
  70228. */
  70229. getClassName(): string;
  70230. /**
  70231. * Gets a hash code for this quaternion
  70232. * @returns the quaternion hash code
  70233. */
  70234. getHashCode(): number;
  70235. /**
  70236. * Copy the quaternion to an array
  70237. * @returns a new array populated with 4 elements from the quaternion coordinates
  70238. */
  70239. asArray(): number[];
  70240. /**
  70241. * Check if two quaternions are equals
  70242. * @param otherQuaternion defines the second operand
  70243. * @return true if the current quaternion and the given one coordinates are strictly equals
  70244. */
  70245. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  70246. /**
  70247. * Clone the current quaternion
  70248. * @returns a new quaternion copied from the current one
  70249. */
  70250. clone(): Quaternion;
  70251. /**
  70252. * Copy a quaternion to the current one
  70253. * @param other defines the other quaternion
  70254. * @returns the updated current quaternion
  70255. */
  70256. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  70257. /**
  70258. * Updates the current quaternion with the given float coordinates
  70259. * @param x defines the x coordinate
  70260. * @param y defines the y coordinate
  70261. * @param z defines the z coordinate
  70262. * @param w defines the w coordinate
  70263. * @returns the updated current quaternion
  70264. */
  70265. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  70266. /**
  70267. * Updates the current quaternion from the given float coordinates
  70268. * @param x defines the x coordinate
  70269. * @param y defines the y coordinate
  70270. * @param z defines the z coordinate
  70271. * @param w defines the w coordinate
  70272. * @returns the updated current quaternion
  70273. */
  70274. set(x: number, y: number, z: number, w: number): Quaternion;
  70275. /**
  70276. * Adds two quaternions
  70277. * @param other defines the second operand
  70278. * @returns a new quaternion as the addition result of the given one and the current quaternion
  70279. */
  70280. add(other: DeepImmutable<Quaternion>): Quaternion;
  70281. /**
  70282. * Add a quaternion to the current one
  70283. * @param other defines the quaternion to add
  70284. * @returns the current quaternion
  70285. */
  70286. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  70287. /**
  70288. * Subtract two quaternions
  70289. * @param other defines the second operand
  70290. * @returns a new quaternion as the subtraction result of the given one from the current one
  70291. */
  70292. subtract(other: Quaternion): Quaternion;
  70293. /**
  70294. * Multiplies the current quaternion by a scale factor
  70295. * @param value defines the scale factor
  70296. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  70297. */
  70298. scale(value: number): Quaternion;
  70299. /**
  70300. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  70301. * @param scale defines the scale factor
  70302. * @param result defines the Quaternion object where to store the result
  70303. * @returns the unmodified current quaternion
  70304. */
  70305. scaleToRef(scale: number, result: Quaternion): Quaternion;
  70306. /**
  70307. * Multiplies in place the current quaternion by a scale factor
  70308. * @param value defines the scale factor
  70309. * @returns the current modified quaternion
  70310. */
  70311. scaleInPlace(value: number): Quaternion;
  70312. /**
  70313. * Scale the current quaternion values by a factor and add the result to a given quaternion
  70314. * @param scale defines the scale factor
  70315. * @param result defines the Quaternion object where to store the result
  70316. * @returns the unmodified current quaternion
  70317. */
  70318. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  70319. /**
  70320. * Multiplies two quaternions
  70321. * @param q1 defines the second operand
  70322. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  70323. */
  70324. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  70325. /**
  70326. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  70327. * @param q1 defines the second operand
  70328. * @param result defines the target quaternion
  70329. * @returns the current quaternion
  70330. */
  70331. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  70332. /**
  70333. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  70334. * @param q1 defines the second operand
  70335. * @returns the currentupdated quaternion
  70336. */
  70337. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  70338. /**
  70339. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  70340. * @param ref defines the target quaternion
  70341. * @returns the current quaternion
  70342. */
  70343. conjugateToRef(ref: Quaternion): Quaternion;
  70344. /**
  70345. * Conjugates in place (1-q) the current quaternion
  70346. * @returns the current updated quaternion
  70347. */
  70348. conjugateInPlace(): Quaternion;
  70349. /**
  70350. * Conjugates in place (1-q) the current quaternion
  70351. * @returns a new quaternion
  70352. */
  70353. conjugate(): Quaternion;
  70354. /**
  70355. * Gets length of current quaternion
  70356. * @returns the quaternion length (float)
  70357. */
  70358. length(): number;
  70359. /**
  70360. * Normalize in place the current quaternion
  70361. * @returns the current updated quaternion
  70362. */
  70363. normalize(): Quaternion;
  70364. /**
  70365. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  70366. * @param order is a reserved parameter and is ignore for now
  70367. * @returns a new Vector3 containing the Euler angles
  70368. */
  70369. toEulerAngles(order?: string): Vector3;
  70370. /**
  70371. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  70372. * @param result defines the vector which will be filled with the Euler angles
  70373. * @param order is a reserved parameter and is ignore for now
  70374. * @returns the current unchanged quaternion
  70375. */
  70376. toEulerAnglesToRef(result: Vector3): Quaternion;
  70377. /**
  70378. * Updates the given rotation matrix with the current quaternion values
  70379. * @param result defines the target matrix
  70380. * @returns the current unchanged quaternion
  70381. */
  70382. toRotationMatrix(result: Matrix): Quaternion;
  70383. /**
  70384. * Updates the current quaternion from the given rotation matrix values
  70385. * @param matrix defines the source matrix
  70386. * @returns the current updated quaternion
  70387. */
  70388. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  70389. /**
  70390. * Creates a new quaternion from a rotation matrix
  70391. * @param matrix defines the source matrix
  70392. * @returns a new quaternion created from the given rotation matrix values
  70393. */
  70394. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  70395. /**
  70396. * Updates the given quaternion with the given rotation matrix values
  70397. * @param matrix defines the source matrix
  70398. * @param result defines the target quaternion
  70399. */
  70400. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  70401. /**
  70402. * Returns the dot product (float) between the quaternions "left" and "right"
  70403. * @param left defines the left operand
  70404. * @param right defines the right operand
  70405. * @returns the dot product
  70406. */
  70407. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  70408. /**
  70409. * Checks if the two quaternions are close to each other
  70410. * @param quat0 defines the first quaternion to check
  70411. * @param quat1 defines the second quaternion to check
  70412. * @returns true if the two quaternions are close to each other
  70413. */
  70414. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  70415. /**
  70416. * Creates an empty quaternion
  70417. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  70418. */
  70419. static Zero(): Quaternion;
  70420. /**
  70421. * Inverse a given quaternion
  70422. * @param q defines the source quaternion
  70423. * @returns a new quaternion as the inverted current quaternion
  70424. */
  70425. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  70426. /**
  70427. * Inverse a given quaternion
  70428. * @param q defines the source quaternion
  70429. * @param result the quaternion the result will be stored in
  70430. * @returns the result quaternion
  70431. */
  70432. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  70433. /**
  70434. * Creates an identity quaternion
  70435. * @returns the identity quaternion
  70436. */
  70437. static Identity(): Quaternion;
  70438. /**
  70439. * Gets a boolean indicating if the given quaternion is identity
  70440. * @param quaternion defines the quaternion to check
  70441. * @returns true if the quaternion is identity
  70442. */
  70443. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  70444. /**
  70445. * Creates a quaternion from a rotation around an axis
  70446. * @param axis defines the axis to use
  70447. * @param angle defines the angle to use
  70448. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  70449. */
  70450. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  70451. /**
  70452. * Creates a rotation around an axis and stores it into the given quaternion
  70453. * @param axis defines the axis to use
  70454. * @param angle defines the angle to use
  70455. * @param result defines the target quaternion
  70456. * @returns the target quaternion
  70457. */
  70458. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  70459. /**
  70460. * Creates a new quaternion from data stored into an array
  70461. * @param array defines the data source
  70462. * @param offset defines the offset in the source array where the data starts
  70463. * @returns a new quaternion
  70464. */
  70465. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  70466. /**
  70467. * Create a quaternion from Euler rotation angles
  70468. * @param x Pitch
  70469. * @param y Yaw
  70470. * @param z Roll
  70471. * @returns the new Quaternion
  70472. */
  70473. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  70474. /**
  70475. * Updates a quaternion from Euler rotation angles
  70476. * @param x Pitch
  70477. * @param y Yaw
  70478. * @param z Roll
  70479. * @param result the quaternion to store the result
  70480. * @returns the updated quaternion
  70481. */
  70482. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  70483. /**
  70484. * Create a quaternion from Euler rotation vector
  70485. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70486. * @returns the new Quaternion
  70487. */
  70488. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  70489. /**
  70490. * Updates a quaternion from Euler rotation vector
  70491. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70492. * @param result the quaternion to store the result
  70493. * @returns the updated quaternion
  70494. */
  70495. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  70496. /**
  70497. * Creates a new quaternion from the given Euler float angles (y, x, z)
  70498. * @param yaw defines the rotation around Y axis
  70499. * @param pitch defines the rotation around X axis
  70500. * @param roll defines the rotation around Z axis
  70501. * @returns the new quaternion
  70502. */
  70503. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  70504. /**
  70505. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  70506. * @param yaw defines the rotation around Y axis
  70507. * @param pitch defines the rotation around X axis
  70508. * @param roll defines the rotation around Z axis
  70509. * @param result defines the target quaternion
  70510. */
  70511. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  70512. /**
  70513. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  70514. * @param alpha defines the rotation around first axis
  70515. * @param beta defines the rotation around second axis
  70516. * @param gamma defines the rotation around third axis
  70517. * @returns the new quaternion
  70518. */
  70519. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  70520. /**
  70521. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  70522. * @param alpha defines the rotation around first axis
  70523. * @param beta defines the rotation around second axis
  70524. * @param gamma defines the rotation around third axis
  70525. * @param result defines the target quaternion
  70526. */
  70527. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  70528. /**
  70529. * 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)
  70530. * @param axis1 defines the first axis
  70531. * @param axis2 defines the second axis
  70532. * @param axis3 defines the third axis
  70533. * @returns the new quaternion
  70534. */
  70535. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  70536. /**
  70537. * 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
  70538. * @param axis1 defines the first axis
  70539. * @param axis2 defines the second axis
  70540. * @param axis3 defines the third axis
  70541. * @param ref defines the target quaternion
  70542. */
  70543. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  70544. /**
  70545. * Interpolates between two quaternions
  70546. * @param left defines first quaternion
  70547. * @param right defines second quaternion
  70548. * @param amount defines the gradient to use
  70549. * @returns the new interpolated quaternion
  70550. */
  70551. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  70552. /**
  70553. * Interpolates between two quaternions and stores it into a target quaternion
  70554. * @param left defines first quaternion
  70555. * @param right defines second quaternion
  70556. * @param amount defines the gradient to use
  70557. * @param result defines the target quaternion
  70558. */
  70559. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  70560. /**
  70561. * Interpolate between two quaternions using Hermite interpolation
  70562. * @param value1 defines first quaternion
  70563. * @param tangent1 defines the incoming tangent
  70564. * @param value2 defines second quaternion
  70565. * @param tangent2 defines the outgoing tangent
  70566. * @param amount defines the target quaternion
  70567. * @returns the new interpolated quaternion
  70568. */
  70569. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  70570. }
  70571. /**
  70572. * Class used to store matrix data (4x4)
  70573. */
  70574. export class Matrix {
  70575. private static _updateFlagSeed;
  70576. private static _identityReadOnly;
  70577. private _isIdentity;
  70578. private _isIdentityDirty;
  70579. private _isIdentity3x2;
  70580. private _isIdentity3x2Dirty;
  70581. /**
  70582. * Gets the update flag of the matrix which is an unique number for the matrix.
  70583. * It will be incremented every time the matrix data change.
  70584. * You can use it to speed the comparison between two versions of the same matrix.
  70585. */
  70586. updateFlag: number;
  70587. private readonly _m;
  70588. /**
  70589. * Gets the internal data of the matrix
  70590. */
  70591. readonly m: DeepImmutable<Float32Array>;
  70592. /** @hidden */
  70593. _markAsUpdated(): void;
  70594. /** @hidden */
  70595. private _updateIdentityStatus;
  70596. /**
  70597. * Creates an empty matrix (filled with zeros)
  70598. */
  70599. constructor();
  70600. /**
  70601. * Check if the current matrix is identity
  70602. * @returns true is the matrix is the identity matrix
  70603. */
  70604. isIdentity(): boolean;
  70605. /**
  70606. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  70607. * @returns true is the matrix is the identity matrix
  70608. */
  70609. isIdentityAs3x2(): boolean;
  70610. /**
  70611. * Gets the determinant of the matrix
  70612. * @returns the matrix determinant
  70613. */
  70614. determinant(): number;
  70615. /**
  70616. * Returns the matrix as a Float32Array
  70617. * @returns the matrix underlying array
  70618. */
  70619. toArray(): DeepImmutable<Float32Array>;
  70620. /**
  70621. * Returns the matrix as a Float32Array
  70622. * @returns the matrix underlying array.
  70623. */
  70624. asArray(): DeepImmutable<Float32Array>;
  70625. /**
  70626. * Inverts the current matrix in place
  70627. * @returns the current inverted matrix
  70628. */
  70629. invert(): Matrix;
  70630. /**
  70631. * Sets all the matrix elements to zero
  70632. * @returns the current matrix
  70633. */
  70634. reset(): Matrix;
  70635. /**
  70636. * Adds the current matrix with a second one
  70637. * @param other defines the matrix to add
  70638. * @returns a new matrix as the addition of the current matrix and the given one
  70639. */
  70640. add(other: DeepImmutable<Matrix>): Matrix;
  70641. /**
  70642. * Sets the given matrix "result" to the addition of the current matrix and the given one
  70643. * @param other defines the matrix to add
  70644. * @param result defines the target matrix
  70645. * @returns the current matrix
  70646. */
  70647. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  70648. /**
  70649. * Adds in place the given matrix to the current matrix
  70650. * @param other defines the second operand
  70651. * @returns the current updated matrix
  70652. */
  70653. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  70654. /**
  70655. * Sets the given matrix to the current inverted Matrix
  70656. * @param other defines the target matrix
  70657. * @returns the unmodified current matrix
  70658. */
  70659. invertToRef(other: Matrix): Matrix;
  70660. /**
  70661. * add a value at the specified position in the current Matrix
  70662. * @param index the index of the value within the matrix. between 0 and 15.
  70663. * @param value the value to be added
  70664. * @returns the current updated matrix
  70665. */
  70666. addAtIndex(index: number, value: number): Matrix;
  70667. /**
  70668. * mutiply the specified position in the current Matrix by a value
  70669. * @param index the index of the value within the matrix. between 0 and 15.
  70670. * @param value the value to be added
  70671. * @returns the current updated matrix
  70672. */
  70673. multiplyAtIndex(index: number, value: number): Matrix;
  70674. /**
  70675. * Inserts the translation vector (using 3 floats) in the current matrix
  70676. * @param x defines the 1st component of the translation
  70677. * @param y defines the 2nd component of the translation
  70678. * @param z defines the 3rd component of the translation
  70679. * @returns the current updated matrix
  70680. */
  70681. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  70682. /**
  70683. * Adds the translation vector (using 3 floats) in the current matrix
  70684. * @param x defines the 1st component of the translation
  70685. * @param y defines the 2nd component of the translation
  70686. * @param z defines the 3rd component of the translation
  70687. * @returns the current updated matrix
  70688. */
  70689. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  70690. /**
  70691. * Inserts the translation vector in the current matrix
  70692. * @param vector3 defines the translation to insert
  70693. * @returns the current updated matrix
  70694. */
  70695. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  70696. /**
  70697. * Gets the translation value of the current matrix
  70698. * @returns a new Vector3 as the extracted translation from the matrix
  70699. */
  70700. getTranslation(): Vector3;
  70701. /**
  70702. * Fill a Vector3 with the extracted translation from the matrix
  70703. * @param result defines the Vector3 where to store the translation
  70704. * @returns the current matrix
  70705. */
  70706. getTranslationToRef(result: Vector3): Matrix;
  70707. /**
  70708. * Remove rotation and scaling part from the matrix
  70709. * @returns the updated matrix
  70710. */
  70711. removeRotationAndScaling(): Matrix;
  70712. /**
  70713. * Multiply two matrices
  70714. * @param other defines the second operand
  70715. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  70716. */
  70717. multiply(other: DeepImmutable<Matrix>): Matrix;
  70718. /**
  70719. * Copy the current matrix from the given one
  70720. * @param other defines the source matrix
  70721. * @returns the current updated matrix
  70722. */
  70723. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  70724. /**
  70725. * Populates the given array from the starting index with the current matrix values
  70726. * @param array defines the target array
  70727. * @param offset defines the offset in the target array where to start storing values
  70728. * @returns the current matrix
  70729. */
  70730. copyToArray(array: Float32Array, offset?: number): Matrix;
  70731. /**
  70732. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  70733. * @param other defines the second operand
  70734. * @param result defines the matrix where to store the multiplication
  70735. * @returns the current matrix
  70736. */
  70737. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  70738. /**
  70739. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  70740. * @param other defines the second operand
  70741. * @param result defines the array where to store the multiplication
  70742. * @param offset defines the offset in the target array where to start storing values
  70743. * @returns the current matrix
  70744. */
  70745. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  70746. /**
  70747. * Check equality between this matrix and a second one
  70748. * @param value defines the second matrix to compare
  70749. * @returns true is the current matrix and the given one values are strictly equal
  70750. */
  70751. equals(value: DeepImmutable<Matrix>): boolean;
  70752. /**
  70753. * Clone the current matrix
  70754. * @returns a new matrix from the current matrix
  70755. */
  70756. clone(): Matrix;
  70757. /**
  70758. * Returns the name of the current matrix class
  70759. * @returns the string "Matrix"
  70760. */
  70761. getClassName(): string;
  70762. /**
  70763. * Gets the hash code of the current matrix
  70764. * @returns the hash code
  70765. */
  70766. getHashCode(): number;
  70767. /**
  70768. * Decomposes the current Matrix into a translation, rotation and scaling components
  70769. * @param scale defines the scale vector3 given as a reference to update
  70770. * @param rotation defines the rotation quaternion given as a reference to update
  70771. * @param translation defines the translation vector3 given as a reference to update
  70772. * @returns true if operation was successful
  70773. */
  70774. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  70775. /**
  70776. * Gets specific row of the matrix
  70777. * @param index defines the number of the row to get
  70778. * @returns the index-th row of the current matrix as a new Vector4
  70779. */
  70780. getRow(index: number): Nullable<Vector4>;
  70781. /**
  70782. * Sets the index-th row of the current matrix to the vector4 values
  70783. * @param index defines the number of the row to set
  70784. * @param row defines the target vector4
  70785. * @returns the updated current matrix
  70786. */
  70787. setRow(index: number, row: Vector4): Matrix;
  70788. /**
  70789. * Compute the transpose of the matrix
  70790. * @returns the new transposed matrix
  70791. */
  70792. transpose(): Matrix;
  70793. /**
  70794. * Compute the transpose of the matrix and store it in a given matrix
  70795. * @param result defines the target matrix
  70796. * @returns the current matrix
  70797. */
  70798. transposeToRef(result: Matrix): Matrix;
  70799. /**
  70800. * Sets the index-th row of the current matrix with the given 4 x float values
  70801. * @param index defines the row index
  70802. * @param x defines the x component to set
  70803. * @param y defines the y component to set
  70804. * @param z defines the z component to set
  70805. * @param w defines the w component to set
  70806. * @returns the updated current matrix
  70807. */
  70808. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  70809. /**
  70810. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  70811. * @param scale defines the scale factor
  70812. * @returns a new matrix
  70813. */
  70814. scale(scale: number): Matrix;
  70815. /**
  70816. * Scale the current matrix values by a factor to a given result matrix
  70817. * @param scale defines the scale factor
  70818. * @param result defines the matrix to store the result
  70819. * @returns the current matrix
  70820. */
  70821. scaleToRef(scale: number, result: Matrix): Matrix;
  70822. /**
  70823. * Scale the current matrix values by a factor and add the result to a given matrix
  70824. * @param scale defines the scale factor
  70825. * @param result defines the Matrix to store the result
  70826. * @returns the current matrix
  70827. */
  70828. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  70829. /**
  70830. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  70831. * @param ref matrix to store the result
  70832. */
  70833. toNormalMatrix(ref: Matrix): void;
  70834. /**
  70835. * Gets only rotation part of the current matrix
  70836. * @returns a new matrix sets to the extracted rotation matrix from the current one
  70837. */
  70838. getRotationMatrix(): Matrix;
  70839. /**
  70840. * Extracts the rotation matrix from the current one and sets it as the given "result"
  70841. * @param result defines the target matrix to store data to
  70842. * @returns the current matrix
  70843. */
  70844. getRotationMatrixToRef(result: Matrix): Matrix;
  70845. /**
  70846. * Toggles model matrix from being right handed to left handed in place and vice versa
  70847. */
  70848. toggleModelMatrixHandInPlace(): void;
  70849. /**
  70850. * Toggles projection matrix from being right handed to left handed in place and vice versa
  70851. */
  70852. toggleProjectionMatrixHandInPlace(): void;
  70853. /**
  70854. * Creates a matrix from an array
  70855. * @param array defines the source array
  70856. * @param offset defines an offset in the source array
  70857. * @returns a new Matrix set from the starting index of the given array
  70858. */
  70859. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  70860. /**
  70861. * Copy the content of an array into a given matrix
  70862. * @param array defines the source array
  70863. * @param offset defines an offset in the source array
  70864. * @param result defines the target matrix
  70865. */
  70866. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  70867. /**
  70868. * Stores an array into a matrix after having multiplied each component by a given factor
  70869. * @param array defines the source array
  70870. * @param offset defines the offset in the source array
  70871. * @param scale defines the scaling factor
  70872. * @param result defines the target matrix
  70873. */
  70874. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  70875. /**
  70876. * Gets an identity matrix that must not be updated
  70877. */
  70878. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  70879. /**
  70880. * Stores a list of values (16) inside a given matrix
  70881. * @param initialM11 defines 1st value of 1st row
  70882. * @param initialM12 defines 2nd value of 1st row
  70883. * @param initialM13 defines 3rd value of 1st row
  70884. * @param initialM14 defines 4th value of 1st row
  70885. * @param initialM21 defines 1st value of 2nd row
  70886. * @param initialM22 defines 2nd value of 2nd row
  70887. * @param initialM23 defines 3rd value of 2nd row
  70888. * @param initialM24 defines 4th value of 2nd row
  70889. * @param initialM31 defines 1st value of 3rd row
  70890. * @param initialM32 defines 2nd value of 3rd row
  70891. * @param initialM33 defines 3rd value of 3rd row
  70892. * @param initialM34 defines 4th value of 3rd row
  70893. * @param initialM41 defines 1st value of 4th row
  70894. * @param initialM42 defines 2nd value of 4th row
  70895. * @param initialM43 defines 3rd value of 4th row
  70896. * @param initialM44 defines 4th value of 4th row
  70897. * @param result defines the target matrix
  70898. */
  70899. 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;
  70900. /**
  70901. * Creates new matrix from a list of values (16)
  70902. * @param initialM11 defines 1st value of 1st row
  70903. * @param initialM12 defines 2nd value of 1st row
  70904. * @param initialM13 defines 3rd value of 1st row
  70905. * @param initialM14 defines 4th value of 1st row
  70906. * @param initialM21 defines 1st value of 2nd row
  70907. * @param initialM22 defines 2nd value of 2nd row
  70908. * @param initialM23 defines 3rd value of 2nd row
  70909. * @param initialM24 defines 4th value of 2nd row
  70910. * @param initialM31 defines 1st value of 3rd row
  70911. * @param initialM32 defines 2nd value of 3rd row
  70912. * @param initialM33 defines 3rd value of 3rd row
  70913. * @param initialM34 defines 4th value of 3rd row
  70914. * @param initialM41 defines 1st value of 4th row
  70915. * @param initialM42 defines 2nd value of 4th row
  70916. * @param initialM43 defines 3rd value of 4th row
  70917. * @param initialM44 defines 4th value of 4th row
  70918. * @returns the new matrix
  70919. */
  70920. 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;
  70921. /**
  70922. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  70923. * @param scale defines the scale vector3
  70924. * @param rotation defines the rotation quaternion
  70925. * @param translation defines the translation vector3
  70926. * @returns a new matrix
  70927. */
  70928. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  70929. /**
  70930. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  70931. * @param scale defines the scale vector3
  70932. * @param rotation defines the rotation quaternion
  70933. * @param translation defines the translation vector3
  70934. * @param result defines the target matrix
  70935. */
  70936. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  70937. /**
  70938. * Creates a new identity matrix
  70939. * @returns a new identity matrix
  70940. */
  70941. static Identity(): Matrix;
  70942. /**
  70943. * Creates a new identity matrix and stores the result in a given matrix
  70944. * @param result defines the target matrix
  70945. */
  70946. static IdentityToRef(result: Matrix): void;
  70947. /**
  70948. * Creates a new zero matrix
  70949. * @returns a new zero matrix
  70950. */
  70951. static Zero(): Matrix;
  70952. /**
  70953. * Creates a new rotation matrix for "angle" radians around the X axis
  70954. * @param angle defines the angle (in radians) to use
  70955. * @return the new matrix
  70956. */
  70957. static RotationX(angle: number): Matrix;
  70958. /**
  70959. * Creates a new matrix as the invert of a given matrix
  70960. * @param source defines the source matrix
  70961. * @returns the new matrix
  70962. */
  70963. static Invert(source: DeepImmutable<Matrix>): Matrix;
  70964. /**
  70965. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  70966. * @param angle defines the angle (in radians) to use
  70967. * @param result defines the target matrix
  70968. */
  70969. static RotationXToRef(angle: number, result: Matrix): void;
  70970. /**
  70971. * Creates a new rotation matrix for "angle" radians around the Y axis
  70972. * @param angle defines the angle (in radians) to use
  70973. * @return the new matrix
  70974. */
  70975. static RotationY(angle: number): Matrix;
  70976. /**
  70977. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  70978. * @param angle defines the angle (in radians) to use
  70979. * @param result defines the target matrix
  70980. */
  70981. static RotationYToRef(angle: number, result: Matrix): void;
  70982. /**
  70983. * Creates a new rotation matrix for "angle" radians around the Z axis
  70984. * @param angle defines the angle (in radians) to use
  70985. * @return the new matrix
  70986. */
  70987. static RotationZ(angle: number): Matrix;
  70988. /**
  70989. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  70990. * @param angle defines the angle (in radians) to use
  70991. * @param result defines the target matrix
  70992. */
  70993. static RotationZToRef(angle: number, result: Matrix): void;
  70994. /**
  70995. * Creates a new rotation matrix for "angle" radians around the given axis
  70996. * @param axis defines the axis to use
  70997. * @param angle defines the angle (in radians) to use
  70998. * @return the new matrix
  70999. */
  71000. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  71001. /**
  71002. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  71003. * @param axis defines the axis to use
  71004. * @param angle defines the angle (in radians) to use
  71005. * @param result defines the target matrix
  71006. */
  71007. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  71008. /**
  71009. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  71010. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  71011. * @param from defines the vector to align
  71012. * @param to defines the vector to align to
  71013. * @param result defines the target matrix
  71014. */
  71015. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  71016. /**
  71017. * Creates a rotation matrix
  71018. * @param yaw defines the yaw angle in radians (Y axis)
  71019. * @param pitch defines the pitch angle in radians (X axis)
  71020. * @param roll defines the roll angle in radians (X axis)
  71021. * @returns the new rotation matrix
  71022. */
  71023. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  71024. /**
  71025. * Creates a rotation matrix and stores it in a given matrix
  71026. * @param yaw defines the yaw angle in radians (Y axis)
  71027. * @param pitch defines the pitch angle in radians (X axis)
  71028. * @param roll defines the roll angle in radians (X axis)
  71029. * @param result defines the target matrix
  71030. */
  71031. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  71032. /**
  71033. * Creates a scaling matrix
  71034. * @param x defines the scale factor on X axis
  71035. * @param y defines the scale factor on Y axis
  71036. * @param z defines the scale factor on Z axis
  71037. * @returns the new matrix
  71038. */
  71039. static Scaling(x: number, y: number, z: number): Matrix;
  71040. /**
  71041. * Creates a scaling matrix and stores it in a given matrix
  71042. * @param x defines the scale factor on X axis
  71043. * @param y defines the scale factor on Y axis
  71044. * @param z defines the scale factor on Z axis
  71045. * @param result defines the target matrix
  71046. */
  71047. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  71048. /**
  71049. * Creates a translation matrix
  71050. * @param x defines the translation on X axis
  71051. * @param y defines the translation on Y axis
  71052. * @param z defines the translationon Z axis
  71053. * @returns the new matrix
  71054. */
  71055. static Translation(x: number, y: number, z: number): Matrix;
  71056. /**
  71057. * Creates a translation matrix and stores it in a given matrix
  71058. * @param x defines the translation on X axis
  71059. * @param y defines the translation on Y axis
  71060. * @param z defines the translationon Z axis
  71061. * @param result defines the target matrix
  71062. */
  71063. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  71064. /**
  71065. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71066. * @param startValue defines the start value
  71067. * @param endValue defines the end value
  71068. * @param gradient defines the gradient factor
  71069. * @returns the new matrix
  71070. */
  71071. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71072. /**
  71073. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71074. * @param startValue defines the start value
  71075. * @param endValue defines the end value
  71076. * @param gradient defines the gradient factor
  71077. * @param result defines the Matrix object where to store data
  71078. */
  71079. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71080. /**
  71081. * Builds a new matrix whose values are computed by:
  71082. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71083. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71084. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71085. * @param startValue defines the first matrix
  71086. * @param endValue defines the second matrix
  71087. * @param gradient defines the gradient between the two matrices
  71088. * @returns the new matrix
  71089. */
  71090. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71091. /**
  71092. * Update a matrix to values which are computed by:
  71093. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71094. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71095. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71096. * @param startValue defines the first matrix
  71097. * @param endValue defines the second matrix
  71098. * @param gradient defines the gradient between the two matrices
  71099. * @param result defines the target matrix
  71100. */
  71101. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71102. /**
  71103. * 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"
  71104. * This function works in left handed mode
  71105. * @param eye defines the final position of the entity
  71106. * @param target defines where the entity should look at
  71107. * @param up defines the up vector for the entity
  71108. * @returns the new matrix
  71109. */
  71110. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71111. /**
  71112. * 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".
  71113. * This function works in left handed mode
  71114. * @param eye defines the final position of the entity
  71115. * @param target defines where the entity should look at
  71116. * @param up defines the up vector for the entity
  71117. * @param result defines the target matrix
  71118. */
  71119. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71120. /**
  71121. * 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"
  71122. * This function works in right handed mode
  71123. * @param eye defines the final position of the entity
  71124. * @param target defines where the entity should look at
  71125. * @param up defines the up vector for the entity
  71126. * @returns the new matrix
  71127. */
  71128. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71129. /**
  71130. * 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".
  71131. * This function works in right handed mode
  71132. * @param eye defines the final position of the entity
  71133. * @param target defines where the entity should look at
  71134. * @param up defines the up vector for the entity
  71135. * @param result defines the target matrix
  71136. */
  71137. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71138. /**
  71139. * Create a left-handed orthographic projection matrix
  71140. * @param width defines the viewport width
  71141. * @param height defines the viewport height
  71142. * @param znear defines the near clip plane
  71143. * @param zfar defines the far clip plane
  71144. * @returns a new matrix as a left-handed orthographic projection matrix
  71145. */
  71146. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71147. /**
  71148. * Store a left-handed orthographic projection to a given matrix
  71149. * @param width defines the viewport width
  71150. * @param height defines the viewport height
  71151. * @param znear defines the near clip plane
  71152. * @param zfar defines the far clip plane
  71153. * @param result defines the target matrix
  71154. */
  71155. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  71156. /**
  71157. * Create a left-handed orthographic projection matrix
  71158. * @param left defines the viewport left coordinate
  71159. * @param right defines the viewport right coordinate
  71160. * @param bottom defines the viewport bottom coordinate
  71161. * @param top defines the viewport top coordinate
  71162. * @param znear defines the near clip plane
  71163. * @param zfar defines the far clip plane
  71164. * @returns a new matrix as a left-handed orthographic projection matrix
  71165. */
  71166. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71167. /**
  71168. * Stores a left-handed orthographic projection into a given matrix
  71169. * @param left defines the viewport left coordinate
  71170. * @param right defines the viewport right coordinate
  71171. * @param bottom defines the viewport bottom coordinate
  71172. * @param top defines the viewport top coordinate
  71173. * @param znear defines the near clip plane
  71174. * @param zfar defines the far clip plane
  71175. * @param result defines the target matrix
  71176. */
  71177. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71178. /**
  71179. * Creates a right-handed orthographic projection matrix
  71180. * @param left defines the viewport left coordinate
  71181. * @param right defines the viewport right coordinate
  71182. * @param bottom defines the viewport bottom coordinate
  71183. * @param top defines the viewport top coordinate
  71184. * @param znear defines the near clip plane
  71185. * @param zfar defines the far clip plane
  71186. * @returns a new matrix as a right-handed orthographic projection matrix
  71187. */
  71188. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71189. /**
  71190. * Stores a right-handed orthographic projection into a given matrix
  71191. * @param left defines the viewport left coordinate
  71192. * @param right defines the viewport right coordinate
  71193. * @param bottom defines the viewport bottom coordinate
  71194. * @param top defines the viewport top coordinate
  71195. * @param znear defines the near clip plane
  71196. * @param zfar defines the far clip plane
  71197. * @param result defines the target matrix
  71198. */
  71199. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71200. /**
  71201. * Creates a left-handed perspective projection matrix
  71202. * @param width defines the viewport width
  71203. * @param height defines the viewport height
  71204. * @param znear defines the near clip plane
  71205. * @param zfar defines the far clip plane
  71206. * @returns a new matrix as a left-handed perspective projection matrix
  71207. */
  71208. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71209. /**
  71210. * Creates a left-handed perspective projection matrix
  71211. * @param fov defines the horizontal field of view
  71212. * @param aspect defines the aspect ratio
  71213. * @param znear defines the near clip plane
  71214. * @param zfar defines the far clip plane
  71215. * @returns a new matrix as a left-handed perspective projection matrix
  71216. */
  71217. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71218. /**
  71219. * Stores a left-handed perspective projection into a given matrix
  71220. * @param fov defines the horizontal field of view
  71221. * @param aspect defines the aspect ratio
  71222. * @param znear defines the near clip plane
  71223. * @param zfar defines the far clip plane
  71224. * @param result defines the target matrix
  71225. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71226. */
  71227. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71228. /**
  71229. * Creates a right-handed perspective projection matrix
  71230. * @param fov defines the horizontal field of view
  71231. * @param aspect defines the aspect ratio
  71232. * @param znear defines the near clip plane
  71233. * @param zfar defines the far clip plane
  71234. * @returns a new matrix as a right-handed perspective projection matrix
  71235. */
  71236. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71237. /**
  71238. * Stores a right-handed perspective projection into a given matrix
  71239. * @param fov defines the horizontal field of view
  71240. * @param aspect defines the aspect ratio
  71241. * @param znear defines the near clip plane
  71242. * @param zfar defines the far clip plane
  71243. * @param result defines the target matrix
  71244. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71245. */
  71246. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71247. /**
  71248. * Stores a perspective projection for WebVR info a given matrix
  71249. * @param fov defines the field of view
  71250. * @param znear defines the near clip plane
  71251. * @param zfar defines the far clip plane
  71252. * @param result defines the target matrix
  71253. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  71254. */
  71255. static PerspectiveFovWebVRToRef(fov: {
  71256. upDegrees: number;
  71257. downDegrees: number;
  71258. leftDegrees: number;
  71259. rightDegrees: number;
  71260. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  71261. /**
  71262. * Computes a complete transformation matrix
  71263. * @param viewport defines the viewport to use
  71264. * @param world defines the world matrix
  71265. * @param view defines the view matrix
  71266. * @param projection defines the projection matrix
  71267. * @param zmin defines the near clip plane
  71268. * @param zmax defines the far clip plane
  71269. * @returns the transformation matrix
  71270. */
  71271. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  71272. /**
  71273. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  71274. * @param matrix defines the matrix to use
  71275. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  71276. */
  71277. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  71278. /**
  71279. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  71280. * @param matrix defines the matrix to use
  71281. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  71282. */
  71283. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  71284. /**
  71285. * Compute the transpose of a given matrix
  71286. * @param matrix defines the matrix to transpose
  71287. * @returns the new matrix
  71288. */
  71289. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  71290. /**
  71291. * Compute the transpose of a matrix and store it in a target matrix
  71292. * @param matrix defines the matrix to transpose
  71293. * @param result defines the target matrix
  71294. */
  71295. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  71296. /**
  71297. * Computes a reflection matrix from a plane
  71298. * @param plane defines the reflection plane
  71299. * @returns a new matrix
  71300. */
  71301. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  71302. /**
  71303. * Computes a reflection matrix from a plane
  71304. * @param plane defines the reflection plane
  71305. * @param result defines the target matrix
  71306. */
  71307. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  71308. /**
  71309. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  71310. * @param xaxis defines the value of the 1st axis
  71311. * @param yaxis defines the value of the 2nd axis
  71312. * @param zaxis defines the value of the 3rd axis
  71313. * @param result defines the target matrix
  71314. */
  71315. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  71316. /**
  71317. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  71318. * @param quat defines the quaternion to use
  71319. * @param result defines the target matrix
  71320. */
  71321. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  71322. }
  71323. /**
  71324. * @hidden
  71325. */
  71326. export class TmpVectors {
  71327. static Vector2: Vector2[];
  71328. static Vector3: Vector3[];
  71329. static Vector4: Vector4[];
  71330. static Quaternion: Quaternion[];
  71331. static Matrix: Matrix[];
  71332. }
  71333. }
  71334. declare module BABYLON {
  71335. /**
  71336. * Defines potential orientation for back face culling
  71337. */
  71338. export enum Orientation {
  71339. /**
  71340. * Clockwise
  71341. */
  71342. CW = 0,
  71343. /** Counter clockwise */
  71344. CCW = 1
  71345. }
  71346. /** Class used to represent a Bezier curve */
  71347. export class BezierCurve {
  71348. /**
  71349. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71350. * @param t defines the time
  71351. * @param x1 defines the left coordinate on X axis
  71352. * @param y1 defines the left coordinate on Y axis
  71353. * @param x2 defines the right coordinate on X axis
  71354. * @param y2 defines the right coordinate on Y axis
  71355. * @returns the interpolated value
  71356. */
  71357. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71358. }
  71359. /**
  71360. * Defines angle representation
  71361. */
  71362. export class Angle {
  71363. private _radians;
  71364. /**
  71365. * Creates an Angle object of "radians" radians (float).
  71366. * @param radians the angle in radians
  71367. */
  71368. constructor(radians: number);
  71369. /**
  71370. * Get value in degrees
  71371. * @returns the Angle value in degrees (float)
  71372. */
  71373. degrees(): number;
  71374. /**
  71375. * Get value in radians
  71376. * @returns the Angle value in radians (float)
  71377. */
  71378. radians(): number;
  71379. /**
  71380. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71381. * @param a defines first vector
  71382. * @param b defines second vector
  71383. * @returns a new Angle
  71384. */
  71385. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71386. /**
  71387. * Gets a new Angle object from the given float in radians
  71388. * @param radians defines the angle value in radians
  71389. * @returns a new Angle
  71390. */
  71391. static FromRadians(radians: number): Angle;
  71392. /**
  71393. * Gets a new Angle object from the given float in degrees
  71394. * @param degrees defines the angle value in degrees
  71395. * @returns a new Angle
  71396. */
  71397. static FromDegrees(degrees: number): Angle;
  71398. }
  71399. /**
  71400. * This represents an arc in a 2d space.
  71401. */
  71402. export class Arc2 {
  71403. /** Defines the start point of the arc */
  71404. startPoint: Vector2;
  71405. /** Defines the mid point of the arc */
  71406. midPoint: Vector2;
  71407. /** Defines the end point of the arc */
  71408. endPoint: Vector2;
  71409. /**
  71410. * Defines the center point of the arc.
  71411. */
  71412. centerPoint: Vector2;
  71413. /**
  71414. * Defines the radius of the arc.
  71415. */
  71416. radius: number;
  71417. /**
  71418. * Defines the angle of the arc (from mid point to end point).
  71419. */
  71420. angle: Angle;
  71421. /**
  71422. * Defines the start angle of the arc (from start point to middle point).
  71423. */
  71424. startAngle: Angle;
  71425. /**
  71426. * Defines the orientation of the arc (clock wise/counter clock wise).
  71427. */
  71428. orientation: Orientation;
  71429. /**
  71430. * Creates an Arc object from the three given points : start, middle and end.
  71431. * @param startPoint Defines the start point of the arc
  71432. * @param midPoint Defines the midlle point of the arc
  71433. * @param endPoint Defines the end point of the arc
  71434. */
  71435. constructor(
  71436. /** Defines the start point of the arc */
  71437. startPoint: Vector2,
  71438. /** Defines the mid point of the arc */
  71439. midPoint: Vector2,
  71440. /** Defines the end point of the arc */
  71441. endPoint: Vector2);
  71442. }
  71443. /**
  71444. * Represents a 2D path made up of multiple 2D points
  71445. */
  71446. export class Path2 {
  71447. private _points;
  71448. private _length;
  71449. /**
  71450. * If the path start and end point are the same
  71451. */
  71452. closed: boolean;
  71453. /**
  71454. * Creates a Path2 object from the starting 2D coordinates x and y.
  71455. * @param x the starting points x value
  71456. * @param y the starting points y value
  71457. */
  71458. constructor(x: number, y: number);
  71459. /**
  71460. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71461. * @param x the added points x value
  71462. * @param y the added points y value
  71463. * @returns the updated Path2.
  71464. */
  71465. addLineTo(x: number, y: number): Path2;
  71466. /**
  71467. * 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.
  71468. * @param midX middle point x value
  71469. * @param midY middle point y value
  71470. * @param endX end point x value
  71471. * @param endY end point y value
  71472. * @param numberOfSegments (default: 36)
  71473. * @returns the updated Path2.
  71474. */
  71475. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71476. /**
  71477. * Closes the Path2.
  71478. * @returns the Path2.
  71479. */
  71480. close(): Path2;
  71481. /**
  71482. * Gets the sum of the distance between each sequential point in the path
  71483. * @returns the Path2 total length (float).
  71484. */
  71485. length(): number;
  71486. /**
  71487. * Gets the points which construct the path
  71488. * @returns the Path2 internal array of points.
  71489. */
  71490. getPoints(): Vector2[];
  71491. /**
  71492. * Retreives the point at the distance aways from the starting point
  71493. * @param normalizedLengthPosition the length along the path to retreive the point from
  71494. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71495. */
  71496. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71497. /**
  71498. * Creates a new path starting from an x and y position
  71499. * @param x starting x value
  71500. * @param y starting y value
  71501. * @returns a new Path2 starting at the coordinates (x, y).
  71502. */
  71503. static StartingAt(x: number, y: number): Path2;
  71504. }
  71505. /**
  71506. * Represents a 3D path made up of multiple 3D points
  71507. */
  71508. export class Path3D {
  71509. /**
  71510. * an array of Vector3, the curve axis of the Path3D
  71511. */
  71512. path: Vector3[];
  71513. private _curve;
  71514. private _distances;
  71515. private _tangents;
  71516. private _normals;
  71517. private _binormals;
  71518. private _raw;
  71519. /**
  71520. * new Path3D(path, normal, raw)
  71521. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71522. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71523. * @param path an array of Vector3, the curve axis of the Path3D
  71524. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71525. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71526. */
  71527. constructor(
  71528. /**
  71529. * an array of Vector3, the curve axis of the Path3D
  71530. */
  71531. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71532. /**
  71533. * Returns the Path3D array of successive Vector3 designing its curve.
  71534. * @returns the Path3D array of successive Vector3 designing its curve.
  71535. */
  71536. getCurve(): Vector3[];
  71537. /**
  71538. * Returns an array populated with tangent vectors on each Path3D curve point.
  71539. * @returns an array populated with tangent vectors on each Path3D curve point.
  71540. */
  71541. getTangents(): Vector3[];
  71542. /**
  71543. * Returns an array populated with normal vectors on each Path3D curve point.
  71544. * @returns an array populated with normal vectors on each Path3D curve point.
  71545. */
  71546. getNormals(): Vector3[];
  71547. /**
  71548. * Returns an array populated with binormal vectors on each Path3D curve point.
  71549. * @returns an array populated with binormal vectors on each Path3D curve point.
  71550. */
  71551. getBinormals(): Vector3[];
  71552. /**
  71553. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71554. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71555. */
  71556. getDistances(): number[];
  71557. /**
  71558. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71559. * @param path path which all values are copied into the curves points
  71560. * @param firstNormal which should be projected onto the curve
  71561. * @returns the same object updated.
  71562. */
  71563. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71564. private _compute;
  71565. private _getFirstNonNullVector;
  71566. private _getLastNonNullVector;
  71567. private _normalVector;
  71568. }
  71569. /**
  71570. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71571. * A Curve3 is designed from a series of successive Vector3.
  71572. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71573. */
  71574. export class Curve3 {
  71575. private _points;
  71576. private _length;
  71577. /**
  71578. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71579. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71580. * @param v1 (Vector3) the control point
  71581. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71582. * @param nbPoints (integer) the wanted number of points in the curve
  71583. * @returns the created Curve3
  71584. */
  71585. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71586. /**
  71587. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71588. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71589. * @param v1 (Vector3) the first control point
  71590. * @param v2 (Vector3) the second control point
  71591. * @param v3 (Vector3) the end point of the Cubic Bezier
  71592. * @param nbPoints (integer) the wanted number of points in the curve
  71593. * @returns the created Curve3
  71594. */
  71595. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71596. /**
  71597. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71598. * @param p1 (Vector3) the origin point of the Hermite Spline
  71599. * @param t1 (Vector3) the tangent vector at the origin point
  71600. * @param p2 (Vector3) the end point of the Hermite Spline
  71601. * @param t2 (Vector3) the tangent vector at the end point
  71602. * @param nbPoints (integer) the wanted number of points in the curve
  71603. * @returns the created Curve3
  71604. */
  71605. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71606. /**
  71607. * Returns a Curve3 object along a CatmullRom Spline curve :
  71608. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71609. * @param nbPoints (integer) the wanted number of points between each curve control points
  71610. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71611. * @returns the created Curve3
  71612. */
  71613. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71614. /**
  71615. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71616. * A Curve3 is designed from a series of successive Vector3.
  71617. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71618. * @param points points which make up the curve
  71619. */
  71620. constructor(points: Vector3[]);
  71621. /**
  71622. * @returns the Curve3 stored array of successive Vector3
  71623. */
  71624. getPoints(): Vector3[];
  71625. /**
  71626. * @returns the computed length (float) of the curve.
  71627. */
  71628. length(): number;
  71629. /**
  71630. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71631. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71632. * curveA and curveB keep unchanged.
  71633. * @param curve the curve to continue from this curve
  71634. * @returns the newly constructed curve
  71635. */
  71636. continue(curve: DeepImmutable<Curve3>): Curve3;
  71637. private _computeLength;
  71638. }
  71639. }
  71640. declare module BABYLON {
  71641. /**
  71642. * This represents the main contract an easing function should follow.
  71643. * Easing functions are used throughout the animation system.
  71644. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71645. */
  71646. export interface IEasingFunction {
  71647. /**
  71648. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71649. * of the easing function.
  71650. * The link below provides some of the most common examples of easing functions.
  71651. * @see https://easings.net/
  71652. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71653. * @returns the corresponding value on the curve defined by the easing function
  71654. */
  71655. ease(gradient: number): number;
  71656. }
  71657. /**
  71658. * Base class used for every default easing function.
  71659. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71660. */
  71661. export class EasingFunction implements IEasingFunction {
  71662. /**
  71663. * Interpolation follows the mathematical formula associated with the easing function.
  71664. */
  71665. static readonly EASINGMODE_EASEIN: number;
  71666. /**
  71667. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71668. */
  71669. static readonly EASINGMODE_EASEOUT: number;
  71670. /**
  71671. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71672. */
  71673. static readonly EASINGMODE_EASEINOUT: number;
  71674. private _easingMode;
  71675. /**
  71676. * Sets the easing mode of the current function.
  71677. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71678. */
  71679. setEasingMode(easingMode: number): void;
  71680. /**
  71681. * Gets the current easing mode.
  71682. * @returns the easing mode
  71683. */
  71684. getEasingMode(): number;
  71685. /**
  71686. * @hidden
  71687. */
  71688. easeInCore(gradient: number): number;
  71689. /**
  71690. * Given an input gradient between 0 and 1, this returns the corresponding value
  71691. * of the easing function.
  71692. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71693. * @returns the corresponding value on the curve defined by the easing function
  71694. */
  71695. ease(gradient: number): number;
  71696. }
  71697. /**
  71698. * Easing function with a circle shape (see link below).
  71699. * @see https://easings.net/#easeInCirc
  71700. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71701. */
  71702. export class CircleEase extends EasingFunction implements IEasingFunction {
  71703. /** @hidden */
  71704. easeInCore(gradient: number): number;
  71705. }
  71706. /**
  71707. * Easing function with a ease back shape (see link below).
  71708. * @see https://easings.net/#easeInBack
  71709. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71710. */
  71711. export class BackEase extends EasingFunction implements IEasingFunction {
  71712. /** Defines the amplitude of the function */
  71713. amplitude: number;
  71714. /**
  71715. * Instantiates a back ease easing
  71716. * @see https://easings.net/#easeInBack
  71717. * @param amplitude Defines the amplitude of the function
  71718. */
  71719. constructor(
  71720. /** Defines the amplitude of the function */
  71721. amplitude?: number);
  71722. /** @hidden */
  71723. easeInCore(gradient: number): number;
  71724. }
  71725. /**
  71726. * Easing function with a bouncing shape (see link below).
  71727. * @see https://easings.net/#easeInBounce
  71728. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71729. */
  71730. export class BounceEase extends EasingFunction implements IEasingFunction {
  71731. /** Defines the number of bounces */
  71732. bounces: number;
  71733. /** Defines the amplitude of the bounce */
  71734. bounciness: number;
  71735. /**
  71736. * Instantiates a bounce easing
  71737. * @see https://easings.net/#easeInBounce
  71738. * @param bounces Defines the number of bounces
  71739. * @param bounciness Defines the amplitude of the bounce
  71740. */
  71741. constructor(
  71742. /** Defines the number of bounces */
  71743. bounces?: number,
  71744. /** Defines the amplitude of the bounce */
  71745. bounciness?: number);
  71746. /** @hidden */
  71747. easeInCore(gradient: number): number;
  71748. }
  71749. /**
  71750. * Easing function with a power of 3 shape (see link below).
  71751. * @see https://easings.net/#easeInCubic
  71752. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71753. */
  71754. export class CubicEase extends EasingFunction implements IEasingFunction {
  71755. /** @hidden */
  71756. easeInCore(gradient: number): number;
  71757. }
  71758. /**
  71759. * Easing function with an elastic shape (see link below).
  71760. * @see https://easings.net/#easeInElastic
  71761. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71762. */
  71763. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71764. /** Defines the number of oscillations*/
  71765. oscillations: number;
  71766. /** Defines the amplitude of the oscillations*/
  71767. springiness: number;
  71768. /**
  71769. * Instantiates an elastic easing function
  71770. * @see https://easings.net/#easeInElastic
  71771. * @param oscillations Defines the number of oscillations
  71772. * @param springiness Defines the amplitude of the oscillations
  71773. */
  71774. constructor(
  71775. /** Defines the number of oscillations*/
  71776. oscillations?: number,
  71777. /** Defines the amplitude of the oscillations*/
  71778. springiness?: number);
  71779. /** @hidden */
  71780. easeInCore(gradient: number): number;
  71781. }
  71782. /**
  71783. * Easing function with an exponential shape (see link below).
  71784. * @see https://easings.net/#easeInExpo
  71785. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71786. */
  71787. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  71788. /** Defines the exponent of the function */
  71789. exponent: number;
  71790. /**
  71791. * Instantiates an exponential easing function
  71792. * @see https://easings.net/#easeInExpo
  71793. * @param exponent Defines the exponent of the function
  71794. */
  71795. constructor(
  71796. /** Defines the exponent of the function */
  71797. exponent?: number);
  71798. /** @hidden */
  71799. easeInCore(gradient: number): number;
  71800. }
  71801. /**
  71802. * Easing function with a power shape (see link below).
  71803. * @see https://easings.net/#easeInQuad
  71804. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71805. */
  71806. export class PowerEase extends EasingFunction implements IEasingFunction {
  71807. /** Defines the power of the function */
  71808. power: number;
  71809. /**
  71810. * Instantiates an power base easing function
  71811. * @see https://easings.net/#easeInQuad
  71812. * @param power Defines the power of the function
  71813. */
  71814. constructor(
  71815. /** Defines the power of the function */
  71816. power?: number);
  71817. /** @hidden */
  71818. easeInCore(gradient: number): number;
  71819. }
  71820. /**
  71821. * Easing function with a power of 2 shape (see link below).
  71822. * @see https://easings.net/#easeInQuad
  71823. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71824. */
  71825. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  71826. /** @hidden */
  71827. easeInCore(gradient: number): number;
  71828. }
  71829. /**
  71830. * Easing function with a power of 4 shape (see link below).
  71831. * @see https://easings.net/#easeInQuart
  71832. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71833. */
  71834. export class QuarticEase extends EasingFunction implements IEasingFunction {
  71835. /** @hidden */
  71836. easeInCore(gradient: number): number;
  71837. }
  71838. /**
  71839. * Easing function with a power of 5 shape (see link below).
  71840. * @see https://easings.net/#easeInQuint
  71841. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71842. */
  71843. export class QuinticEase extends EasingFunction implements IEasingFunction {
  71844. /** @hidden */
  71845. easeInCore(gradient: number): number;
  71846. }
  71847. /**
  71848. * Easing function with a sin shape (see link below).
  71849. * @see https://easings.net/#easeInSine
  71850. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71851. */
  71852. export class SineEase extends EasingFunction implements IEasingFunction {
  71853. /** @hidden */
  71854. easeInCore(gradient: number): number;
  71855. }
  71856. /**
  71857. * Easing function with a bezier shape (see link below).
  71858. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71859. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71860. */
  71861. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  71862. /** Defines the x component of the start tangent in the bezier curve */
  71863. x1: number;
  71864. /** Defines the y component of the start tangent in the bezier curve */
  71865. y1: number;
  71866. /** Defines the x component of the end tangent in the bezier curve */
  71867. x2: number;
  71868. /** Defines the y component of the end tangent in the bezier curve */
  71869. y2: number;
  71870. /**
  71871. * Instantiates a bezier function
  71872. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71873. * @param x1 Defines the x component of the start tangent in the bezier curve
  71874. * @param y1 Defines the y component of the start tangent in the bezier curve
  71875. * @param x2 Defines the x component of the end tangent in the bezier curve
  71876. * @param y2 Defines the y component of the end tangent in the bezier curve
  71877. */
  71878. constructor(
  71879. /** Defines the x component of the start tangent in the bezier curve */
  71880. x1?: number,
  71881. /** Defines the y component of the start tangent in the bezier curve */
  71882. y1?: number,
  71883. /** Defines the x component of the end tangent in the bezier curve */
  71884. x2?: number,
  71885. /** Defines the y component of the end tangent in the bezier curve */
  71886. y2?: number);
  71887. /** @hidden */
  71888. easeInCore(gradient: number): number;
  71889. }
  71890. }
  71891. declare module BABYLON {
  71892. /**
  71893. * Class used to hold a RBG color
  71894. */
  71895. export class Color3 {
  71896. /**
  71897. * Defines the red component (between 0 and 1, default is 0)
  71898. */
  71899. r: number;
  71900. /**
  71901. * Defines the green component (between 0 and 1, default is 0)
  71902. */
  71903. g: number;
  71904. /**
  71905. * Defines the blue component (between 0 and 1, default is 0)
  71906. */
  71907. b: number;
  71908. /**
  71909. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  71910. * @param r defines the red component (between 0 and 1, default is 0)
  71911. * @param g defines the green component (between 0 and 1, default is 0)
  71912. * @param b defines the blue component (between 0 and 1, default is 0)
  71913. */
  71914. constructor(
  71915. /**
  71916. * Defines the red component (between 0 and 1, default is 0)
  71917. */
  71918. r?: number,
  71919. /**
  71920. * Defines the green component (between 0 and 1, default is 0)
  71921. */
  71922. g?: number,
  71923. /**
  71924. * Defines the blue component (between 0 and 1, default is 0)
  71925. */
  71926. b?: number);
  71927. /**
  71928. * Creates a string with the Color3 current values
  71929. * @returns the string representation of the Color3 object
  71930. */
  71931. toString(): string;
  71932. /**
  71933. * Returns the string "Color3"
  71934. * @returns "Color3"
  71935. */
  71936. getClassName(): string;
  71937. /**
  71938. * Compute the Color3 hash code
  71939. * @returns an unique number that can be used to hash Color3 objects
  71940. */
  71941. getHashCode(): number;
  71942. /**
  71943. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  71944. * @param array defines the array where to store the r,g,b components
  71945. * @param index defines an optional index in the target array to define where to start storing values
  71946. * @returns the current Color3 object
  71947. */
  71948. toArray(array: FloatArray, index?: number): Color3;
  71949. /**
  71950. * Returns a new Color4 object from the current Color3 and the given alpha
  71951. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  71952. * @returns a new Color4 object
  71953. */
  71954. toColor4(alpha?: number): Color4;
  71955. /**
  71956. * Returns a new array populated with 3 numeric elements : red, green and blue values
  71957. * @returns the new array
  71958. */
  71959. asArray(): number[];
  71960. /**
  71961. * Returns the luminance value
  71962. * @returns a float value
  71963. */
  71964. toLuminance(): number;
  71965. /**
  71966. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  71967. * @param otherColor defines the second operand
  71968. * @returns the new Color3 object
  71969. */
  71970. multiply(otherColor: DeepImmutable<Color3>): Color3;
  71971. /**
  71972. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  71973. * @param otherColor defines the second operand
  71974. * @param result defines the Color3 object where to store the result
  71975. * @returns the current Color3
  71976. */
  71977. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  71978. /**
  71979. * Determines equality between Color3 objects
  71980. * @param otherColor defines the second operand
  71981. * @returns true if the rgb values are equal to the given ones
  71982. */
  71983. equals(otherColor: DeepImmutable<Color3>): boolean;
  71984. /**
  71985. * Determines equality between the current Color3 object and a set of r,b,g values
  71986. * @param r defines the red component to check
  71987. * @param g defines the green component to check
  71988. * @param b defines the blue component to check
  71989. * @returns true if the rgb values are equal to the given ones
  71990. */
  71991. equalsFloats(r: number, g: number, b: number): boolean;
  71992. /**
  71993. * Multiplies in place each rgb value by scale
  71994. * @param scale defines the scaling factor
  71995. * @returns the updated Color3
  71996. */
  71997. scale(scale: number): Color3;
  71998. /**
  71999. * Multiplies the rgb values by scale and stores the result into "result"
  72000. * @param scale defines the scaling factor
  72001. * @param result defines the Color3 object where to store the result
  72002. * @returns the unmodified current Color3
  72003. */
  72004. scaleToRef(scale: number, result: Color3): Color3;
  72005. /**
  72006. * Scale the current Color3 values by a factor and add the result to a given Color3
  72007. * @param scale defines the scale factor
  72008. * @param result defines color to store the result into
  72009. * @returns the unmodified current Color3
  72010. */
  72011. scaleAndAddToRef(scale: number, result: Color3): Color3;
  72012. /**
  72013. * Clamps the rgb values by the min and max values and stores the result into "result"
  72014. * @param min defines minimum clamping value (default is 0)
  72015. * @param max defines maximum clamping value (default is 1)
  72016. * @param result defines color to store the result into
  72017. * @returns the original Color3
  72018. */
  72019. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  72020. /**
  72021. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  72022. * @param otherColor defines the second operand
  72023. * @returns the new Color3
  72024. */
  72025. add(otherColor: DeepImmutable<Color3>): Color3;
  72026. /**
  72027. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  72028. * @param otherColor defines the second operand
  72029. * @param result defines Color3 object to store the result into
  72030. * @returns the unmodified current Color3
  72031. */
  72032. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72033. /**
  72034. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  72035. * @param otherColor defines the second operand
  72036. * @returns the new Color3
  72037. */
  72038. subtract(otherColor: DeepImmutable<Color3>): Color3;
  72039. /**
  72040. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  72041. * @param otherColor defines the second operand
  72042. * @param result defines Color3 object to store the result into
  72043. * @returns the unmodified current Color3
  72044. */
  72045. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72046. /**
  72047. * Copy the current object
  72048. * @returns a new Color3 copied the current one
  72049. */
  72050. clone(): Color3;
  72051. /**
  72052. * Copies the rgb values from the source in the current Color3
  72053. * @param source defines the source Color3 object
  72054. * @returns the updated Color3 object
  72055. */
  72056. copyFrom(source: DeepImmutable<Color3>): Color3;
  72057. /**
  72058. * Updates the Color3 rgb values from the given floats
  72059. * @param r defines the red component to read from
  72060. * @param g defines the green component to read from
  72061. * @param b defines the blue component to read from
  72062. * @returns the current Color3 object
  72063. */
  72064. copyFromFloats(r: number, g: number, b: number): Color3;
  72065. /**
  72066. * Updates the Color3 rgb values from the given floats
  72067. * @param r defines the red component to read from
  72068. * @param g defines the green component to read from
  72069. * @param b defines the blue component to read from
  72070. * @returns the current Color3 object
  72071. */
  72072. set(r: number, g: number, b: number): Color3;
  72073. /**
  72074. * Compute the Color3 hexadecimal code as a string
  72075. * @returns a string containing the hexadecimal representation of the Color3 object
  72076. */
  72077. toHexString(): string;
  72078. /**
  72079. * Computes a new Color3 converted from the current one to linear space
  72080. * @returns a new Color3 object
  72081. */
  72082. toLinearSpace(): Color3;
  72083. /**
  72084. * Converts current color in rgb space to HSV values
  72085. * @returns a new color3 representing the HSV values
  72086. */
  72087. toHSV(): Color3;
  72088. /**
  72089. * Converts current color in rgb space to HSV values
  72090. * @param result defines the Color3 where to store the HSV values
  72091. */
  72092. toHSVToRef(result: Color3): void;
  72093. /**
  72094. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  72095. * @param convertedColor defines the Color3 object where to store the linear space version
  72096. * @returns the unmodified Color3
  72097. */
  72098. toLinearSpaceToRef(convertedColor: Color3): Color3;
  72099. /**
  72100. * Computes a new Color3 converted from the current one to gamma space
  72101. * @returns a new Color3 object
  72102. */
  72103. toGammaSpace(): Color3;
  72104. /**
  72105. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  72106. * @param convertedColor defines the Color3 object where to store the gamma space version
  72107. * @returns the unmodified Color3
  72108. */
  72109. toGammaSpaceToRef(convertedColor: Color3): Color3;
  72110. private static _BlackReadOnly;
  72111. /**
  72112. * Convert Hue, saturation and value to a Color3 (RGB)
  72113. * @param hue defines the hue
  72114. * @param saturation defines the saturation
  72115. * @param value defines the value
  72116. * @param result defines the Color3 where to store the RGB values
  72117. */
  72118. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  72119. /**
  72120. * Creates a new Color3 from the string containing valid hexadecimal values
  72121. * @param hex defines a string containing valid hexadecimal values
  72122. * @returns a new Color3 object
  72123. */
  72124. static FromHexString(hex: string): Color3;
  72125. /**
  72126. * Creates a new Color3 from the starting index of the given array
  72127. * @param array defines the source array
  72128. * @param offset defines an offset in the source array
  72129. * @returns a new Color3 object
  72130. */
  72131. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  72132. /**
  72133. * Creates a new Color3 from integer values (< 256)
  72134. * @param r defines the red component to read from (value between 0 and 255)
  72135. * @param g defines the green component to read from (value between 0 and 255)
  72136. * @param b defines the blue component to read from (value between 0 and 255)
  72137. * @returns a new Color3 object
  72138. */
  72139. static FromInts(r: number, g: number, b: number): Color3;
  72140. /**
  72141. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72142. * @param start defines the start Color3 value
  72143. * @param end defines the end Color3 value
  72144. * @param amount defines the gradient value between start and end
  72145. * @returns a new Color3 object
  72146. */
  72147. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  72148. /**
  72149. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72150. * @param left defines the start value
  72151. * @param right defines the end value
  72152. * @param amount defines the gradient factor
  72153. * @param result defines the Color3 object where to store the result
  72154. */
  72155. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  72156. /**
  72157. * Returns a Color3 value containing a red color
  72158. * @returns a new Color3 object
  72159. */
  72160. static Red(): Color3;
  72161. /**
  72162. * Returns a Color3 value containing a green color
  72163. * @returns a new Color3 object
  72164. */
  72165. static Green(): Color3;
  72166. /**
  72167. * Returns a Color3 value containing a blue color
  72168. * @returns a new Color3 object
  72169. */
  72170. static Blue(): Color3;
  72171. /**
  72172. * Returns a Color3 value containing a black color
  72173. * @returns a new Color3 object
  72174. */
  72175. static Black(): Color3;
  72176. /**
  72177. * Gets a Color3 value containing a black color that must not be updated
  72178. */
  72179. static readonly BlackReadOnly: DeepImmutable<Color3>;
  72180. /**
  72181. * Returns a Color3 value containing a white color
  72182. * @returns a new Color3 object
  72183. */
  72184. static White(): Color3;
  72185. /**
  72186. * Returns a Color3 value containing a purple color
  72187. * @returns a new Color3 object
  72188. */
  72189. static Purple(): Color3;
  72190. /**
  72191. * Returns a Color3 value containing a magenta color
  72192. * @returns a new Color3 object
  72193. */
  72194. static Magenta(): Color3;
  72195. /**
  72196. * Returns a Color3 value containing a yellow color
  72197. * @returns a new Color3 object
  72198. */
  72199. static Yellow(): Color3;
  72200. /**
  72201. * Returns a Color3 value containing a gray color
  72202. * @returns a new Color3 object
  72203. */
  72204. static Gray(): Color3;
  72205. /**
  72206. * Returns a Color3 value containing a teal color
  72207. * @returns a new Color3 object
  72208. */
  72209. static Teal(): Color3;
  72210. /**
  72211. * Returns a Color3 value containing a random color
  72212. * @returns a new Color3 object
  72213. */
  72214. static Random(): Color3;
  72215. }
  72216. /**
  72217. * Class used to hold a RBGA color
  72218. */
  72219. export class Color4 {
  72220. /**
  72221. * Defines the red component (between 0 and 1, default is 0)
  72222. */
  72223. r: number;
  72224. /**
  72225. * Defines the green component (between 0 and 1, default is 0)
  72226. */
  72227. g: number;
  72228. /**
  72229. * Defines the blue component (between 0 and 1, default is 0)
  72230. */
  72231. b: number;
  72232. /**
  72233. * Defines the alpha component (between 0 and 1, default is 1)
  72234. */
  72235. a: number;
  72236. /**
  72237. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  72238. * @param r defines the red component (between 0 and 1, default is 0)
  72239. * @param g defines the green component (between 0 and 1, default is 0)
  72240. * @param b defines the blue component (between 0 and 1, default is 0)
  72241. * @param a defines the alpha component (between 0 and 1, default is 1)
  72242. */
  72243. constructor(
  72244. /**
  72245. * Defines the red component (between 0 and 1, default is 0)
  72246. */
  72247. r?: number,
  72248. /**
  72249. * Defines the green component (between 0 and 1, default is 0)
  72250. */
  72251. g?: number,
  72252. /**
  72253. * Defines the blue component (between 0 and 1, default is 0)
  72254. */
  72255. b?: number,
  72256. /**
  72257. * Defines the alpha component (between 0 and 1, default is 1)
  72258. */
  72259. a?: number);
  72260. /**
  72261. * Adds in place the given Color4 values to the current Color4 object
  72262. * @param right defines the second operand
  72263. * @returns the current updated Color4 object
  72264. */
  72265. addInPlace(right: DeepImmutable<Color4>): Color4;
  72266. /**
  72267. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  72268. * @returns the new array
  72269. */
  72270. asArray(): number[];
  72271. /**
  72272. * Stores from the starting index in the given array the Color4 successive values
  72273. * @param array defines the array where to store the r,g,b components
  72274. * @param index defines an optional index in the target array to define where to start storing values
  72275. * @returns the current Color4 object
  72276. */
  72277. toArray(array: number[], index?: number): Color4;
  72278. /**
  72279. * Determines equality between Color4 objects
  72280. * @param otherColor defines the second operand
  72281. * @returns true if the rgba values are equal to the given ones
  72282. */
  72283. equals(otherColor: DeepImmutable<Color4>): boolean;
  72284. /**
  72285. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  72286. * @param right defines the second operand
  72287. * @returns a new Color4 object
  72288. */
  72289. add(right: DeepImmutable<Color4>): Color4;
  72290. /**
  72291. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  72292. * @param right defines the second operand
  72293. * @returns a new Color4 object
  72294. */
  72295. subtract(right: DeepImmutable<Color4>): Color4;
  72296. /**
  72297. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  72298. * @param right defines the second operand
  72299. * @param result defines the Color4 object where to store the result
  72300. * @returns the current Color4 object
  72301. */
  72302. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  72303. /**
  72304. * Creates a new Color4 with the current Color4 values multiplied by scale
  72305. * @param scale defines the scaling factor to apply
  72306. * @returns a new Color4 object
  72307. */
  72308. scale(scale: number): Color4;
  72309. /**
  72310. * Multiplies the current Color4 values by scale and stores the result in "result"
  72311. * @param scale defines the scaling factor to apply
  72312. * @param result defines the Color4 object where to store the result
  72313. * @returns the current unmodified Color4
  72314. */
  72315. scaleToRef(scale: number, result: Color4): Color4;
  72316. /**
  72317. * Scale the current Color4 values by a factor and add the result to a given Color4
  72318. * @param scale defines the scale factor
  72319. * @param result defines the Color4 object where to store the result
  72320. * @returns the unmodified current Color4
  72321. */
  72322. scaleAndAddToRef(scale: number, result: Color4): Color4;
  72323. /**
  72324. * Clamps the rgb values by the min and max values and stores the result into "result"
  72325. * @param min defines minimum clamping value (default is 0)
  72326. * @param max defines maximum clamping value (default is 1)
  72327. * @param result defines color to store the result into.
  72328. * @returns the cuurent Color4
  72329. */
  72330. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  72331. /**
  72332. * Multipy an Color4 value by another and return a new Color4 object
  72333. * @param color defines the Color4 value to multiply by
  72334. * @returns a new Color4 object
  72335. */
  72336. multiply(color: Color4): Color4;
  72337. /**
  72338. * Multipy a Color4 value by another and push the result in a reference value
  72339. * @param color defines the Color4 value to multiply by
  72340. * @param result defines the Color4 to fill the result in
  72341. * @returns the result Color4
  72342. */
  72343. multiplyToRef(color: Color4, result: Color4): Color4;
  72344. /**
  72345. * Creates a string with the Color4 current values
  72346. * @returns the string representation of the Color4 object
  72347. */
  72348. toString(): string;
  72349. /**
  72350. * Returns the string "Color4"
  72351. * @returns "Color4"
  72352. */
  72353. getClassName(): string;
  72354. /**
  72355. * Compute the Color4 hash code
  72356. * @returns an unique number that can be used to hash Color4 objects
  72357. */
  72358. getHashCode(): number;
  72359. /**
  72360. * Creates a new Color4 copied from the current one
  72361. * @returns a new Color4 object
  72362. */
  72363. clone(): Color4;
  72364. /**
  72365. * Copies the given Color4 values into the current one
  72366. * @param source defines the source Color4 object
  72367. * @returns the current updated Color4 object
  72368. */
  72369. copyFrom(source: Color4): Color4;
  72370. /**
  72371. * Copies the given float values into the current one
  72372. * @param r defines the red component to read from
  72373. * @param g defines the green component to read from
  72374. * @param b defines the blue component to read from
  72375. * @param a defines the alpha component to read from
  72376. * @returns the current updated Color4 object
  72377. */
  72378. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  72379. /**
  72380. * Copies the given float values into the current one
  72381. * @param r defines the red component to read from
  72382. * @param g defines the green component to read from
  72383. * @param b defines the blue component to read from
  72384. * @param a defines the alpha component to read from
  72385. * @returns the current updated Color4 object
  72386. */
  72387. set(r: number, g: number, b: number, a: number): Color4;
  72388. /**
  72389. * Compute the Color4 hexadecimal code as a string
  72390. * @returns a string containing the hexadecimal representation of the Color4 object
  72391. */
  72392. toHexString(): string;
  72393. /**
  72394. * Computes a new Color4 converted from the current one to linear space
  72395. * @returns a new Color4 object
  72396. */
  72397. toLinearSpace(): Color4;
  72398. /**
  72399. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  72400. * @param convertedColor defines the Color4 object where to store the linear space version
  72401. * @returns the unmodified Color4
  72402. */
  72403. toLinearSpaceToRef(convertedColor: Color4): Color4;
  72404. /**
  72405. * Computes a new Color4 converted from the current one to gamma space
  72406. * @returns a new Color4 object
  72407. */
  72408. toGammaSpace(): Color4;
  72409. /**
  72410. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  72411. * @param convertedColor defines the Color4 object where to store the gamma space version
  72412. * @returns the unmodified Color4
  72413. */
  72414. toGammaSpaceToRef(convertedColor: Color4): Color4;
  72415. /**
  72416. * Creates a new Color4 from the string containing valid hexadecimal values
  72417. * @param hex defines a string containing valid hexadecimal values
  72418. * @returns a new Color4 object
  72419. */
  72420. static FromHexString(hex: string): Color4;
  72421. /**
  72422. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72423. * @param left defines the start value
  72424. * @param right defines the end value
  72425. * @param amount defines the gradient factor
  72426. * @returns a new Color4 object
  72427. */
  72428. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  72429. /**
  72430. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72431. * @param left defines the start value
  72432. * @param right defines the end value
  72433. * @param amount defines the gradient factor
  72434. * @param result defines the Color4 object where to store data
  72435. */
  72436. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  72437. /**
  72438. * Creates a new Color4 from a Color3 and an alpha value
  72439. * @param color3 defines the source Color3 to read from
  72440. * @param alpha defines the alpha component (1.0 by default)
  72441. * @returns a new Color4 object
  72442. */
  72443. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  72444. /**
  72445. * Creates a new Color4 from the starting index element of the given array
  72446. * @param array defines the source array to read from
  72447. * @param offset defines the offset in the source array
  72448. * @returns a new Color4 object
  72449. */
  72450. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  72451. /**
  72452. * Creates a new Color3 from integer values (< 256)
  72453. * @param r defines the red component to read from (value between 0 and 255)
  72454. * @param g defines the green component to read from (value between 0 and 255)
  72455. * @param b defines the blue component to read from (value between 0 and 255)
  72456. * @param a defines the alpha component to read from (value between 0 and 255)
  72457. * @returns a new Color3 object
  72458. */
  72459. static FromInts(r: number, g: number, b: number, a: number): Color4;
  72460. /**
  72461. * Check the content of a given array and convert it to an array containing RGBA data
  72462. * If the original array was already containing count * 4 values then it is returned directly
  72463. * @param colors defines the array to check
  72464. * @param count defines the number of RGBA data to expect
  72465. * @returns an array containing count * 4 values (RGBA)
  72466. */
  72467. static CheckColors4(colors: number[], count: number): number[];
  72468. }
  72469. /**
  72470. * @hidden
  72471. */
  72472. export class TmpColors {
  72473. static Color3: Color3[];
  72474. static Color4: Color4[];
  72475. }
  72476. }
  72477. declare module BABYLON {
  72478. /**
  72479. * Defines an interface which represents an animation key frame
  72480. */
  72481. export interface IAnimationKey {
  72482. /**
  72483. * Frame of the key frame
  72484. */
  72485. frame: number;
  72486. /**
  72487. * Value at the specifies key frame
  72488. */
  72489. value: any;
  72490. /**
  72491. * The input tangent for the cubic hermite spline
  72492. */
  72493. inTangent?: any;
  72494. /**
  72495. * The output tangent for the cubic hermite spline
  72496. */
  72497. outTangent?: any;
  72498. /**
  72499. * The animation interpolation type
  72500. */
  72501. interpolation?: AnimationKeyInterpolation;
  72502. }
  72503. /**
  72504. * Enum for the animation key frame interpolation type
  72505. */
  72506. export enum AnimationKeyInterpolation {
  72507. /**
  72508. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72509. */
  72510. STEP = 1
  72511. }
  72512. }
  72513. declare module BABYLON {
  72514. /**
  72515. * Represents the range of an animation
  72516. */
  72517. export class AnimationRange {
  72518. /**The name of the animation range**/
  72519. name: string;
  72520. /**The starting frame of the animation */
  72521. from: number;
  72522. /**The ending frame of the animation*/
  72523. to: number;
  72524. /**
  72525. * Initializes the range of an animation
  72526. * @param name The name of the animation range
  72527. * @param from The starting frame of the animation
  72528. * @param to The ending frame of the animation
  72529. */
  72530. constructor(
  72531. /**The name of the animation range**/
  72532. name: string,
  72533. /**The starting frame of the animation */
  72534. from: number,
  72535. /**The ending frame of the animation*/
  72536. to: number);
  72537. /**
  72538. * Makes a copy of the animation range
  72539. * @returns A copy of the animation range
  72540. */
  72541. clone(): AnimationRange;
  72542. }
  72543. }
  72544. declare module BABYLON {
  72545. /**
  72546. * Composed of a frame, and an action function
  72547. */
  72548. export class AnimationEvent {
  72549. /** The frame for which the event is triggered **/
  72550. frame: number;
  72551. /** The event to perform when triggered **/
  72552. action: (currentFrame: number) => void;
  72553. /** Specifies if the event should be triggered only once**/
  72554. onlyOnce?: boolean | undefined;
  72555. /**
  72556. * Specifies if the animation event is done
  72557. */
  72558. isDone: boolean;
  72559. /**
  72560. * Initializes the animation event
  72561. * @param frame The frame for which the event is triggered
  72562. * @param action The event to perform when triggered
  72563. * @param onlyOnce Specifies if the event should be triggered only once
  72564. */
  72565. constructor(
  72566. /** The frame for which the event is triggered **/
  72567. frame: number,
  72568. /** The event to perform when triggered **/
  72569. action: (currentFrame: number) => void,
  72570. /** Specifies if the event should be triggered only once**/
  72571. onlyOnce?: boolean | undefined);
  72572. /** @hidden */
  72573. _clone(): AnimationEvent;
  72574. }
  72575. }
  72576. declare module BABYLON {
  72577. /**
  72578. * Interface used to define a behavior
  72579. */
  72580. export interface Behavior<T> {
  72581. /** gets or sets behavior's name */
  72582. name: string;
  72583. /**
  72584. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72585. */
  72586. init(): void;
  72587. /**
  72588. * Called when the behavior is attached to a target
  72589. * @param target defines the target where the behavior is attached to
  72590. */
  72591. attach(target: T): void;
  72592. /**
  72593. * Called when the behavior is detached from its target
  72594. */
  72595. detach(): void;
  72596. }
  72597. /**
  72598. * Interface implemented by classes supporting behaviors
  72599. */
  72600. export interface IBehaviorAware<T> {
  72601. /**
  72602. * Attach a behavior
  72603. * @param behavior defines the behavior to attach
  72604. * @returns the current host
  72605. */
  72606. addBehavior(behavior: Behavior<T>): T;
  72607. /**
  72608. * Remove a behavior from the current object
  72609. * @param behavior defines the behavior to detach
  72610. * @returns the current host
  72611. */
  72612. removeBehavior(behavior: Behavior<T>): T;
  72613. /**
  72614. * Gets a behavior using its name to search
  72615. * @param name defines the name to search
  72616. * @returns the behavior or null if not found
  72617. */
  72618. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72619. }
  72620. }
  72621. declare module BABYLON {
  72622. /**
  72623. * Defines an array and its length.
  72624. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72625. */
  72626. export interface ISmartArrayLike<T> {
  72627. /**
  72628. * The data of the array.
  72629. */
  72630. data: Array<T>;
  72631. /**
  72632. * The active length of the array.
  72633. */
  72634. length: number;
  72635. }
  72636. /**
  72637. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72638. */
  72639. export class SmartArray<T> implements ISmartArrayLike<T> {
  72640. /**
  72641. * The full set of data from the array.
  72642. */
  72643. data: Array<T>;
  72644. /**
  72645. * The active length of the array.
  72646. */
  72647. length: number;
  72648. protected _id: number;
  72649. /**
  72650. * Instantiates a Smart Array.
  72651. * @param capacity defines the default capacity of the array.
  72652. */
  72653. constructor(capacity: number);
  72654. /**
  72655. * Pushes a value at the end of the active data.
  72656. * @param value defines the object to push in the array.
  72657. */
  72658. push(value: T): void;
  72659. /**
  72660. * Iterates over the active data and apply the lambda to them.
  72661. * @param func defines the action to apply on each value.
  72662. */
  72663. forEach(func: (content: T) => void): void;
  72664. /**
  72665. * Sorts the full sets of data.
  72666. * @param compareFn defines the comparison function to apply.
  72667. */
  72668. sort(compareFn: (a: T, b: T) => number): void;
  72669. /**
  72670. * Resets the active data to an empty array.
  72671. */
  72672. reset(): void;
  72673. /**
  72674. * Releases all the data from the array as well as the array.
  72675. */
  72676. dispose(): void;
  72677. /**
  72678. * Concats the active data with a given array.
  72679. * @param array defines the data to concatenate with.
  72680. */
  72681. concat(array: any): void;
  72682. /**
  72683. * Returns the position of a value in the active data.
  72684. * @param value defines the value to find the index for
  72685. * @returns the index if found in the active data otherwise -1
  72686. */
  72687. indexOf(value: T): number;
  72688. /**
  72689. * Returns whether an element is part of the active data.
  72690. * @param value defines the value to look for
  72691. * @returns true if found in the active data otherwise false
  72692. */
  72693. contains(value: T): boolean;
  72694. private static _GlobalId;
  72695. }
  72696. /**
  72697. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72698. * The data in this array can only be present once
  72699. */
  72700. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72701. private _duplicateId;
  72702. /**
  72703. * Pushes a value at the end of the active data.
  72704. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72705. * @param value defines the object to push in the array.
  72706. */
  72707. push(value: T): void;
  72708. /**
  72709. * Pushes a value at the end of the active data.
  72710. * If the data is already present, it won t be added again
  72711. * @param value defines the object to push in the array.
  72712. * @returns true if added false if it was already present
  72713. */
  72714. pushNoDuplicate(value: T): boolean;
  72715. /**
  72716. * Resets the active data to an empty array.
  72717. */
  72718. reset(): void;
  72719. /**
  72720. * Concats the active data with a given array.
  72721. * This ensures no dupplicate will be present in the result.
  72722. * @param array defines the data to concatenate with.
  72723. */
  72724. concatWithNoDuplicate(array: any): void;
  72725. }
  72726. }
  72727. declare module BABYLON {
  72728. /**
  72729. * @ignore
  72730. * This is a list of all the different input types that are available in the application.
  72731. * Fo instance: ArcRotateCameraGamepadInput...
  72732. */
  72733. export var CameraInputTypes: {};
  72734. /**
  72735. * This is the contract to implement in order to create a new input class.
  72736. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72737. */
  72738. export interface ICameraInput<TCamera extends Camera> {
  72739. /**
  72740. * Defines the camera the input is attached to.
  72741. */
  72742. camera: Nullable<TCamera>;
  72743. /**
  72744. * Gets the class name of the current intput.
  72745. * @returns the class name
  72746. */
  72747. getClassName(): string;
  72748. /**
  72749. * Get the friendly name associated with the input class.
  72750. * @returns the input friendly name
  72751. */
  72752. getSimpleName(): string;
  72753. /**
  72754. * Attach the input controls to a specific dom element to get the input from.
  72755. * @param element Defines the element the controls should be listened from
  72756. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72757. */
  72758. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72759. /**
  72760. * Detach the current controls from the specified dom element.
  72761. * @param element Defines the element to stop listening the inputs from
  72762. */
  72763. detachControl(element: Nullable<HTMLElement>): void;
  72764. /**
  72765. * Update the current camera state depending on the inputs that have been used this frame.
  72766. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72767. */
  72768. checkInputs?: () => void;
  72769. }
  72770. /**
  72771. * Represents a map of input types to input instance or input index to input instance.
  72772. */
  72773. export interface CameraInputsMap<TCamera extends Camera> {
  72774. /**
  72775. * Accessor to the input by input type.
  72776. */
  72777. [name: string]: ICameraInput<TCamera>;
  72778. /**
  72779. * Accessor to the input by input index.
  72780. */
  72781. [idx: number]: ICameraInput<TCamera>;
  72782. }
  72783. /**
  72784. * This represents the input manager used within a camera.
  72785. * It helps dealing with all the different kind of input attached to a camera.
  72786. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72787. */
  72788. export class CameraInputsManager<TCamera extends Camera> {
  72789. /**
  72790. * Defines the list of inputs attahed to the camera.
  72791. */
  72792. attached: CameraInputsMap<TCamera>;
  72793. /**
  72794. * Defines the dom element the camera is collecting inputs from.
  72795. * This is null if the controls have not been attached.
  72796. */
  72797. attachedElement: Nullable<HTMLElement>;
  72798. /**
  72799. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72800. */
  72801. noPreventDefault: boolean;
  72802. /**
  72803. * Defined the camera the input manager belongs to.
  72804. */
  72805. camera: TCamera;
  72806. /**
  72807. * Update the current camera state depending on the inputs that have been used this frame.
  72808. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72809. */
  72810. checkInputs: () => void;
  72811. /**
  72812. * Instantiate a new Camera Input Manager.
  72813. * @param camera Defines the camera the input manager blongs to
  72814. */
  72815. constructor(camera: TCamera);
  72816. /**
  72817. * Add an input method to a camera
  72818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72819. * @param input camera input method
  72820. */
  72821. add(input: ICameraInput<TCamera>): void;
  72822. /**
  72823. * Remove a specific input method from a camera
  72824. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72825. * @param inputToRemove camera input method
  72826. */
  72827. remove(inputToRemove: ICameraInput<TCamera>): void;
  72828. /**
  72829. * Remove a specific input type from a camera
  72830. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72831. * @param inputType the type of the input to remove
  72832. */
  72833. removeByType(inputType: string): void;
  72834. private _addCheckInputs;
  72835. /**
  72836. * Attach the input controls to the currently attached dom element to listen the events from.
  72837. * @param input Defines the input to attach
  72838. */
  72839. attachInput(input: ICameraInput<TCamera>): void;
  72840. /**
  72841. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72842. * @param element Defines the dom element to collect the events from
  72843. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72844. */
  72845. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72846. /**
  72847. * Detach the current manager inputs controls from a specific dom element.
  72848. * @param element Defines the dom element to collect the events from
  72849. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72850. */
  72851. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72852. /**
  72853. * Rebuild the dynamic inputCheck function from the current list of
  72854. * defined inputs in the manager.
  72855. */
  72856. rebuildInputCheck(): void;
  72857. /**
  72858. * Remove all attached input methods from a camera
  72859. */
  72860. clear(): void;
  72861. /**
  72862. * Serialize the current input manager attached to a camera.
  72863. * This ensures than once parsed,
  72864. * the input associated to the camera will be identical to the current ones
  72865. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72866. */
  72867. serialize(serializedCamera: any): void;
  72868. /**
  72869. * Parses an input manager serialized JSON to restore the previous list of inputs
  72870. * and states associated to a camera.
  72871. * @param parsedCamera Defines the JSON to parse
  72872. */
  72873. parse(parsedCamera: any): void;
  72874. }
  72875. }
  72876. declare module BABYLON {
  72877. /**
  72878. * Class used to store data that will be store in GPU memory
  72879. */
  72880. export class Buffer {
  72881. private _engine;
  72882. private _buffer;
  72883. /** @hidden */
  72884. _data: Nullable<DataArray>;
  72885. private _updatable;
  72886. private _instanced;
  72887. /**
  72888. * Gets the byte stride.
  72889. */
  72890. readonly byteStride: number;
  72891. /**
  72892. * Constructor
  72893. * @param engine the engine
  72894. * @param data the data to use for this buffer
  72895. * @param updatable whether the data is updatable
  72896. * @param stride the stride (optional)
  72897. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72898. * @param instanced whether the buffer is instanced (optional)
  72899. * @param useBytes set to true if the stride in in bytes (optional)
  72900. */
  72901. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  72902. /**
  72903. * Create a new VertexBuffer based on the current buffer
  72904. * @param kind defines the vertex buffer kind (position, normal, etc.)
  72905. * @param offset defines offset in the buffer (0 by default)
  72906. * @param size defines the size in floats of attributes (position is 3 for instance)
  72907. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  72908. * @param instanced defines if the vertex buffer contains indexed data
  72909. * @param useBytes defines if the offset and stride are in bytes
  72910. * @returns the new vertex buffer
  72911. */
  72912. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  72913. /**
  72914. * Gets a boolean indicating if the Buffer is updatable?
  72915. * @returns true if the buffer is updatable
  72916. */
  72917. isUpdatable(): boolean;
  72918. /**
  72919. * Gets current buffer's data
  72920. * @returns a DataArray or null
  72921. */
  72922. getData(): Nullable<DataArray>;
  72923. /**
  72924. * Gets underlying native buffer
  72925. * @returns underlying native buffer
  72926. */
  72927. getBuffer(): Nullable<DataBuffer>;
  72928. /**
  72929. * Gets the stride in float32 units (i.e. byte stride / 4).
  72930. * May not be an integer if the byte stride is not divisible by 4.
  72931. * DEPRECATED. Use byteStride instead.
  72932. * @returns the stride in float32 units
  72933. */
  72934. getStrideSize(): number;
  72935. /**
  72936. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  72937. * @param data defines the data to store
  72938. */
  72939. create(data?: Nullable<DataArray>): void;
  72940. /** @hidden */
  72941. _rebuild(): void;
  72942. /**
  72943. * Update current buffer data
  72944. * @param data defines the data to store
  72945. */
  72946. update(data: DataArray): void;
  72947. /**
  72948. * Updates the data directly.
  72949. * @param data the new data
  72950. * @param offset the new offset
  72951. * @param vertexCount the vertex count (optional)
  72952. * @param useBytes set to true if the offset is in bytes
  72953. */
  72954. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  72955. /**
  72956. * Release all resources
  72957. */
  72958. dispose(): void;
  72959. }
  72960. /**
  72961. * Specialized buffer used to store vertex data
  72962. */
  72963. export class VertexBuffer {
  72964. /** @hidden */
  72965. _buffer: Buffer;
  72966. private _kind;
  72967. private _size;
  72968. private _ownsBuffer;
  72969. private _instanced;
  72970. private _instanceDivisor;
  72971. /**
  72972. * The byte type.
  72973. */
  72974. static readonly BYTE: number;
  72975. /**
  72976. * The unsigned byte type.
  72977. */
  72978. static readonly UNSIGNED_BYTE: number;
  72979. /**
  72980. * The short type.
  72981. */
  72982. static readonly SHORT: number;
  72983. /**
  72984. * The unsigned short type.
  72985. */
  72986. static readonly UNSIGNED_SHORT: number;
  72987. /**
  72988. * The integer type.
  72989. */
  72990. static readonly INT: number;
  72991. /**
  72992. * The unsigned integer type.
  72993. */
  72994. static readonly UNSIGNED_INT: number;
  72995. /**
  72996. * The float type.
  72997. */
  72998. static readonly FLOAT: number;
  72999. /**
  73000. * Gets or sets the instance divisor when in instanced mode
  73001. */
  73002. instanceDivisor: number;
  73003. /**
  73004. * Gets the byte stride.
  73005. */
  73006. readonly byteStride: number;
  73007. /**
  73008. * Gets the byte offset.
  73009. */
  73010. readonly byteOffset: number;
  73011. /**
  73012. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73013. */
  73014. readonly normalized: boolean;
  73015. /**
  73016. * Gets the data type of each component in the array.
  73017. */
  73018. readonly type: number;
  73019. /**
  73020. * Constructor
  73021. * @param engine the engine
  73022. * @param data the data to use for this vertex buffer
  73023. * @param kind the vertex buffer kind
  73024. * @param updatable whether the data is updatable
  73025. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73026. * @param stride the stride (optional)
  73027. * @param instanced whether the buffer is instanced (optional)
  73028. * @param offset the offset of the data (optional)
  73029. * @param size the number of components (optional)
  73030. * @param type the type of the component (optional)
  73031. * @param normalized whether the data contains normalized data (optional)
  73032. * @param useBytes set to true if stride and offset are in bytes (optional)
  73033. */
  73034. 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);
  73035. /** @hidden */
  73036. _rebuild(): void;
  73037. /**
  73038. * Returns the kind of the VertexBuffer (string)
  73039. * @returns a string
  73040. */
  73041. getKind(): string;
  73042. /**
  73043. * Gets a boolean indicating if the VertexBuffer is updatable?
  73044. * @returns true if the buffer is updatable
  73045. */
  73046. isUpdatable(): boolean;
  73047. /**
  73048. * Gets current buffer's data
  73049. * @returns a DataArray or null
  73050. */
  73051. getData(): Nullable<DataArray>;
  73052. /**
  73053. * Gets underlying native buffer
  73054. * @returns underlying native buffer
  73055. */
  73056. getBuffer(): Nullable<DataBuffer>;
  73057. /**
  73058. * Gets the stride in float32 units (i.e. byte stride / 4).
  73059. * May not be an integer if the byte stride is not divisible by 4.
  73060. * DEPRECATED. Use byteStride instead.
  73061. * @returns the stride in float32 units
  73062. */
  73063. getStrideSize(): number;
  73064. /**
  73065. * Returns the offset as a multiple of the type byte length.
  73066. * DEPRECATED. Use byteOffset instead.
  73067. * @returns the offset in bytes
  73068. */
  73069. getOffset(): number;
  73070. /**
  73071. * Returns the number of components per vertex attribute (integer)
  73072. * @returns the size in float
  73073. */
  73074. getSize(): number;
  73075. /**
  73076. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73077. * @returns true if this buffer is instanced
  73078. */
  73079. getIsInstanced(): boolean;
  73080. /**
  73081. * Returns the instancing divisor, zero for non-instanced (integer).
  73082. * @returns a number
  73083. */
  73084. getInstanceDivisor(): number;
  73085. /**
  73086. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73087. * @param data defines the data to store
  73088. */
  73089. create(data?: DataArray): void;
  73090. /**
  73091. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73092. * This function will create a new buffer if the current one is not updatable
  73093. * @param data defines the data to store
  73094. */
  73095. update(data: DataArray): void;
  73096. /**
  73097. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73098. * Returns the directly updated WebGLBuffer.
  73099. * @param data the new data
  73100. * @param offset the new offset
  73101. * @param useBytes set to true if the offset is in bytes
  73102. */
  73103. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73104. /**
  73105. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73106. */
  73107. dispose(): void;
  73108. /**
  73109. * Enumerates each value of this vertex buffer as numbers.
  73110. * @param count the number of values to enumerate
  73111. * @param callback the callback function called for each value
  73112. */
  73113. forEach(count: number, callback: (value: number, index: number) => void): void;
  73114. /**
  73115. * Positions
  73116. */
  73117. static readonly PositionKind: string;
  73118. /**
  73119. * Normals
  73120. */
  73121. static readonly NormalKind: string;
  73122. /**
  73123. * Tangents
  73124. */
  73125. static readonly TangentKind: string;
  73126. /**
  73127. * Texture coordinates
  73128. */
  73129. static readonly UVKind: string;
  73130. /**
  73131. * Texture coordinates 2
  73132. */
  73133. static readonly UV2Kind: string;
  73134. /**
  73135. * Texture coordinates 3
  73136. */
  73137. static readonly UV3Kind: string;
  73138. /**
  73139. * Texture coordinates 4
  73140. */
  73141. static readonly UV4Kind: string;
  73142. /**
  73143. * Texture coordinates 5
  73144. */
  73145. static readonly UV5Kind: string;
  73146. /**
  73147. * Texture coordinates 6
  73148. */
  73149. static readonly UV6Kind: string;
  73150. /**
  73151. * Colors
  73152. */
  73153. static readonly ColorKind: string;
  73154. /**
  73155. * Matrix indices (for bones)
  73156. */
  73157. static readonly MatricesIndicesKind: string;
  73158. /**
  73159. * Matrix weights (for bones)
  73160. */
  73161. static readonly MatricesWeightsKind: string;
  73162. /**
  73163. * Additional matrix indices (for bones)
  73164. */
  73165. static readonly MatricesIndicesExtraKind: string;
  73166. /**
  73167. * Additional matrix weights (for bones)
  73168. */
  73169. static readonly MatricesWeightsExtraKind: string;
  73170. /**
  73171. * Deduces the stride given a kind.
  73172. * @param kind The kind string to deduce
  73173. * @returns The deduced stride
  73174. */
  73175. static DeduceStride(kind: string): number;
  73176. /**
  73177. * Gets the byte length of the given type.
  73178. * @param type the type
  73179. * @returns the number of bytes
  73180. */
  73181. static GetTypeByteLength(type: number): number;
  73182. /**
  73183. * Enumerates each value of the given parameters as numbers.
  73184. * @param data the data to enumerate
  73185. * @param byteOffset the byte offset of the data
  73186. * @param byteStride the byte stride of the data
  73187. * @param componentCount the number of components per element
  73188. * @param componentType the type of the component
  73189. * @param count the number of values to enumerate
  73190. * @param normalized whether the data is normalized
  73191. * @param callback the callback function called for each value
  73192. */
  73193. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73194. private static _GetFloatValue;
  73195. }
  73196. }
  73197. declare module BABYLON {
  73198. /**
  73199. * @hidden
  73200. */
  73201. export class IntersectionInfo {
  73202. bu: Nullable<number>;
  73203. bv: Nullable<number>;
  73204. distance: number;
  73205. faceId: number;
  73206. subMeshId: number;
  73207. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73208. }
  73209. }
  73210. declare module BABYLON {
  73211. /**
  73212. * Represens a plane by the equation ax + by + cz + d = 0
  73213. */
  73214. export class Plane {
  73215. private static _TmpMatrix;
  73216. /**
  73217. * Normal of the plane (a,b,c)
  73218. */
  73219. normal: Vector3;
  73220. /**
  73221. * d component of the plane
  73222. */
  73223. d: number;
  73224. /**
  73225. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73226. * @param a a component of the plane
  73227. * @param b b component of the plane
  73228. * @param c c component of the plane
  73229. * @param d d component of the plane
  73230. */
  73231. constructor(a: number, b: number, c: number, d: number);
  73232. /**
  73233. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73234. */
  73235. asArray(): number[];
  73236. /**
  73237. * @returns a new plane copied from the current Plane.
  73238. */
  73239. clone(): Plane;
  73240. /**
  73241. * @returns the string "Plane".
  73242. */
  73243. getClassName(): string;
  73244. /**
  73245. * @returns the Plane hash code.
  73246. */
  73247. getHashCode(): number;
  73248. /**
  73249. * Normalize the current Plane in place.
  73250. * @returns the updated Plane.
  73251. */
  73252. normalize(): Plane;
  73253. /**
  73254. * Applies a transformation the plane and returns the result
  73255. * @param transformation the transformation matrix to be applied to the plane
  73256. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73257. */
  73258. transform(transformation: DeepImmutable<Matrix>): Plane;
  73259. /**
  73260. * Calcualtte the dot product between the point and the plane normal
  73261. * @param point point to calculate the dot product with
  73262. * @returns the dot product (float) of the point coordinates and the plane normal.
  73263. */
  73264. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73265. /**
  73266. * Updates the current Plane from the plane defined by the three given points.
  73267. * @param point1 one of the points used to contruct the plane
  73268. * @param point2 one of the points used to contruct the plane
  73269. * @param point3 one of the points used to contruct the plane
  73270. * @returns the updated Plane.
  73271. */
  73272. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73273. /**
  73274. * Checks if the plane is facing a given direction
  73275. * @param direction the direction to check if the plane is facing
  73276. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73277. * @returns True is the vector "direction" is the same side than the plane normal.
  73278. */
  73279. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73280. /**
  73281. * Calculates the distance to a point
  73282. * @param point point to calculate distance to
  73283. * @returns the signed distance (float) from the given point to the Plane.
  73284. */
  73285. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73286. /**
  73287. * Creates a plane from an array
  73288. * @param array the array to create a plane from
  73289. * @returns a new Plane from the given array.
  73290. */
  73291. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73292. /**
  73293. * Creates a plane from three points
  73294. * @param point1 point used to create the plane
  73295. * @param point2 point used to create the plane
  73296. * @param point3 point used to create the plane
  73297. * @returns a new Plane defined by the three given points.
  73298. */
  73299. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73300. /**
  73301. * Creates a plane from an origin point and a normal
  73302. * @param origin origin of the plane to be constructed
  73303. * @param normal normal of the plane to be constructed
  73304. * @returns a new Plane the normal vector to this plane at the given origin point.
  73305. * Note : the vector "normal" is updated because normalized.
  73306. */
  73307. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73308. /**
  73309. * Calculates the distance from a plane and a point
  73310. * @param origin origin of the plane to be constructed
  73311. * @param normal normal of the plane to be constructed
  73312. * @param point point to calculate distance to
  73313. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73314. */
  73315. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73316. }
  73317. }
  73318. declare module BABYLON {
  73319. /**
  73320. * Class used to store bounding sphere information
  73321. */
  73322. export class BoundingSphere {
  73323. /**
  73324. * Gets the center of the bounding sphere in local space
  73325. */
  73326. readonly center: Vector3;
  73327. /**
  73328. * Radius of the bounding sphere in local space
  73329. */
  73330. radius: number;
  73331. /**
  73332. * Gets the center of the bounding sphere in world space
  73333. */
  73334. readonly centerWorld: Vector3;
  73335. /**
  73336. * Radius of the bounding sphere in world space
  73337. */
  73338. radiusWorld: number;
  73339. /**
  73340. * Gets the minimum vector in local space
  73341. */
  73342. readonly minimum: Vector3;
  73343. /**
  73344. * Gets the maximum vector in local space
  73345. */
  73346. readonly maximum: Vector3;
  73347. private _worldMatrix;
  73348. private static readonly TmpVector3;
  73349. /**
  73350. * Creates a new bounding sphere
  73351. * @param min defines the minimum vector (in local space)
  73352. * @param max defines the maximum vector (in local space)
  73353. * @param worldMatrix defines the new world matrix
  73354. */
  73355. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73356. /**
  73357. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73358. * @param min defines the new minimum vector (in local space)
  73359. * @param max defines the new maximum vector (in local space)
  73360. * @param worldMatrix defines the new world matrix
  73361. */
  73362. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73363. /**
  73364. * Scale the current bounding sphere by applying a scale factor
  73365. * @param factor defines the scale factor to apply
  73366. * @returns the current bounding box
  73367. */
  73368. scale(factor: number): BoundingSphere;
  73369. /**
  73370. * Gets the world matrix of the bounding box
  73371. * @returns a matrix
  73372. */
  73373. getWorldMatrix(): DeepImmutable<Matrix>;
  73374. /** @hidden */
  73375. _update(worldMatrix: DeepImmutable<Matrix>): void;
  73376. /**
  73377. * Tests if the bounding sphere is intersecting the frustum planes
  73378. * @param frustumPlanes defines the frustum planes to test
  73379. * @returns true if there is an intersection
  73380. */
  73381. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73382. /**
  73383. * Tests if the bounding sphere center is in between the frustum planes.
  73384. * Used for optimistic fast inclusion.
  73385. * @param frustumPlanes defines the frustum planes to test
  73386. * @returns true if the sphere center is in between the frustum planes
  73387. */
  73388. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73389. /**
  73390. * Tests if a point is inside the bounding sphere
  73391. * @param point defines the point to test
  73392. * @returns true if the point is inside the bounding sphere
  73393. */
  73394. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73395. /**
  73396. * Checks if two sphere intersct
  73397. * @param sphere0 sphere 0
  73398. * @param sphere1 sphere 1
  73399. * @returns true if the speres intersect
  73400. */
  73401. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  73402. }
  73403. }
  73404. declare module BABYLON {
  73405. /**
  73406. * Class used to store bounding box information
  73407. */
  73408. export class BoundingBox implements ICullable {
  73409. /**
  73410. * Gets the 8 vectors representing the bounding box in local space
  73411. */
  73412. readonly vectors: Vector3[];
  73413. /**
  73414. * Gets the center of the bounding box in local space
  73415. */
  73416. readonly center: Vector3;
  73417. /**
  73418. * Gets the center of the bounding box in world space
  73419. */
  73420. readonly centerWorld: Vector3;
  73421. /**
  73422. * Gets the extend size in local space
  73423. */
  73424. readonly extendSize: Vector3;
  73425. /**
  73426. * Gets the extend size in world space
  73427. */
  73428. readonly extendSizeWorld: Vector3;
  73429. /**
  73430. * Gets the OBB (object bounding box) directions
  73431. */
  73432. readonly directions: Vector3[];
  73433. /**
  73434. * Gets the 8 vectors representing the bounding box in world space
  73435. */
  73436. readonly vectorsWorld: Vector3[];
  73437. /**
  73438. * Gets the minimum vector in world space
  73439. */
  73440. readonly minimumWorld: Vector3;
  73441. /**
  73442. * Gets the maximum vector in world space
  73443. */
  73444. readonly maximumWorld: Vector3;
  73445. /**
  73446. * Gets the minimum vector in local space
  73447. */
  73448. readonly minimum: Vector3;
  73449. /**
  73450. * Gets the maximum vector in local space
  73451. */
  73452. readonly maximum: Vector3;
  73453. private _worldMatrix;
  73454. private static readonly TmpVector3;
  73455. /**
  73456. * @hidden
  73457. */
  73458. _tag: number;
  73459. /**
  73460. * Creates a new bounding box
  73461. * @param min defines the minimum vector (in local space)
  73462. * @param max defines the maximum vector (in local space)
  73463. * @param worldMatrix defines the new world matrix
  73464. */
  73465. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73466. /**
  73467. * Recreates the entire bounding box from scratch as if we call the constructor in place
  73468. * @param min defines the new minimum vector (in local space)
  73469. * @param max defines the new maximum vector (in local space)
  73470. * @param worldMatrix defines the new world matrix
  73471. */
  73472. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73473. /**
  73474. * Scale the current bounding box by applying a scale factor
  73475. * @param factor defines the scale factor to apply
  73476. * @returns the current bounding box
  73477. */
  73478. scale(factor: number): BoundingBox;
  73479. /**
  73480. * Gets the world matrix of the bounding box
  73481. * @returns a matrix
  73482. */
  73483. getWorldMatrix(): DeepImmutable<Matrix>;
  73484. /** @hidden */
  73485. _update(world: DeepImmutable<Matrix>): void;
  73486. /**
  73487. * Tests if the bounding box is intersecting the frustum planes
  73488. * @param frustumPlanes defines the frustum planes to test
  73489. * @returns true if there is an intersection
  73490. */
  73491. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73492. /**
  73493. * Tests if the bounding box is entirely inside the frustum planes
  73494. * @param frustumPlanes defines the frustum planes to test
  73495. * @returns true if there is an inclusion
  73496. */
  73497. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73498. /**
  73499. * Tests if a point is inside the bounding box
  73500. * @param point defines the point to test
  73501. * @returns true if the point is inside the bounding box
  73502. */
  73503. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73504. /**
  73505. * Tests if the bounding box intersects with a bounding sphere
  73506. * @param sphere defines the sphere to test
  73507. * @returns true if there is an intersection
  73508. */
  73509. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  73510. /**
  73511. * Tests if the bounding box intersects with a box defined by a min and max vectors
  73512. * @param min defines the min vector to use
  73513. * @param max defines the max vector to use
  73514. * @returns true if there is an intersection
  73515. */
  73516. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  73517. /**
  73518. * Tests if two bounding boxes are intersections
  73519. * @param box0 defines the first box to test
  73520. * @param box1 defines the second box to test
  73521. * @returns true if there is an intersection
  73522. */
  73523. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  73524. /**
  73525. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  73526. * @param minPoint defines the minimum vector of the bounding box
  73527. * @param maxPoint defines the maximum vector of the bounding box
  73528. * @param sphereCenter defines the sphere center
  73529. * @param sphereRadius defines the sphere radius
  73530. * @returns true if there is an intersection
  73531. */
  73532. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  73533. /**
  73534. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  73535. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73536. * @param frustumPlanes defines the frustum planes to test
  73537. * @return true if there is an inclusion
  73538. */
  73539. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73540. /**
  73541. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  73542. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73543. * @param frustumPlanes defines the frustum planes to test
  73544. * @return true if there is an intersection
  73545. */
  73546. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73547. }
  73548. }
  73549. declare module BABYLON {
  73550. /** @hidden */
  73551. export class Collider {
  73552. /** Define if a collision was found */
  73553. collisionFound: boolean;
  73554. /**
  73555. * Define last intersection point in local space
  73556. */
  73557. intersectionPoint: Vector3;
  73558. /**
  73559. * Define last collided mesh
  73560. */
  73561. collidedMesh: Nullable<AbstractMesh>;
  73562. private _collisionPoint;
  73563. private _planeIntersectionPoint;
  73564. private _tempVector;
  73565. private _tempVector2;
  73566. private _tempVector3;
  73567. private _tempVector4;
  73568. private _edge;
  73569. private _baseToVertex;
  73570. private _destinationPoint;
  73571. private _slidePlaneNormal;
  73572. private _displacementVector;
  73573. /** @hidden */
  73574. _radius: Vector3;
  73575. /** @hidden */
  73576. _retry: number;
  73577. private _velocity;
  73578. private _basePoint;
  73579. private _epsilon;
  73580. /** @hidden */
  73581. _velocityWorldLength: number;
  73582. /** @hidden */
  73583. _basePointWorld: Vector3;
  73584. private _velocityWorld;
  73585. private _normalizedVelocity;
  73586. /** @hidden */
  73587. _initialVelocity: Vector3;
  73588. /** @hidden */
  73589. _initialPosition: Vector3;
  73590. private _nearestDistance;
  73591. private _collisionMask;
  73592. collisionMask: number;
  73593. /**
  73594. * Gets the plane normal used to compute the sliding response (in local space)
  73595. */
  73596. readonly slidePlaneNormal: Vector3;
  73597. /** @hidden */
  73598. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73599. /** @hidden */
  73600. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73601. /** @hidden */
  73602. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73603. /** @hidden */
  73604. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73605. /** @hidden */
  73606. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73607. /** @hidden */
  73608. _getResponse(pos: Vector3, vel: Vector3): void;
  73609. }
  73610. }
  73611. declare module BABYLON {
  73612. /**
  73613. * Interface for cullable objects
  73614. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73615. */
  73616. export interface ICullable {
  73617. /**
  73618. * Checks if the object or part of the object is in the frustum
  73619. * @param frustumPlanes Camera near/planes
  73620. * @returns true if the object is in frustum otherwise false
  73621. */
  73622. isInFrustum(frustumPlanes: Plane[]): boolean;
  73623. /**
  73624. * Checks if a cullable object (mesh...) is in the camera frustum
  73625. * Unlike isInFrustum this cheks the full bounding box
  73626. * @param frustumPlanes Camera near/planes
  73627. * @returns true if the object is in frustum otherwise false
  73628. */
  73629. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73630. }
  73631. /**
  73632. * Info for a bounding data of a mesh
  73633. */
  73634. export class BoundingInfo implements ICullable {
  73635. /**
  73636. * Bounding box for the mesh
  73637. */
  73638. readonly boundingBox: BoundingBox;
  73639. /**
  73640. * Bounding sphere for the mesh
  73641. */
  73642. readonly boundingSphere: BoundingSphere;
  73643. private _isLocked;
  73644. private static readonly TmpVector3;
  73645. /**
  73646. * Constructs bounding info
  73647. * @param minimum min vector of the bounding box/sphere
  73648. * @param maximum max vector of the bounding box/sphere
  73649. * @param worldMatrix defines the new world matrix
  73650. */
  73651. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73652. /**
  73653. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73654. * @param min defines the new minimum vector (in local space)
  73655. * @param max defines the new maximum vector (in local space)
  73656. * @param worldMatrix defines the new world matrix
  73657. */
  73658. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73659. /**
  73660. * min vector of the bounding box/sphere
  73661. */
  73662. readonly minimum: Vector3;
  73663. /**
  73664. * max vector of the bounding box/sphere
  73665. */
  73666. readonly maximum: Vector3;
  73667. /**
  73668. * If the info is locked and won't be updated to avoid perf overhead
  73669. */
  73670. isLocked: boolean;
  73671. /**
  73672. * Updates the bounding sphere and box
  73673. * @param world world matrix to be used to update
  73674. */
  73675. update(world: DeepImmutable<Matrix>): void;
  73676. /**
  73677. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73678. * @param center New center of the bounding info
  73679. * @param extend New extend of the bounding info
  73680. * @returns the current bounding info
  73681. */
  73682. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73683. /**
  73684. * Scale the current bounding info by applying a scale factor
  73685. * @param factor defines the scale factor to apply
  73686. * @returns the current bounding info
  73687. */
  73688. scale(factor: number): BoundingInfo;
  73689. /**
  73690. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73691. * @param frustumPlanes defines the frustum to test
  73692. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73693. * @returns true if the bounding info is in the frustum planes
  73694. */
  73695. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73696. /**
  73697. * Gets the world distance between the min and max points of the bounding box
  73698. */
  73699. readonly diagonalLength: number;
  73700. /**
  73701. * Checks if a cullable object (mesh...) is in the camera frustum
  73702. * Unlike isInFrustum this cheks the full bounding box
  73703. * @param frustumPlanes Camera near/planes
  73704. * @returns true if the object is in frustum otherwise false
  73705. */
  73706. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73707. /** @hidden */
  73708. _checkCollision(collider: Collider): boolean;
  73709. /**
  73710. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73711. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73712. * @param point the point to check intersection with
  73713. * @returns if the point intersects
  73714. */
  73715. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73716. /**
  73717. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73718. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73719. * @param boundingInfo the bounding info to check intersection with
  73720. * @param precise if the intersection should be done using OBB
  73721. * @returns if the bounding info intersects
  73722. */
  73723. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73724. }
  73725. }
  73726. declare module BABYLON {
  73727. /**
  73728. * Extracts minimum and maximum values from a list of indexed positions
  73729. * @param positions defines the positions to use
  73730. * @param indices defines the indices to the positions
  73731. * @param indexStart defines the start index
  73732. * @param indexCount defines the end index
  73733. * @param bias defines bias value to add to the result
  73734. * @return minimum and maximum values
  73735. */
  73736. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73737. minimum: Vector3;
  73738. maximum: Vector3;
  73739. };
  73740. /**
  73741. * Extracts minimum and maximum values from a list of positions
  73742. * @param positions defines the positions to use
  73743. * @param start defines the start index in the positions array
  73744. * @param count defines the number of positions to handle
  73745. * @param bias defines bias value to add to the result
  73746. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73747. * @return minimum and maximum values
  73748. */
  73749. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73750. minimum: Vector3;
  73751. maximum: Vector3;
  73752. };
  73753. }
  73754. declare module BABYLON {
  73755. /** @hidden */
  73756. export class WebGLDataBuffer extends DataBuffer {
  73757. private _buffer;
  73758. constructor(resource: WebGLBuffer);
  73759. readonly underlyingResource: any;
  73760. }
  73761. }
  73762. declare module BABYLON {
  73763. /** @hidden */
  73764. export class WebGLPipelineContext implements IPipelineContext {
  73765. engine: ThinEngine;
  73766. program: Nullable<WebGLProgram>;
  73767. context?: WebGLRenderingContext;
  73768. vertexShader?: WebGLShader;
  73769. fragmentShader?: WebGLShader;
  73770. isParallelCompiled: boolean;
  73771. onCompiled?: () => void;
  73772. transformFeedback?: WebGLTransformFeedback | null;
  73773. readonly isAsync: boolean;
  73774. readonly isReady: boolean;
  73775. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  73776. }
  73777. }
  73778. declare module BABYLON {
  73779. interface ThinEngine {
  73780. /**
  73781. * Create an uniform buffer
  73782. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73783. * @param elements defines the content of the uniform buffer
  73784. * @returns the webGL uniform buffer
  73785. */
  73786. createUniformBuffer(elements: FloatArray): DataBuffer;
  73787. /**
  73788. * Create a dynamic uniform buffer
  73789. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73790. * @param elements defines the content of the uniform buffer
  73791. * @returns the webGL uniform buffer
  73792. */
  73793. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  73794. /**
  73795. * Update an existing uniform buffer
  73796. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73797. * @param uniformBuffer defines the target uniform buffer
  73798. * @param elements defines the content to update
  73799. * @param offset defines the offset in the uniform buffer where update should start
  73800. * @param count defines the size of the data to update
  73801. */
  73802. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  73803. /**
  73804. * Bind an uniform buffer to the current webGL context
  73805. * @param buffer defines the buffer to bind
  73806. */
  73807. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  73808. /**
  73809. * Bind a buffer to the current webGL context at a given location
  73810. * @param buffer defines the buffer to bind
  73811. * @param location defines the index where to bind the buffer
  73812. */
  73813. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  73814. /**
  73815. * Bind a specific block at a given index in a specific shader program
  73816. * @param pipelineContext defines the pipeline context to use
  73817. * @param blockName defines the block name
  73818. * @param index defines the index where to bind the block
  73819. */
  73820. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  73821. }
  73822. }
  73823. declare module BABYLON {
  73824. /**
  73825. * Uniform buffer objects.
  73826. *
  73827. * Handles blocks of uniform on the GPU.
  73828. *
  73829. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73830. *
  73831. * For more information, please refer to :
  73832. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73833. */
  73834. export class UniformBuffer {
  73835. private _engine;
  73836. private _buffer;
  73837. private _data;
  73838. private _bufferData;
  73839. private _dynamic?;
  73840. private _uniformLocations;
  73841. private _uniformSizes;
  73842. private _uniformLocationPointer;
  73843. private _needSync;
  73844. private _noUBO;
  73845. private _currentEffect;
  73846. private static _MAX_UNIFORM_SIZE;
  73847. private static _tempBuffer;
  73848. /**
  73849. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  73850. * This is dynamic to allow compat with webgl 1 and 2.
  73851. * You will need to pass the name of the uniform as well as the value.
  73852. */
  73853. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  73854. /**
  73855. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  73856. * This is dynamic to allow compat with webgl 1 and 2.
  73857. * You will need to pass the name of the uniform as well as the value.
  73858. */
  73859. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  73860. /**
  73861. * Lambda to Update a single float in a uniform buffer.
  73862. * This is dynamic to allow compat with webgl 1 and 2.
  73863. * You will need to pass the name of the uniform as well as the value.
  73864. */
  73865. updateFloat: (name: string, x: number) => void;
  73866. /**
  73867. * Lambda to Update a vec2 of float in a uniform buffer.
  73868. * This is dynamic to allow compat with webgl 1 and 2.
  73869. * You will need to pass the name of the uniform as well as the value.
  73870. */
  73871. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  73872. /**
  73873. * Lambda to Update a vec3 of float in a uniform buffer.
  73874. * This is dynamic to allow compat with webgl 1 and 2.
  73875. * You will need to pass the name of the uniform as well as the value.
  73876. */
  73877. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  73878. /**
  73879. * Lambda to Update a vec4 of float in a uniform buffer.
  73880. * This is dynamic to allow compat with webgl 1 and 2.
  73881. * You will need to pass the name of the uniform as well as the value.
  73882. */
  73883. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  73884. /**
  73885. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  73886. * This is dynamic to allow compat with webgl 1 and 2.
  73887. * You will need to pass the name of the uniform as well as the value.
  73888. */
  73889. updateMatrix: (name: string, mat: Matrix) => void;
  73890. /**
  73891. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  73892. * This is dynamic to allow compat with webgl 1 and 2.
  73893. * You will need to pass the name of the uniform as well as the value.
  73894. */
  73895. updateVector3: (name: string, vector: Vector3) => void;
  73896. /**
  73897. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  73898. * This is dynamic to allow compat with webgl 1 and 2.
  73899. * You will need to pass the name of the uniform as well as the value.
  73900. */
  73901. updateVector4: (name: string, vector: Vector4) => void;
  73902. /**
  73903. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  73904. * This is dynamic to allow compat with webgl 1 and 2.
  73905. * You will need to pass the name of the uniform as well as the value.
  73906. */
  73907. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  73908. /**
  73909. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  73910. * This is dynamic to allow compat with webgl 1 and 2.
  73911. * You will need to pass the name of the uniform as well as the value.
  73912. */
  73913. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  73914. /**
  73915. * Instantiates a new Uniform buffer objects.
  73916. *
  73917. * Handles blocks of uniform on the GPU.
  73918. *
  73919. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73920. *
  73921. * For more information, please refer to :
  73922. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73923. * @param engine Define the engine the buffer is associated with
  73924. * @param data Define the data contained in the buffer
  73925. * @param dynamic Define if the buffer is updatable
  73926. */
  73927. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  73928. /**
  73929. * Indicates if the buffer is using the WebGL2 UBO implementation,
  73930. * or just falling back on setUniformXXX calls.
  73931. */
  73932. readonly useUbo: boolean;
  73933. /**
  73934. * Indicates if the WebGL underlying uniform buffer is in sync
  73935. * with the javascript cache data.
  73936. */
  73937. readonly isSync: boolean;
  73938. /**
  73939. * Indicates if the WebGL underlying uniform buffer is dynamic.
  73940. * Also, a dynamic UniformBuffer will disable cache verification and always
  73941. * update the underlying WebGL uniform buffer to the GPU.
  73942. * @returns if Dynamic, otherwise false
  73943. */
  73944. isDynamic(): boolean;
  73945. /**
  73946. * The data cache on JS side.
  73947. * @returns the underlying data as a float array
  73948. */
  73949. getData(): Float32Array;
  73950. /**
  73951. * The underlying WebGL Uniform buffer.
  73952. * @returns the webgl buffer
  73953. */
  73954. getBuffer(): Nullable<DataBuffer>;
  73955. /**
  73956. * std140 layout specifies how to align data within an UBO structure.
  73957. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  73958. * for specs.
  73959. */
  73960. private _fillAlignment;
  73961. /**
  73962. * Adds an uniform in the buffer.
  73963. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  73964. * for the layout to be correct !
  73965. * @param name Name of the uniform, as used in the uniform block in the shader.
  73966. * @param size Data size, or data directly.
  73967. */
  73968. addUniform(name: string, size: number | number[]): void;
  73969. /**
  73970. * Adds a Matrix 4x4 to the uniform buffer.
  73971. * @param name Name of the uniform, as used in the uniform block in the shader.
  73972. * @param mat A 4x4 matrix.
  73973. */
  73974. addMatrix(name: string, mat: Matrix): void;
  73975. /**
  73976. * Adds a vec2 to the uniform buffer.
  73977. * @param name Name of the uniform, as used in the uniform block in the shader.
  73978. * @param x Define the x component value of the vec2
  73979. * @param y Define the y component value of the vec2
  73980. */
  73981. addFloat2(name: string, x: number, y: number): void;
  73982. /**
  73983. * Adds a vec3 to the uniform buffer.
  73984. * @param name Name of the uniform, as used in the uniform block in the shader.
  73985. * @param x Define the x component value of the vec3
  73986. * @param y Define the y component value of the vec3
  73987. * @param z Define the z component value of the vec3
  73988. */
  73989. addFloat3(name: string, x: number, y: number, z: number): void;
  73990. /**
  73991. * Adds a vec3 to the uniform buffer.
  73992. * @param name Name of the uniform, as used in the uniform block in the shader.
  73993. * @param color Define the vec3 from a Color
  73994. */
  73995. addColor3(name: string, color: Color3): void;
  73996. /**
  73997. * Adds a vec4 to the uniform buffer.
  73998. * @param name Name of the uniform, as used in the uniform block in the shader.
  73999. * @param color Define the rgb components from a Color
  74000. * @param alpha Define the a component of the vec4
  74001. */
  74002. addColor4(name: string, color: Color3, alpha: number): void;
  74003. /**
  74004. * Adds a vec3 to the uniform buffer.
  74005. * @param name Name of the uniform, as used in the uniform block in the shader.
  74006. * @param vector Define the vec3 components from a Vector
  74007. */
  74008. addVector3(name: string, vector: Vector3): void;
  74009. /**
  74010. * Adds a Matrix 3x3 to the uniform buffer.
  74011. * @param name Name of the uniform, as used in the uniform block in the shader.
  74012. */
  74013. addMatrix3x3(name: string): void;
  74014. /**
  74015. * Adds a Matrix 2x2 to the uniform buffer.
  74016. * @param name Name of the uniform, as used in the uniform block in the shader.
  74017. */
  74018. addMatrix2x2(name: string): void;
  74019. /**
  74020. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74021. */
  74022. create(): void;
  74023. /** @hidden */
  74024. _rebuild(): void;
  74025. /**
  74026. * Updates the WebGL Uniform Buffer on the GPU.
  74027. * If the `dynamic` flag is set to true, no cache comparison is done.
  74028. * Otherwise, the buffer will be updated only if the cache differs.
  74029. */
  74030. update(): void;
  74031. /**
  74032. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74033. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74034. * @param data Define the flattened data
  74035. * @param size Define the size of the data.
  74036. */
  74037. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74038. private _valueCache;
  74039. private _cacheMatrix;
  74040. private _updateMatrix3x3ForUniform;
  74041. private _updateMatrix3x3ForEffect;
  74042. private _updateMatrix2x2ForEffect;
  74043. private _updateMatrix2x2ForUniform;
  74044. private _updateFloatForEffect;
  74045. private _updateFloatForUniform;
  74046. private _updateFloat2ForEffect;
  74047. private _updateFloat2ForUniform;
  74048. private _updateFloat3ForEffect;
  74049. private _updateFloat3ForUniform;
  74050. private _updateFloat4ForEffect;
  74051. private _updateFloat4ForUniform;
  74052. private _updateMatrixForEffect;
  74053. private _updateMatrixForUniform;
  74054. private _updateVector3ForEffect;
  74055. private _updateVector3ForUniform;
  74056. private _updateVector4ForEffect;
  74057. private _updateVector4ForUniform;
  74058. private _updateColor3ForEffect;
  74059. private _updateColor3ForUniform;
  74060. private _updateColor4ForEffect;
  74061. private _updateColor4ForUniform;
  74062. /**
  74063. * Sets a sampler uniform on the effect.
  74064. * @param name Define the name of the sampler.
  74065. * @param texture Define the texture to set in the sampler
  74066. */
  74067. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74068. /**
  74069. * Directly updates the value of the uniform in the cache AND on the GPU.
  74070. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74071. * @param data Define the flattened data
  74072. */
  74073. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74074. /**
  74075. * Binds this uniform buffer to an effect.
  74076. * @param effect Define the effect to bind the buffer to
  74077. * @param name Name of the uniform block in the shader.
  74078. */
  74079. bindToEffect(effect: Effect, name: string): void;
  74080. /**
  74081. * Disposes the uniform buffer.
  74082. */
  74083. dispose(): void;
  74084. }
  74085. }
  74086. declare module BABYLON {
  74087. /**
  74088. * Enum that determines the text-wrapping mode to use.
  74089. */
  74090. export enum InspectableType {
  74091. /**
  74092. * Checkbox for booleans
  74093. */
  74094. Checkbox = 0,
  74095. /**
  74096. * Sliders for numbers
  74097. */
  74098. Slider = 1,
  74099. /**
  74100. * Vector3
  74101. */
  74102. Vector3 = 2,
  74103. /**
  74104. * Quaternions
  74105. */
  74106. Quaternion = 3,
  74107. /**
  74108. * Color3
  74109. */
  74110. Color3 = 4,
  74111. /**
  74112. * String
  74113. */
  74114. String = 5
  74115. }
  74116. /**
  74117. * Interface used to define custom inspectable properties.
  74118. * This interface is used by the inspector to display custom property grids
  74119. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74120. */
  74121. export interface IInspectable {
  74122. /**
  74123. * Gets the label to display
  74124. */
  74125. label: string;
  74126. /**
  74127. * Gets the name of the property to edit
  74128. */
  74129. propertyName: string;
  74130. /**
  74131. * Gets the type of the editor to use
  74132. */
  74133. type: InspectableType;
  74134. /**
  74135. * Gets the minimum value of the property when using in "slider" mode
  74136. */
  74137. min?: number;
  74138. /**
  74139. * Gets the maximum value of the property when using in "slider" mode
  74140. */
  74141. max?: number;
  74142. /**
  74143. * Gets the setp to use when using in "slider" mode
  74144. */
  74145. step?: number;
  74146. }
  74147. }
  74148. declare module BABYLON {
  74149. /**
  74150. * Class used to provide helper for timing
  74151. */
  74152. export class TimingTools {
  74153. /**
  74154. * Polyfill for setImmediate
  74155. * @param action defines the action to execute after the current execution block
  74156. */
  74157. static SetImmediate(action: () => void): void;
  74158. }
  74159. }
  74160. declare module BABYLON {
  74161. /**
  74162. * Class used to enable instatition of objects by class name
  74163. */
  74164. export class InstantiationTools {
  74165. /**
  74166. * Use this object to register external classes like custom textures or material
  74167. * to allow the laoders to instantiate them
  74168. */
  74169. static RegisteredExternalClasses: {
  74170. [key: string]: Object;
  74171. };
  74172. /**
  74173. * Tries to instantiate a new object from a given class name
  74174. * @param className defines the class name to instantiate
  74175. * @returns the new object or null if the system was not able to do the instantiation
  74176. */
  74177. static Instantiate(className: string): any;
  74178. }
  74179. }
  74180. declare module BABYLON {
  74181. /**
  74182. * Define options used to create a depth texture
  74183. */
  74184. export class DepthTextureCreationOptions {
  74185. /** Specifies whether or not a stencil should be allocated in the texture */
  74186. generateStencil?: boolean;
  74187. /** Specifies whether or not bilinear filtering is enable on the texture */
  74188. bilinearFiltering?: boolean;
  74189. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74190. comparisonFunction?: number;
  74191. /** Specifies if the created texture is a cube texture */
  74192. isCube?: boolean;
  74193. }
  74194. }
  74195. declare module BABYLON {
  74196. interface ThinEngine {
  74197. /**
  74198. * Creates a depth stencil cube texture.
  74199. * This is only available in WebGL 2.
  74200. * @param size The size of face edge in the cube texture.
  74201. * @param options The options defining the cube texture.
  74202. * @returns The cube texture
  74203. */
  74204. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74205. /**
  74206. * Creates a cube texture
  74207. * @param rootUrl defines the url where the files to load is located
  74208. * @param scene defines the current scene
  74209. * @param files defines the list of files to load (1 per face)
  74210. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74211. * @param onLoad defines an optional callback raised when the texture is loaded
  74212. * @param onError defines an optional callback raised if there is an issue to load the texture
  74213. * @param format defines the format of the data
  74214. * @param forcedExtension defines the extension to use to pick the right loader
  74215. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74216. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74217. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74218. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74219. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74220. * @returns the cube texture as an InternalTexture
  74221. */
  74222. 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;
  74223. /**
  74224. * Creates a cube texture
  74225. * @param rootUrl defines the url where the files to load is located
  74226. * @param scene defines the current scene
  74227. * @param files defines the list of files to load (1 per face)
  74228. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74229. * @param onLoad defines an optional callback raised when the texture is loaded
  74230. * @param onError defines an optional callback raised if there is an issue to load the texture
  74231. * @param format defines the format of the data
  74232. * @param forcedExtension defines the extension to use to pick the right loader
  74233. * @returns the cube texture as an InternalTexture
  74234. */
  74235. 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;
  74236. /**
  74237. * Creates a cube texture
  74238. * @param rootUrl defines the url where the files to load is located
  74239. * @param scene defines the current scene
  74240. * @param files defines the list of files to load (1 per face)
  74241. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74242. * @param onLoad defines an optional callback raised when the texture is loaded
  74243. * @param onError defines an optional callback raised if there is an issue to load the texture
  74244. * @param format defines the format of the data
  74245. * @param forcedExtension defines the extension to use to pick the right loader
  74246. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74247. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74248. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74249. * @returns the cube texture as an InternalTexture
  74250. */
  74251. 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;
  74252. /** @hidden */
  74253. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74254. /** @hidden */
  74255. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74256. /** @hidden */
  74257. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74258. /** @hidden */
  74259. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74260. }
  74261. }
  74262. declare module BABYLON {
  74263. /**
  74264. * Class for creating a cube texture
  74265. */
  74266. export class CubeTexture extends BaseTexture {
  74267. private _delayedOnLoad;
  74268. /**
  74269. * The url of the texture
  74270. */
  74271. url: string;
  74272. /**
  74273. * Gets or sets the center of the bounding box associated with the cube texture.
  74274. * It must define where the camera used to render the texture was set
  74275. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74276. */
  74277. boundingBoxPosition: Vector3;
  74278. private _boundingBoxSize;
  74279. /**
  74280. * Gets or sets the size of the bounding box associated with the cube texture
  74281. * When defined, the cubemap will switch to local mode
  74282. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74283. * @example https://www.babylonjs-playground.com/#RNASML
  74284. */
  74285. /**
  74286. * Returns the bounding box size
  74287. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74288. */
  74289. boundingBoxSize: Vector3;
  74290. protected _rotationY: number;
  74291. /**
  74292. * Sets texture matrix rotation angle around Y axis in radians.
  74293. */
  74294. /**
  74295. * Gets texture matrix rotation angle around Y axis radians.
  74296. */
  74297. rotationY: number;
  74298. /**
  74299. * Are mip maps generated for this texture or not.
  74300. */
  74301. readonly noMipmap: boolean;
  74302. private _noMipmap;
  74303. private _files;
  74304. protected _forcedExtension: Nullable<string>;
  74305. private _extensions;
  74306. private _textureMatrix;
  74307. private _format;
  74308. private _createPolynomials;
  74309. /** @hidden */
  74310. _prefiltered: boolean;
  74311. /**
  74312. * Creates a cube texture from an array of image urls
  74313. * @param files defines an array of image urls
  74314. * @param scene defines the hosting scene
  74315. * @param noMipmap specifies if mip maps are not used
  74316. * @returns a cube texture
  74317. */
  74318. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74319. /**
  74320. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74321. * @param url defines the url of the prefiltered texture
  74322. * @param scene defines the scene the texture is attached to
  74323. * @param forcedExtension defines the extension of the file if different from the url
  74324. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74325. * @return the prefiltered texture
  74326. */
  74327. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74328. /**
  74329. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74330. * as prefiltered data.
  74331. * @param rootUrl defines the url of the texture or the root name of the six images
  74332. * @param scene defines the scene the texture is attached to
  74333. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74334. * @param noMipmap defines if mipmaps should be created or not
  74335. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74336. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74337. * @param onError defines a callback triggered in case of error during load
  74338. * @param format defines the internal format to use for the texture once loaded
  74339. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74340. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74341. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74342. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74343. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74344. * @return the cube texture
  74345. */
  74346. 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);
  74347. /**
  74348. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74349. */
  74350. readonly isPrefiltered: boolean;
  74351. /**
  74352. * Get the current class name of the texture useful for serialization or dynamic coding.
  74353. * @returns "CubeTexture"
  74354. */
  74355. getClassName(): string;
  74356. /**
  74357. * Update the url (and optional buffer) of this texture if url was null during construction.
  74358. * @param url the url of the texture
  74359. * @param forcedExtension defines the extension to use
  74360. * @param onLoad callback called when the texture is loaded (defaults to null)
  74361. */
  74362. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  74363. /**
  74364. * Delays loading of the cube texture
  74365. * @param forcedExtension defines the extension to use
  74366. */
  74367. delayLoad(forcedExtension?: string): void;
  74368. /**
  74369. * Returns the reflection texture matrix
  74370. * @returns the reflection texture matrix
  74371. */
  74372. getReflectionTextureMatrix(): Matrix;
  74373. /**
  74374. * Sets the reflection texture matrix
  74375. * @param value Reflection texture matrix
  74376. */
  74377. setReflectionTextureMatrix(value: Matrix): void;
  74378. /**
  74379. * Parses text to create a cube texture
  74380. * @param parsedTexture define the serialized text to read from
  74381. * @param scene defines the hosting scene
  74382. * @param rootUrl defines the root url of the cube texture
  74383. * @returns a cube texture
  74384. */
  74385. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  74386. /**
  74387. * Makes a clone, or deep copy, of the cube texture
  74388. * @returns a new cube texture
  74389. */
  74390. clone(): CubeTexture;
  74391. }
  74392. }
  74393. declare module BABYLON {
  74394. /**
  74395. * Manages the defines for the Material
  74396. */
  74397. export class MaterialDefines {
  74398. /** @hidden */
  74399. protected _keys: string[];
  74400. private _isDirty;
  74401. /** @hidden */
  74402. _renderId: number;
  74403. /** @hidden */
  74404. _areLightsDirty: boolean;
  74405. /** @hidden */
  74406. _areLightsDisposed: boolean;
  74407. /** @hidden */
  74408. _areAttributesDirty: boolean;
  74409. /** @hidden */
  74410. _areTexturesDirty: boolean;
  74411. /** @hidden */
  74412. _areFresnelDirty: boolean;
  74413. /** @hidden */
  74414. _areMiscDirty: boolean;
  74415. /** @hidden */
  74416. _areImageProcessingDirty: boolean;
  74417. /** @hidden */
  74418. _normals: boolean;
  74419. /** @hidden */
  74420. _uvs: boolean;
  74421. /** @hidden */
  74422. _needNormals: boolean;
  74423. /** @hidden */
  74424. _needUVs: boolean;
  74425. [id: string]: any;
  74426. /**
  74427. * Specifies if the material needs to be re-calculated
  74428. */
  74429. readonly isDirty: boolean;
  74430. /**
  74431. * Marks the material to indicate that it has been re-calculated
  74432. */
  74433. markAsProcessed(): void;
  74434. /**
  74435. * Marks the material to indicate that it needs to be re-calculated
  74436. */
  74437. markAsUnprocessed(): void;
  74438. /**
  74439. * Marks the material to indicate all of its defines need to be re-calculated
  74440. */
  74441. markAllAsDirty(): void;
  74442. /**
  74443. * Marks the material to indicate that image processing needs to be re-calculated
  74444. */
  74445. markAsImageProcessingDirty(): void;
  74446. /**
  74447. * Marks the material to indicate the lights need to be re-calculated
  74448. * @param disposed Defines whether the light is dirty due to dispose or not
  74449. */
  74450. markAsLightDirty(disposed?: boolean): void;
  74451. /**
  74452. * Marks the attribute state as changed
  74453. */
  74454. markAsAttributesDirty(): void;
  74455. /**
  74456. * Marks the texture state as changed
  74457. */
  74458. markAsTexturesDirty(): void;
  74459. /**
  74460. * Marks the fresnel state as changed
  74461. */
  74462. markAsFresnelDirty(): void;
  74463. /**
  74464. * Marks the misc state as changed
  74465. */
  74466. markAsMiscDirty(): void;
  74467. /**
  74468. * Rebuilds the material defines
  74469. */
  74470. rebuild(): void;
  74471. /**
  74472. * Specifies if two material defines are equal
  74473. * @param other - A material define instance to compare to
  74474. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  74475. */
  74476. isEqual(other: MaterialDefines): boolean;
  74477. /**
  74478. * Clones this instance's defines to another instance
  74479. * @param other - material defines to clone values to
  74480. */
  74481. cloneTo(other: MaterialDefines): void;
  74482. /**
  74483. * Resets the material define values
  74484. */
  74485. reset(): void;
  74486. /**
  74487. * Converts the material define values to a string
  74488. * @returns - String of material define information
  74489. */
  74490. toString(): string;
  74491. }
  74492. }
  74493. declare module BABYLON {
  74494. /**
  74495. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  74496. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  74497. * 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;
  74498. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  74499. */
  74500. export class ColorCurves {
  74501. private _dirty;
  74502. private _tempColor;
  74503. private _globalCurve;
  74504. private _highlightsCurve;
  74505. private _midtonesCurve;
  74506. private _shadowsCurve;
  74507. private _positiveCurve;
  74508. private _negativeCurve;
  74509. private _globalHue;
  74510. private _globalDensity;
  74511. private _globalSaturation;
  74512. private _globalExposure;
  74513. /**
  74514. * Gets the global Hue value.
  74515. * 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).
  74516. */
  74517. /**
  74518. * Sets the global Hue value.
  74519. * 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).
  74520. */
  74521. globalHue: number;
  74522. /**
  74523. * Gets the global Density value.
  74524. * 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.
  74525. * Values less than zero provide a filter of opposite hue.
  74526. */
  74527. /**
  74528. * Sets the global Density value.
  74529. * 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.
  74530. * Values less than zero provide a filter of opposite hue.
  74531. */
  74532. globalDensity: number;
  74533. /**
  74534. * Gets the global Saturation value.
  74535. * 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.
  74536. */
  74537. /**
  74538. * Sets the global Saturation value.
  74539. * 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.
  74540. */
  74541. globalSaturation: number;
  74542. /**
  74543. * Gets the global Exposure value.
  74544. * 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.
  74545. */
  74546. /**
  74547. * Sets the global Exposure value.
  74548. * 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.
  74549. */
  74550. globalExposure: number;
  74551. private _highlightsHue;
  74552. private _highlightsDensity;
  74553. private _highlightsSaturation;
  74554. private _highlightsExposure;
  74555. /**
  74556. * Gets the highlights Hue value.
  74557. * 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).
  74558. */
  74559. /**
  74560. * Sets the highlights Hue value.
  74561. * 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).
  74562. */
  74563. highlightsHue: number;
  74564. /**
  74565. * Gets the highlights Density value.
  74566. * 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.
  74567. * Values less than zero provide a filter of opposite hue.
  74568. */
  74569. /**
  74570. * Sets the highlights Density value.
  74571. * 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.
  74572. * Values less than zero provide a filter of opposite hue.
  74573. */
  74574. highlightsDensity: number;
  74575. /**
  74576. * Gets the highlights Saturation value.
  74577. * 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.
  74578. */
  74579. /**
  74580. * Sets the highlights Saturation value.
  74581. * 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.
  74582. */
  74583. highlightsSaturation: number;
  74584. /**
  74585. * Gets the highlights Exposure value.
  74586. * 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.
  74587. */
  74588. /**
  74589. * Sets the highlights Exposure value.
  74590. * 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.
  74591. */
  74592. highlightsExposure: number;
  74593. private _midtonesHue;
  74594. private _midtonesDensity;
  74595. private _midtonesSaturation;
  74596. private _midtonesExposure;
  74597. /**
  74598. * Gets the midtones Hue value.
  74599. * 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).
  74600. */
  74601. /**
  74602. * Sets the midtones Hue value.
  74603. * 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).
  74604. */
  74605. midtonesHue: number;
  74606. /**
  74607. * Gets the midtones Density value.
  74608. * 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.
  74609. * Values less than zero provide a filter of opposite hue.
  74610. */
  74611. /**
  74612. * Sets the midtones Density value.
  74613. * 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.
  74614. * Values less than zero provide a filter of opposite hue.
  74615. */
  74616. midtonesDensity: number;
  74617. /**
  74618. * Gets the midtones Saturation value.
  74619. * 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.
  74620. */
  74621. /**
  74622. * Sets the midtones Saturation value.
  74623. * 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.
  74624. */
  74625. midtonesSaturation: number;
  74626. /**
  74627. * Gets the midtones Exposure value.
  74628. * 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.
  74629. */
  74630. /**
  74631. * Sets the midtones Exposure value.
  74632. * 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.
  74633. */
  74634. midtonesExposure: number;
  74635. private _shadowsHue;
  74636. private _shadowsDensity;
  74637. private _shadowsSaturation;
  74638. private _shadowsExposure;
  74639. /**
  74640. * Gets the shadows Hue value.
  74641. * 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).
  74642. */
  74643. /**
  74644. * Sets the shadows Hue value.
  74645. * 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).
  74646. */
  74647. shadowsHue: number;
  74648. /**
  74649. * Gets the shadows Density value.
  74650. * 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.
  74651. * Values less than zero provide a filter of opposite hue.
  74652. */
  74653. /**
  74654. * Sets the shadows Density value.
  74655. * 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.
  74656. * Values less than zero provide a filter of opposite hue.
  74657. */
  74658. shadowsDensity: number;
  74659. /**
  74660. * Gets the shadows Saturation value.
  74661. * 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.
  74662. */
  74663. /**
  74664. * Sets the shadows Saturation value.
  74665. * 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.
  74666. */
  74667. shadowsSaturation: number;
  74668. /**
  74669. * Gets the shadows Exposure value.
  74670. * 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.
  74671. */
  74672. /**
  74673. * Sets the shadows Exposure value.
  74674. * 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.
  74675. */
  74676. shadowsExposure: number;
  74677. /**
  74678. * Returns the class name
  74679. * @returns The class name
  74680. */
  74681. getClassName(): string;
  74682. /**
  74683. * Binds the color curves to the shader.
  74684. * @param colorCurves The color curve to bind
  74685. * @param effect The effect to bind to
  74686. * @param positiveUniform The positive uniform shader parameter
  74687. * @param neutralUniform The neutral uniform shader parameter
  74688. * @param negativeUniform The negative uniform shader parameter
  74689. */
  74690. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  74691. /**
  74692. * Prepare the list of uniforms associated with the ColorCurves effects.
  74693. * @param uniformsList The list of uniforms used in the effect
  74694. */
  74695. static PrepareUniforms(uniformsList: string[]): void;
  74696. /**
  74697. * Returns color grading data based on a hue, density, saturation and exposure value.
  74698. * @param filterHue The hue of the color filter.
  74699. * @param filterDensity The density of the color filter.
  74700. * @param saturation The saturation.
  74701. * @param exposure The exposure.
  74702. * @param result The result data container.
  74703. */
  74704. private getColorGradingDataToRef;
  74705. /**
  74706. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  74707. * @param value The input slider value in range [-100,100].
  74708. * @returns Adjusted value.
  74709. */
  74710. private static applyColorGradingSliderNonlinear;
  74711. /**
  74712. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  74713. * @param hue The hue (H) input.
  74714. * @param saturation The saturation (S) input.
  74715. * @param brightness The brightness (B) input.
  74716. * @result An RGBA color represented as Vector4.
  74717. */
  74718. private static fromHSBToRef;
  74719. /**
  74720. * Returns a value clamped between min and max
  74721. * @param value The value to clamp
  74722. * @param min The minimum of value
  74723. * @param max The maximum of value
  74724. * @returns The clamped value.
  74725. */
  74726. private static clamp;
  74727. /**
  74728. * Clones the current color curve instance.
  74729. * @return The cloned curves
  74730. */
  74731. clone(): ColorCurves;
  74732. /**
  74733. * Serializes the current color curve instance to a json representation.
  74734. * @return a JSON representation
  74735. */
  74736. serialize(): any;
  74737. /**
  74738. * Parses the color curve from a json representation.
  74739. * @param source the JSON source to parse
  74740. * @return The parsed curves
  74741. */
  74742. static Parse(source: any): ColorCurves;
  74743. }
  74744. }
  74745. declare module BABYLON {
  74746. /**
  74747. * Interface to follow in your material defines to integrate easily the
  74748. * Image proccessing functions.
  74749. * @hidden
  74750. */
  74751. export interface IImageProcessingConfigurationDefines {
  74752. IMAGEPROCESSING: boolean;
  74753. VIGNETTE: boolean;
  74754. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74755. VIGNETTEBLENDMODEOPAQUE: boolean;
  74756. TONEMAPPING: boolean;
  74757. TONEMAPPING_ACES: boolean;
  74758. CONTRAST: boolean;
  74759. EXPOSURE: boolean;
  74760. COLORCURVES: boolean;
  74761. COLORGRADING: boolean;
  74762. COLORGRADING3D: boolean;
  74763. SAMPLER3DGREENDEPTH: boolean;
  74764. SAMPLER3DBGRMAP: boolean;
  74765. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74766. }
  74767. /**
  74768. * @hidden
  74769. */
  74770. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  74771. IMAGEPROCESSING: boolean;
  74772. VIGNETTE: boolean;
  74773. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74774. VIGNETTEBLENDMODEOPAQUE: boolean;
  74775. TONEMAPPING: boolean;
  74776. TONEMAPPING_ACES: boolean;
  74777. CONTRAST: boolean;
  74778. COLORCURVES: boolean;
  74779. COLORGRADING: boolean;
  74780. COLORGRADING3D: boolean;
  74781. SAMPLER3DGREENDEPTH: boolean;
  74782. SAMPLER3DBGRMAP: boolean;
  74783. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74784. EXPOSURE: boolean;
  74785. constructor();
  74786. }
  74787. /**
  74788. * This groups together the common properties used for image processing either in direct forward pass
  74789. * or through post processing effect depending on the use of the image processing pipeline in your scene
  74790. * or not.
  74791. */
  74792. export class ImageProcessingConfiguration {
  74793. /**
  74794. * Default tone mapping applied in BabylonJS.
  74795. */
  74796. static readonly TONEMAPPING_STANDARD: number;
  74797. /**
  74798. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  74799. * to other engines rendering to increase portability.
  74800. */
  74801. static readonly TONEMAPPING_ACES: number;
  74802. /**
  74803. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  74804. */
  74805. colorCurves: Nullable<ColorCurves>;
  74806. private _colorCurvesEnabled;
  74807. /**
  74808. * Gets wether the color curves effect is enabled.
  74809. */
  74810. /**
  74811. * Sets wether the color curves effect is enabled.
  74812. */
  74813. colorCurvesEnabled: boolean;
  74814. private _colorGradingTexture;
  74815. /**
  74816. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74817. */
  74818. /**
  74819. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74820. */
  74821. colorGradingTexture: Nullable<BaseTexture>;
  74822. private _colorGradingEnabled;
  74823. /**
  74824. * Gets wether the color grading effect is enabled.
  74825. */
  74826. /**
  74827. * Sets wether the color grading effect is enabled.
  74828. */
  74829. colorGradingEnabled: boolean;
  74830. private _colorGradingWithGreenDepth;
  74831. /**
  74832. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  74833. */
  74834. /**
  74835. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  74836. */
  74837. colorGradingWithGreenDepth: boolean;
  74838. private _colorGradingBGR;
  74839. /**
  74840. * Gets wether the color grading texture contains BGR values.
  74841. */
  74842. /**
  74843. * Sets wether the color grading texture contains BGR values.
  74844. */
  74845. colorGradingBGR: boolean;
  74846. /** @hidden */
  74847. _exposure: number;
  74848. /**
  74849. * Gets the Exposure used in the effect.
  74850. */
  74851. /**
  74852. * Sets the Exposure used in the effect.
  74853. */
  74854. exposure: number;
  74855. private _toneMappingEnabled;
  74856. /**
  74857. * Gets wether the tone mapping effect is enabled.
  74858. */
  74859. /**
  74860. * Sets wether the tone mapping effect is enabled.
  74861. */
  74862. toneMappingEnabled: boolean;
  74863. private _toneMappingType;
  74864. /**
  74865. * Gets the type of tone mapping effect.
  74866. */
  74867. /**
  74868. * Sets the type of tone mapping effect used in BabylonJS.
  74869. */
  74870. toneMappingType: number;
  74871. protected _contrast: number;
  74872. /**
  74873. * Gets the contrast used in the effect.
  74874. */
  74875. /**
  74876. * Sets the contrast used in the effect.
  74877. */
  74878. contrast: number;
  74879. /**
  74880. * Vignette stretch size.
  74881. */
  74882. vignetteStretch: number;
  74883. /**
  74884. * Vignette centre X Offset.
  74885. */
  74886. vignetteCentreX: number;
  74887. /**
  74888. * Vignette centre Y Offset.
  74889. */
  74890. vignetteCentreY: number;
  74891. /**
  74892. * Vignette weight or intensity of the vignette effect.
  74893. */
  74894. vignetteWeight: number;
  74895. /**
  74896. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  74897. * if vignetteEnabled is set to true.
  74898. */
  74899. vignetteColor: Color4;
  74900. /**
  74901. * Camera field of view used by the Vignette effect.
  74902. */
  74903. vignetteCameraFov: number;
  74904. private _vignetteBlendMode;
  74905. /**
  74906. * Gets the vignette blend mode allowing different kind of effect.
  74907. */
  74908. /**
  74909. * Sets the vignette blend mode allowing different kind of effect.
  74910. */
  74911. vignetteBlendMode: number;
  74912. private _vignetteEnabled;
  74913. /**
  74914. * Gets wether the vignette effect is enabled.
  74915. */
  74916. /**
  74917. * Sets wether the vignette effect is enabled.
  74918. */
  74919. vignetteEnabled: boolean;
  74920. private _applyByPostProcess;
  74921. /**
  74922. * Gets wether the image processing is applied through a post process or not.
  74923. */
  74924. /**
  74925. * Sets wether the image processing is applied through a post process or not.
  74926. */
  74927. applyByPostProcess: boolean;
  74928. private _isEnabled;
  74929. /**
  74930. * Gets wether the image processing is enabled or not.
  74931. */
  74932. /**
  74933. * Sets wether the image processing is enabled or not.
  74934. */
  74935. isEnabled: boolean;
  74936. /**
  74937. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  74938. */
  74939. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  74940. /**
  74941. * Method called each time the image processing information changes requires to recompile the effect.
  74942. */
  74943. protected _updateParameters(): void;
  74944. /**
  74945. * Gets the current class name.
  74946. * @return "ImageProcessingConfiguration"
  74947. */
  74948. getClassName(): string;
  74949. /**
  74950. * Prepare the list of uniforms associated with the Image Processing effects.
  74951. * @param uniforms The list of uniforms used in the effect
  74952. * @param defines the list of defines currently in use
  74953. */
  74954. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  74955. /**
  74956. * Prepare the list of samplers associated with the Image Processing effects.
  74957. * @param samplersList The list of uniforms used in the effect
  74958. * @param defines the list of defines currently in use
  74959. */
  74960. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  74961. /**
  74962. * Prepare the list of defines associated to the shader.
  74963. * @param defines the list of defines to complete
  74964. * @param forPostProcess Define if we are currently in post process mode or not
  74965. */
  74966. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  74967. /**
  74968. * Returns true if all the image processing information are ready.
  74969. * @returns True if ready, otherwise, false
  74970. */
  74971. isReady(): boolean;
  74972. /**
  74973. * Binds the image processing to the shader.
  74974. * @param effect The effect to bind to
  74975. * @param aspectRatio Define the current aspect ratio of the effect
  74976. */
  74977. bind(effect: Effect, aspectRatio?: number): void;
  74978. /**
  74979. * Clones the current image processing instance.
  74980. * @return The cloned image processing
  74981. */
  74982. clone(): ImageProcessingConfiguration;
  74983. /**
  74984. * Serializes the current image processing instance to a json representation.
  74985. * @return a JSON representation
  74986. */
  74987. serialize(): any;
  74988. /**
  74989. * Parses the image processing from a json representation.
  74990. * @param source the JSON source to parse
  74991. * @return The parsed image processing
  74992. */
  74993. static Parse(source: any): ImageProcessingConfiguration;
  74994. private static _VIGNETTEMODE_MULTIPLY;
  74995. private static _VIGNETTEMODE_OPAQUE;
  74996. /**
  74997. * Used to apply the vignette as a mix with the pixel color.
  74998. */
  74999. static readonly VIGNETTEMODE_MULTIPLY: number;
  75000. /**
  75001. * Used to apply the vignette as a replacement of the pixel color.
  75002. */
  75003. static readonly VIGNETTEMODE_OPAQUE: number;
  75004. }
  75005. }
  75006. declare module BABYLON {
  75007. /** @hidden */
  75008. export var postprocessVertexShader: {
  75009. name: string;
  75010. shader: string;
  75011. };
  75012. }
  75013. declare module BABYLON {
  75014. interface ThinEngine {
  75015. /**
  75016. * Creates a new render target texture
  75017. * @param size defines the size of the texture
  75018. * @param options defines the options used to create the texture
  75019. * @returns a new render target texture stored in an InternalTexture
  75020. */
  75021. createRenderTargetTexture(size: number | {
  75022. width: number;
  75023. height: number;
  75024. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  75025. }
  75026. }
  75027. declare module BABYLON {
  75028. /** Defines supported spaces */
  75029. export enum Space {
  75030. /** Local (object) space */
  75031. LOCAL = 0,
  75032. /** World space */
  75033. WORLD = 1,
  75034. /** Bone space */
  75035. BONE = 2
  75036. }
  75037. /** Defines the 3 main axes */
  75038. export class Axis {
  75039. /** X axis */
  75040. static X: Vector3;
  75041. /** Y axis */
  75042. static Y: Vector3;
  75043. /** Z axis */
  75044. static Z: Vector3;
  75045. }
  75046. }
  75047. declare module BABYLON {
  75048. /**
  75049. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75050. * This is the base of the follow, arc rotate cameras and Free camera
  75051. * @see http://doc.babylonjs.com/features/cameras
  75052. */
  75053. export class TargetCamera extends Camera {
  75054. private static _RigCamTransformMatrix;
  75055. private static _TargetTransformMatrix;
  75056. private static _TargetFocalPoint;
  75057. /**
  75058. * Define the current direction the camera is moving to
  75059. */
  75060. cameraDirection: Vector3;
  75061. /**
  75062. * Define the current rotation the camera is rotating to
  75063. */
  75064. cameraRotation: Vector2;
  75065. /**
  75066. * When set, the up vector of the camera will be updated by the rotation of the camera
  75067. */
  75068. updateUpVectorFromRotation: boolean;
  75069. private _tmpQuaternion;
  75070. /**
  75071. * Define the current rotation of the camera
  75072. */
  75073. rotation: Vector3;
  75074. /**
  75075. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75076. */
  75077. rotationQuaternion: Quaternion;
  75078. /**
  75079. * Define the current speed of the camera
  75080. */
  75081. speed: number;
  75082. /**
  75083. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75084. * around all axis.
  75085. */
  75086. noRotationConstraint: boolean;
  75087. /**
  75088. * Define the current target of the camera as an object or a position.
  75089. */
  75090. lockedTarget: any;
  75091. /** @hidden */
  75092. _currentTarget: Vector3;
  75093. /** @hidden */
  75094. _initialFocalDistance: number;
  75095. /** @hidden */
  75096. _viewMatrix: Matrix;
  75097. /** @hidden */
  75098. _camMatrix: Matrix;
  75099. /** @hidden */
  75100. _cameraTransformMatrix: Matrix;
  75101. /** @hidden */
  75102. _cameraRotationMatrix: Matrix;
  75103. /** @hidden */
  75104. _referencePoint: Vector3;
  75105. /** @hidden */
  75106. _transformedReferencePoint: Vector3;
  75107. protected _globalCurrentTarget: Vector3;
  75108. protected _globalCurrentUpVector: Vector3;
  75109. /** @hidden */
  75110. _reset: () => void;
  75111. private _defaultUp;
  75112. /**
  75113. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75114. * This is the base of the follow, arc rotate cameras and Free camera
  75115. * @see http://doc.babylonjs.com/features/cameras
  75116. * @param name Defines the name of the camera in the scene
  75117. * @param position Defines the start position of the camera in the scene
  75118. * @param scene Defines the scene the camera belongs to
  75119. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75120. */
  75121. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75122. /**
  75123. * Gets the position in front of the camera at a given distance.
  75124. * @param distance The distance from the camera we want the position to be
  75125. * @returns the position
  75126. */
  75127. getFrontPosition(distance: number): Vector3;
  75128. /** @hidden */
  75129. _getLockedTargetPosition(): Nullable<Vector3>;
  75130. private _storedPosition;
  75131. private _storedRotation;
  75132. private _storedRotationQuaternion;
  75133. /**
  75134. * Store current camera state of the camera (fov, position, rotation, etc..)
  75135. * @returns the camera
  75136. */
  75137. storeState(): Camera;
  75138. /**
  75139. * Restored camera state. You must call storeState() first
  75140. * @returns whether it was successful or not
  75141. * @hidden
  75142. */
  75143. _restoreStateValues(): boolean;
  75144. /** @hidden */
  75145. _initCache(): void;
  75146. /** @hidden */
  75147. _updateCache(ignoreParentClass?: boolean): void;
  75148. /** @hidden */
  75149. _isSynchronizedViewMatrix(): boolean;
  75150. /** @hidden */
  75151. _computeLocalCameraSpeed(): number;
  75152. /**
  75153. * Defines the target the camera should look at.
  75154. * @param target Defines the new target as a Vector or a mesh
  75155. */
  75156. setTarget(target: Vector3): void;
  75157. /**
  75158. * Return the current target position of the camera. This value is expressed in local space.
  75159. * @returns the target position
  75160. */
  75161. getTarget(): Vector3;
  75162. /** @hidden */
  75163. _decideIfNeedsToMove(): boolean;
  75164. /** @hidden */
  75165. _updatePosition(): void;
  75166. /** @hidden */
  75167. _checkInputs(): void;
  75168. protected _updateCameraRotationMatrix(): void;
  75169. /**
  75170. * 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)
  75171. * @returns the current camera
  75172. */
  75173. private _rotateUpVectorWithCameraRotationMatrix;
  75174. private _cachedRotationZ;
  75175. private _cachedQuaternionRotationZ;
  75176. /** @hidden */
  75177. _getViewMatrix(): Matrix;
  75178. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75179. /**
  75180. * @hidden
  75181. */
  75182. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75183. /**
  75184. * @hidden
  75185. */
  75186. _updateRigCameras(): void;
  75187. private _getRigCamPositionAndTarget;
  75188. /**
  75189. * Gets the current object class name.
  75190. * @return the class name
  75191. */
  75192. getClassName(): string;
  75193. }
  75194. }
  75195. declare module BABYLON {
  75196. /**
  75197. * Gather the list of keyboard event types as constants.
  75198. */
  75199. export class KeyboardEventTypes {
  75200. /**
  75201. * The keydown event is fired when a key becomes active (pressed).
  75202. */
  75203. static readonly KEYDOWN: number;
  75204. /**
  75205. * The keyup event is fired when a key has been released.
  75206. */
  75207. static readonly KEYUP: number;
  75208. }
  75209. /**
  75210. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75211. */
  75212. export class KeyboardInfo {
  75213. /**
  75214. * Defines the type of event (KeyboardEventTypes)
  75215. */
  75216. type: number;
  75217. /**
  75218. * Defines the related dom event
  75219. */
  75220. event: KeyboardEvent;
  75221. /**
  75222. * Instantiates a new keyboard info.
  75223. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75224. * @param type Defines the type of event (KeyboardEventTypes)
  75225. * @param event Defines the related dom event
  75226. */
  75227. constructor(
  75228. /**
  75229. * Defines the type of event (KeyboardEventTypes)
  75230. */
  75231. type: number,
  75232. /**
  75233. * Defines the related dom event
  75234. */
  75235. event: KeyboardEvent);
  75236. }
  75237. /**
  75238. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75239. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75240. */
  75241. export class KeyboardInfoPre extends KeyboardInfo {
  75242. /**
  75243. * Defines the type of event (KeyboardEventTypes)
  75244. */
  75245. type: number;
  75246. /**
  75247. * Defines the related dom event
  75248. */
  75249. event: KeyboardEvent;
  75250. /**
  75251. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75252. */
  75253. skipOnPointerObservable: boolean;
  75254. /**
  75255. * Instantiates a new keyboard pre info.
  75256. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75257. * @param type Defines the type of event (KeyboardEventTypes)
  75258. * @param event Defines the related dom event
  75259. */
  75260. constructor(
  75261. /**
  75262. * Defines the type of event (KeyboardEventTypes)
  75263. */
  75264. type: number,
  75265. /**
  75266. * Defines the related dom event
  75267. */
  75268. event: KeyboardEvent);
  75269. }
  75270. }
  75271. declare module BABYLON {
  75272. /**
  75273. * Manage the keyboard inputs to control the movement of a free camera.
  75274. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75275. */
  75276. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75277. /**
  75278. * Defines the camera the input is attached to.
  75279. */
  75280. camera: FreeCamera;
  75281. /**
  75282. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75283. */
  75284. keysUp: number[];
  75285. /**
  75286. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75287. */
  75288. keysDown: number[];
  75289. /**
  75290. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75291. */
  75292. keysLeft: number[];
  75293. /**
  75294. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75295. */
  75296. keysRight: number[];
  75297. private _keys;
  75298. private _onCanvasBlurObserver;
  75299. private _onKeyboardObserver;
  75300. private _engine;
  75301. private _scene;
  75302. /**
  75303. * Attach the input controls to a specific dom element to get the input from.
  75304. * @param element Defines the element the controls should be listened from
  75305. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75306. */
  75307. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75308. /**
  75309. * Detach the current controls from the specified dom element.
  75310. * @param element Defines the element to stop listening the inputs from
  75311. */
  75312. detachControl(element: Nullable<HTMLElement>): void;
  75313. /**
  75314. * Update the current camera state depending on the inputs that have been used this frame.
  75315. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75316. */
  75317. checkInputs(): void;
  75318. /**
  75319. * Gets the class name of the current intput.
  75320. * @returns the class name
  75321. */
  75322. getClassName(): string;
  75323. /** @hidden */
  75324. _onLostFocus(): void;
  75325. /**
  75326. * Get the friendly name associated with the input class.
  75327. * @returns the input friendly name
  75328. */
  75329. getSimpleName(): string;
  75330. }
  75331. }
  75332. declare module BABYLON {
  75333. /**
  75334. * Interface describing all the common properties and methods a shadow light needs to implement.
  75335. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75336. * as well as binding the different shadow properties to the effects.
  75337. */
  75338. export interface IShadowLight extends Light {
  75339. /**
  75340. * The light id in the scene (used in scene.findLighById for instance)
  75341. */
  75342. id: string;
  75343. /**
  75344. * The position the shdow will be casted from.
  75345. */
  75346. position: Vector3;
  75347. /**
  75348. * In 2d mode (needCube being false), the direction used to cast the shadow.
  75349. */
  75350. direction: Vector3;
  75351. /**
  75352. * The transformed position. Position of the light in world space taking parenting in account.
  75353. */
  75354. transformedPosition: Vector3;
  75355. /**
  75356. * The transformed direction. Direction of the light in world space taking parenting in account.
  75357. */
  75358. transformedDirection: Vector3;
  75359. /**
  75360. * The friendly name of the light in the scene.
  75361. */
  75362. name: string;
  75363. /**
  75364. * Defines the shadow projection clipping minimum z value.
  75365. */
  75366. shadowMinZ: number;
  75367. /**
  75368. * Defines the shadow projection clipping maximum z value.
  75369. */
  75370. shadowMaxZ: number;
  75371. /**
  75372. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75373. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75374. */
  75375. computeTransformedInformation(): boolean;
  75376. /**
  75377. * Gets the scene the light belongs to.
  75378. * @returns The scene
  75379. */
  75380. getScene(): Scene;
  75381. /**
  75382. * Callback defining a custom Projection Matrix Builder.
  75383. * This can be used to override the default projection matrix computation.
  75384. */
  75385. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75386. /**
  75387. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75388. * @param matrix The materix to updated with the projection information
  75389. * @param viewMatrix The transform matrix of the light
  75390. * @param renderList The list of mesh to render in the map
  75391. * @returns The current light
  75392. */
  75393. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75394. /**
  75395. * Gets the current depth scale used in ESM.
  75396. * @returns The scale
  75397. */
  75398. getDepthScale(): number;
  75399. /**
  75400. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75401. * @returns true if a cube texture needs to be use
  75402. */
  75403. needCube(): boolean;
  75404. /**
  75405. * Detects if the projection matrix requires to be recomputed this frame.
  75406. * @returns true if it requires to be recomputed otherwise, false.
  75407. */
  75408. needProjectionMatrixCompute(): boolean;
  75409. /**
  75410. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75411. */
  75412. forceProjectionMatrixCompute(): void;
  75413. /**
  75414. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75415. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75416. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75417. */
  75418. getShadowDirection(faceIndex?: number): Vector3;
  75419. /**
  75420. * Gets the minZ used for shadow according to both the scene and the light.
  75421. * @param activeCamera The camera we are returning the min for
  75422. * @returns the depth min z
  75423. */
  75424. getDepthMinZ(activeCamera: Camera): number;
  75425. /**
  75426. * Gets the maxZ used for shadow according to both the scene and the light.
  75427. * @param activeCamera The camera we are returning the max for
  75428. * @returns the depth max z
  75429. */
  75430. getDepthMaxZ(activeCamera: Camera): number;
  75431. }
  75432. /**
  75433. * Base implementation IShadowLight
  75434. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  75435. */
  75436. export abstract class ShadowLight extends Light implements IShadowLight {
  75437. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  75438. protected _position: Vector3;
  75439. protected _setPosition(value: Vector3): void;
  75440. /**
  75441. * Sets the position the shadow will be casted from. Also use as the light position for both
  75442. * point and spot lights.
  75443. */
  75444. /**
  75445. * Sets the position the shadow will be casted from. Also use as the light position for both
  75446. * point and spot lights.
  75447. */
  75448. position: Vector3;
  75449. protected _direction: Vector3;
  75450. protected _setDirection(value: Vector3): void;
  75451. /**
  75452. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  75453. * Also use as the light direction on spot and directional lights.
  75454. */
  75455. /**
  75456. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  75457. * Also use as the light direction on spot and directional lights.
  75458. */
  75459. direction: Vector3;
  75460. private _shadowMinZ;
  75461. /**
  75462. * Gets the shadow projection clipping minimum z value.
  75463. */
  75464. /**
  75465. * Sets the shadow projection clipping minimum z value.
  75466. */
  75467. shadowMinZ: number;
  75468. private _shadowMaxZ;
  75469. /**
  75470. * Sets the shadow projection clipping maximum z value.
  75471. */
  75472. /**
  75473. * Gets the shadow projection clipping maximum z value.
  75474. */
  75475. shadowMaxZ: number;
  75476. /**
  75477. * Callback defining a custom Projection Matrix Builder.
  75478. * This can be used to override the default projection matrix computation.
  75479. */
  75480. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75481. /**
  75482. * The transformed position. Position of the light in world space taking parenting in account.
  75483. */
  75484. transformedPosition: Vector3;
  75485. /**
  75486. * The transformed direction. Direction of the light in world space taking parenting in account.
  75487. */
  75488. transformedDirection: Vector3;
  75489. private _needProjectionMatrixCompute;
  75490. /**
  75491. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75492. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75493. */
  75494. computeTransformedInformation(): boolean;
  75495. /**
  75496. * Return the depth scale used for the shadow map.
  75497. * @returns the depth scale.
  75498. */
  75499. getDepthScale(): number;
  75500. /**
  75501. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75502. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75503. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75504. */
  75505. getShadowDirection(faceIndex?: number): Vector3;
  75506. /**
  75507. * Returns the ShadowLight absolute position in the World.
  75508. * @returns the position vector in world space
  75509. */
  75510. getAbsolutePosition(): Vector3;
  75511. /**
  75512. * Sets the ShadowLight direction toward the passed target.
  75513. * @param target The point to target in local space
  75514. * @returns the updated ShadowLight direction
  75515. */
  75516. setDirectionToTarget(target: Vector3): Vector3;
  75517. /**
  75518. * Returns the light rotation in euler definition.
  75519. * @returns the x y z rotation in local space.
  75520. */
  75521. getRotation(): Vector3;
  75522. /**
  75523. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75524. * @returns true if a cube texture needs to be use
  75525. */
  75526. needCube(): boolean;
  75527. /**
  75528. * Detects if the projection matrix requires to be recomputed this frame.
  75529. * @returns true if it requires to be recomputed otherwise, false.
  75530. */
  75531. needProjectionMatrixCompute(): boolean;
  75532. /**
  75533. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75534. */
  75535. forceProjectionMatrixCompute(): void;
  75536. /** @hidden */
  75537. _initCache(): void;
  75538. /** @hidden */
  75539. _isSynchronized(): boolean;
  75540. /**
  75541. * Computes the world matrix of the node
  75542. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75543. * @returns the world matrix
  75544. */
  75545. computeWorldMatrix(force?: boolean): Matrix;
  75546. /**
  75547. * Gets the minZ used for shadow according to both the scene and the light.
  75548. * @param activeCamera The camera we are returning the min for
  75549. * @returns the depth min z
  75550. */
  75551. getDepthMinZ(activeCamera: Camera): number;
  75552. /**
  75553. * Gets the maxZ used for shadow according to both the scene and the light.
  75554. * @param activeCamera The camera we are returning the max for
  75555. * @returns the depth max z
  75556. */
  75557. getDepthMaxZ(activeCamera: Camera): number;
  75558. /**
  75559. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75560. * @param matrix The materix to updated with the projection information
  75561. * @param viewMatrix The transform matrix of the light
  75562. * @param renderList The list of mesh to render in the map
  75563. * @returns The current light
  75564. */
  75565. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75566. }
  75567. }
  75568. declare module BABYLON {
  75569. /**
  75570. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  75571. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  75572. */
  75573. export class EffectFallbacks implements IEffectFallbacks {
  75574. private _defines;
  75575. private _currentRank;
  75576. private _maxRank;
  75577. private _mesh;
  75578. /**
  75579. * Removes the fallback from the bound mesh.
  75580. */
  75581. unBindMesh(): void;
  75582. /**
  75583. * Adds a fallback on the specified property.
  75584. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75585. * @param define The name of the define in the shader
  75586. */
  75587. addFallback(rank: number, define: string): void;
  75588. /**
  75589. * Sets the mesh to use CPU skinning when needing to fallback.
  75590. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75591. * @param mesh The mesh to use the fallbacks.
  75592. */
  75593. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  75594. /**
  75595. * Checks to see if more fallbacks are still availible.
  75596. */
  75597. readonly hasMoreFallbacks: boolean;
  75598. /**
  75599. * Removes the defines that should be removed when falling back.
  75600. * @param currentDefines defines the current define statements for the shader.
  75601. * @param effect defines the current effect we try to compile
  75602. * @returns The resulting defines with defines of the current rank removed.
  75603. */
  75604. reduce(currentDefines: string, effect: Effect): string;
  75605. }
  75606. }
  75607. declare module BABYLON {
  75608. /**
  75609. * "Static Class" containing the most commonly used helper while dealing with material for
  75610. * rendering purpose.
  75611. *
  75612. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  75613. *
  75614. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  75615. */
  75616. export class MaterialHelper {
  75617. /**
  75618. * Bind the current view position to an effect.
  75619. * @param effect The effect to be bound
  75620. * @param scene The scene the eyes position is used from
  75621. */
  75622. static BindEyePosition(effect: Effect, scene: Scene): void;
  75623. /**
  75624. * Helps preparing the defines values about the UVs in used in the effect.
  75625. * UVs are shared as much as we can accross channels in the shaders.
  75626. * @param texture The texture we are preparing the UVs for
  75627. * @param defines The defines to update
  75628. * @param key The channel key "diffuse", "specular"... used in the shader
  75629. */
  75630. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  75631. /**
  75632. * Binds a texture matrix value to its corrsponding uniform
  75633. * @param texture The texture to bind the matrix for
  75634. * @param uniformBuffer The uniform buffer receivin the data
  75635. * @param key The channel key "diffuse", "specular"... used in the shader
  75636. */
  75637. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  75638. /**
  75639. * Gets the current status of the fog (should it be enabled?)
  75640. * @param mesh defines the mesh to evaluate for fog support
  75641. * @param scene defines the hosting scene
  75642. * @returns true if fog must be enabled
  75643. */
  75644. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  75645. /**
  75646. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  75647. * @param mesh defines the current mesh
  75648. * @param scene defines the current scene
  75649. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  75650. * @param pointsCloud defines if point cloud rendering has to be turned on
  75651. * @param fogEnabled defines if fog has to be turned on
  75652. * @param alphaTest defines if alpha testing has to be turned on
  75653. * @param defines defines the current list of defines
  75654. */
  75655. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  75656. /**
  75657. * Helper used to prepare the list of defines associated with frame values for shader compilation
  75658. * @param scene defines the current scene
  75659. * @param engine defines the current engine
  75660. * @param defines specifies the list of active defines
  75661. * @param useInstances defines if instances have to be turned on
  75662. * @param useClipPlane defines if clip plane have to be turned on
  75663. */
  75664. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  75665. /**
  75666. * Prepares the defines for bones
  75667. * @param mesh The mesh containing the geometry data we will draw
  75668. * @param defines The defines to update
  75669. */
  75670. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  75671. /**
  75672. * Prepares the defines for morph targets
  75673. * @param mesh The mesh containing the geometry data we will draw
  75674. * @param defines The defines to update
  75675. */
  75676. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  75677. /**
  75678. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  75679. * @param mesh The mesh containing the geometry data we will draw
  75680. * @param defines The defines to update
  75681. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  75682. * @param useBones Precise whether bones should be used or not (override mesh info)
  75683. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  75684. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  75685. * @returns false if defines are considered not dirty and have not been checked
  75686. */
  75687. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  75688. /**
  75689. * Prepares the defines related to multiview
  75690. * @param scene The scene we are intending to draw
  75691. * @param defines The defines to update
  75692. */
  75693. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  75694. /**
  75695. * Prepares the defines related to the light information passed in parameter
  75696. * @param scene The scene we are intending to draw
  75697. * @param mesh The mesh the effect is compiling for
  75698. * @param light The light the effect is compiling for
  75699. * @param lightIndex The index of the light
  75700. * @param defines The defines to update
  75701. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75702. * @param state Defines the current state regarding what is needed (normals, etc...)
  75703. */
  75704. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  75705. needNormals: boolean;
  75706. needRebuild: boolean;
  75707. shadowEnabled: boolean;
  75708. specularEnabled: boolean;
  75709. lightmapMode: boolean;
  75710. }): void;
  75711. /**
  75712. * Prepares the defines related to the light information passed in parameter
  75713. * @param scene The scene we are intending to draw
  75714. * @param mesh The mesh the effect is compiling for
  75715. * @param defines The defines to update
  75716. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75717. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  75718. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  75719. * @returns true if normals will be required for the rest of the effect
  75720. */
  75721. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  75722. /**
  75723. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  75724. * @param lightIndex defines the light index
  75725. * @param uniformsList The uniform list
  75726. * @param samplersList The sampler list
  75727. * @param projectedLightTexture defines if projected texture must be used
  75728. * @param uniformBuffersList defines an optional list of uniform buffers
  75729. */
  75730. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  75731. /**
  75732. * Prepares the uniforms and samplers list to be used in the effect
  75733. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  75734. * @param samplersList The sampler list
  75735. * @param defines The defines helping in the list generation
  75736. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  75737. */
  75738. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  75739. /**
  75740. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  75741. * @param defines The defines to update while falling back
  75742. * @param fallbacks The authorized effect fallbacks
  75743. * @param maxSimultaneousLights The maximum number of lights allowed
  75744. * @param rank the current rank of the Effect
  75745. * @returns The newly affected rank
  75746. */
  75747. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  75748. private static _TmpMorphInfluencers;
  75749. /**
  75750. * Prepares the list of attributes required for morph targets according to the effect defines.
  75751. * @param attribs The current list of supported attribs
  75752. * @param mesh The mesh to prepare the morph targets attributes for
  75753. * @param influencers The number of influencers
  75754. */
  75755. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  75756. /**
  75757. * Prepares the list of attributes required for morph targets according to the effect defines.
  75758. * @param attribs The current list of supported attribs
  75759. * @param mesh The mesh to prepare the morph targets attributes for
  75760. * @param defines The current Defines of the effect
  75761. */
  75762. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  75763. /**
  75764. * Prepares the list of attributes required for bones according to the effect defines.
  75765. * @param attribs The current list of supported attribs
  75766. * @param mesh The mesh to prepare the bones attributes for
  75767. * @param defines The current Defines of the effect
  75768. * @param fallbacks The current efffect fallback strategy
  75769. */
  75770. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  75771. /**
  75772. * Check and prepare the list of attributes required for instances according to the effect defines.
  75773. * @param attribs The current list of supported attribs
  75774. * @param defines The current MaterialDefines of the effect
  75775. */
  75776. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  75777. /**
  75778. * Add the list of attributes required for instances to the attribs array.
  75779. * @param attribs The current list of supported attribs
  75780. */
  75781. static PushAttributesForInstances(attribs: string[]): void;
  75782. /**
  75783. * Binds the light shadow information to the effect for the given mesh.
  75784. * @param light The light containing the generator
  75785. * @param scene The scene the lights belongs to
  75786. * @param mesh The mesh we are binding the information to render
  75787. * @param lightIndex The light index in the effect used to render the mesh
  75788. * @param effect The effect we are binding the data to
  75789. */
  75790. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  75791. /**
  75792. * Binds the light information to the effect.
  75793. * @param light The light containing the generator
  75794. * @param effect The effect we are binding the data to
  75795. * @param lightIndex The light index in the effect used to render
  75796. */
  75797. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  75798. /**
  75799. * Binds the lights information from the scene to the effect for the given mesh.
  75800. * @param light Light to bind
  75801. * @param lightIndex Light index
  75802. * @param scene The scene where the light belongs to
  75803. * @param mesh The mesh we are binding the information to render
  75804. * @param effect The effect we are binding the data to
  75805. * @param useSpecular Defines if specular is supported
  75806. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75807. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75808. */
  75809. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75810. /**
  75811. * Binds the lights information from the scene to the effect for the given mesh.
  75812. * @param scene The scene the lights belongs to
  75813. * @param mesh The mesh we are binding the information to render
  75814. * @param effect The effect we are binding the data to
  75815. * @param defines The generated defines for the effect
  75816. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  75817. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75818. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75819. */
  75820. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75821. private static _tempFogColor;
  75822. /**
  75823. * Binds the fog information from the scene to the effect for the given mesh.
  75824. * @param scene The scene the lights belongs to
  75825. * @param mesh The mesh we are binding the information to render
  75826. * @param effect The effect we are binding the data to
  75827. * @param linearSpace Defines if the fog effect is applied in linear space
  75828. */
  75829. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  75830. /**
  75831. * Binds the bones information from the mesh to the effect.
  75832. * @param mesh The mesh we are binding the information to render
  75833. * @param effect The effect we are binding the data to
  75834. */
  75835. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  75836. /**
  75837. * Binds the morph targets information from the mesh to the effect.
  75838. * @param abstractMesh The mesh we are binding the information to render
  75839. * @param effect The effect we are binding the data to
  75840. */
  75841. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  75842. /**
  75843. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  75844. * @param defines The generated defines used in the effect
  75845. * @param effect The effect we are binding the data to
  75846. * @param scene The scene we are willing to render with logarithmic scale for
  75847. */
  75848. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  75849. /**
  75850. * Binds the clip plane information from the scene to the effect.
  75851. * @param scene The scene the clip plane information are extracted from
  75852. * @param effect The effect we are binding the data to
  75853. */
  75854. static BindClipPlane(effect: Effect, scene: Scene): void;
  75855. }
  75856. }
  75857. declare module BABYLON {
  75858. /** @hidden */
  75859. export var packingFunctions: {
  75860. name: string;
  75861. shader: string;
  75862. };
  75863. }
  75864. declare module BABYLON {
  75865. /** @hidden */
  75866. export var shadowMapPixelShader: {
  75867. name: string;
  75868. shader: string;
  75869. };
  75870. }
  75871. declare module BABYLON {
  75872. /** @hidden */
  75873. export var bonesDeclaration: {
  75874. name: string;
  75875. shader: string;
  75876. };
  75877. }
  75878. declare module BABYLON {
  75879. /** @hidden */
  75880. export var morphTargetsVertexGlobalDeclaration: {
  75881. name: string;
  75882. shader: string;
  75883. };
  75884. }
  75885. declare module BABYLON {
  75886. /** @hidden */
  75887. export var morphTargetsVertexDeclaration: {
  75888. name: string;
  75889. shader: string;
  75890. };
  75891. }
  75892. declare module BABYLON {
  75893. /** @hidden */
  75894. export var instancesDeclaration: {
  75895. name: string;
  75896. shader: string;
  75897. };
  75898. }
  75899. declare module BABYLON {
  75900. /** @hidden */
  75901. export var helperFunctions: {
  75902. name: string;
  75903. shader: string;
  75904. };
  75905. }
  75906. declare module BABYLON {
  75907. /** @hidden */
  75908. export var morphTargetsVertex: {
  75909. name: string;
  75910. shader: string;
  75911. };
  75912. }
  75913. declare module BABYLON {
  75914. /** @hidden */
  75915. export var instancesVertex: {
  75916. name: string;
  75917. shader: string;
  75918. };
  75919. }
  75920. declare module BABYLON {
  75921. /** @hidden */
  75922. export var bonesVertex: {
  75923. name: string;
  75924. shader: string;
  75925. };
  75926. }
  75927. declare module BABYLON {
  75928. /** @hidden */
  75929. export var shadowMapVertexShader: {
  75930. name: string;
  75931. shader: string;
  75932. };
  75933. }
  75934. declare module BABYLON {
  75935. /** @hidden */
  75936. export var depthBoxBlurPixelShader: {
  75937. name: string;
  75938. shader: string;
  75939. };
  75940. }
  75941. declare module BABYLON {
  75942. /**
  75943. * Defines the options associated with the creation of a custom shader for a shadow generator.
  75944. */
  75945. export interface ICustomShaderOptions {
  75946. /**
  75947. * Gets or sets the custom shader name to use
  75948. */
  75949. shaderName: string;
  75950. /**
  75951. * The list of attribute names used in the shader
  75952. */
  75953. attributes?: string[];
  75954. /**
  75955. * The list of unifrom names used in the shader
  75956. */
  75957. uniforms?: string[];
  75958. /**
  75959. * The list of sampler names used in the shader
  75960. */
  75961. samplers?: string[];
  75962. /**
  75963. * The list of defines used in the shader
  75964. */
  75965. defines?: string[];
  75966. }
  75967. /**
  75968. * Interface to implement to create a shadow generator compatible with BJS.
  75969. */
  75970. export interface IShadowGenerator {
  75971. /**
  75972. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75973. * @returns The render target texture if present otherwise, null
  75974. */
  75975. getShadowMap(): Nullable<RenderTargetTexture>;
  75976. /**
  75977. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75978. * @returns The render target texture if the shadow map is present otherwise, null
  75979. */
  75980. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75981. /**
  75982. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75983. * @param subMesh The submesh we want to render in the shadow map
  75984. * @param useInstances Defines wether will draw in the map using instances
  75985. * @returns true if ready otherwise, false
  75986. */
  75987. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75988. /**
  75989. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75990. * @param defines Defines of the material we want to update
  75991. * @param lightIndex Index of the light in the enabled light list of the material
  75992. */
  75993. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  75994. /**
  75995. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75996. * defined in the generator but impacting the effect).
  75997. * It implies the unifroms available on the materials are the standard BJS ones.
  75998. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75999. * @param effect The effect we are binfing the information for
  76000. */
  76001. bindShadowLight(lightIndex: string, effect: Effect): void;
  76002. /**
  76003. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76004. * (eq to shadow prjection matrix * light transform matrix)
  76005. * @returns The transform matrix used to create the shadow map
  76006. */
  76007. getTransformMatrix(): Matrix;
  76008. /**
  76009. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76010. * Cube and 2D textures for instance.
  76011. */
  76012. recreateShadowMap(): void;
  76013. /**
  76014. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76015. * @param onCompiled Callback triggered at the and of the effects compilation
  76016. * @param options Sets of optional options forcing the compilation with different modes
  76017. */
  76018. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76019. useInstances: boolean;
  76020. }>): void;
  76021. /**
  76022. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76023. * @param options Sets of optional options forcing the compilation with different modes
  76024. * @returns A promise that resolves when the compilation completes
  76025. */
  76026. forceCompilationAsync(options?: Partial<{
  76027. useInstances: boolean;
  76028. }>): Promise<void>;
  76029. /**
  76030. * Serializes the shadow generator setup to a json object.
  76031. * @returns The serialized JSON object
  76032. */
  76033. serialize(): any;
  76034. /**
  76035. * Disposes the Shadow map and related Textures and effects.
  76036. */
  76037. dispose(): void;
  76038. }
  76039. /**
  76040. * Default implementation IShadowGenerator.
  76041. * This is the main object responsible of generating shadows in the framework.
  76042. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76043. */
  76044. export class ShadowGenerator implements IShadowGenerator {
  76045. /**
  76046. * Shadow generator mode None: no filtering applied.
  76047. */
  76048. static readonly FILTER_NONE: number;
  76049. /**
  76050. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76051. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76052. */
  76053. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76054. /**
  76055. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76056. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76057. */
  76058. static readonly FILTER_POISSONSAMPLING: number;
  76059. /**
  76060. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76061. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76062. */
  76063. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76064. /**
  76065. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76066. * edge artifacts on steep falloff.
  76067. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76068. */
  76069. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76070. /**
  76071. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76072. * edge artifacts on steep falloff.
  76073. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76074. */
  76075. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76076. /**
  76077. * Shadow generator mode PCF: Percentage Closer Filtering
  76078. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76079. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76080. */
  76081. static readonly FILTER_PCF: number;
  76082. /**
  76083. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76084. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76085. * Contact Hardening
  76086. */
  76087. static readonly FILTER_PCSS: number;
  76088. /**
  76089. * Reserved for PCF and PCSS
  76090. * Highest Quality.
  76091. *
  76092. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76093. *
  76094. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76095. */
  76096. static readonly QUALITY_HIGH: number;
  76097. /**
  76098. * Reserved for PCF and PCSS
  76099. * Good tradeoff for quality/perf cross devices
  76100. *
  76101. * Execute PCF on a 3*3 kernel.
  76102. *
  76103. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76104. */
  76105. static readonly QUALITY_MEDIUM: number;
  76106. /**
  76107. * Reserved for PCF and PCSS
  76108. * The lowest quality but the fastest.
  76109. *
  76110. * Execute PCF on a 1*1 kernel.
  76111. *
  76112. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76113. */
  76114. static readonly QUALITY_LOW: number;
  76115. /** Gets or sets the custom shader name to use */
  76116. customShaderOptions: ICustomShaderOptions;
  76117. /**
  76118. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76119. */
  76120. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76121. /**
  76122. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76123. */
  76124. onAfterShadowMapRenderObservable: Observable<Effect>;
  76125. /**
  76126. * Observable triggered before a mesh is rendered in the shadow map.
  76127. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76128. */
  76129. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76130. /**
  76131. * Observable triggered after a mesh is rendered in the shadow map.
  76132. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76133. */
  76134. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76135. private _bias;
  76136. /**
  76137. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76138. */
  76139. /**
  76140. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76141. */
  76142. bias: number;
  76143. private _normalBias;
  76144. /**
  76145. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76146. */
  76147. /**
  76148. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76149. */
  76150. normalBias: number;
  76151. private _blurBoxOffset;
  76152. /**
  76153. * Gets the blur box offset: offset applied during the blur pass.
  76154. * Only useful if useKernelBlur = false
  76155. */
  76156. /**
  76157. * Sets the blur box offset: offset applied during the blur pass.
  76158. * Only useful if useKernelBlur = false
  76159. */
  76160. blurBoxOffset: number;
  76161. private _blurScale;
  76162. /**
  76163. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76164. * 2 means half of the size.
  76165. */
  76166. /**
  76167. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76168. * 2 means half of the size.
  76169. */
  76170. blurScale: number;
  76171. private _blurKernel;
  76172. /**
  76173. * Gets the blur kernel: kernel size of the blur pass.
  76174. * Only useful if useKernelBlur = true
  76175. */
  76176. /**
  76177. * Sets the blur kernel: kernel size of the blur pass.
  76178. * Only useful if useKernelBlur = true
  76179. */
  76180. blurKernel: number;
  76181. private _useKernelBlur;
  76182. /**
  76183. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76184. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76185. */
  76186. /**
  76187. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76188. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76189. */
  76190. useKernelBlur: boolean;
  76191. private _depthScale;
  76192. /**
  76193. * Gets the depth scale used in ESM mode.
  76194. */
  76195. /**
  76196. * Sets the depth scale used in ESM mode.
  76197. * This can override the scale stored on the light.
  76198. */
  76199. depthScale: number;
  76200. private _filter;
  76201. /**
  76202. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76203. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76204. */
  76205. /**
  76206. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76207. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76208. */
  76209. filter: number;
  76210. /**
  76211. * Gets if the current filter is set to Poisson Sampling.
  76212. */
  76213. /**
  76214. * Sets the current filter to Poisson Sampling.
  76215. */
  76216. usePoissonSampling: boolean;
  76217. /**
  76218. * Gets if the current filter is set to ESM.
  76219. */
  76220. /**
  76221. * Sets the current filter is to ESM.
  76222. */
  76223. useExponentialShadowMap: boolean;
  76224. /**
  76225. * Gets if the current filter is set to filtered ESM.
  76226. */
  76227. /**
  76228. * Gets if the current filter is set to filtered ESM.
  76229. */
  76230. useBlurExponentialShadowMap: boolean;
  76231. /**
  76232. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76233. * exponential to prevent steep falloff artifacts).
  76234. */
  76235. /**
  76236. * Sets the current filter to "close ESM" (using the inverse of the
  76237. * exponential to prevent steep falloff artifacts).
  76238. */
  76239. useCloseExponentialShadowMap: boolean;
  76240. /**
  76241. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76242. * exponential to prevent steep falloff artifacts).
  76243. */
  76244. /**
  76245. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76246. * exponential to prevent steep falloff artifacts).
  76247. */
  76248. useBlurCloseExponentialShadowMap: boolean;
  76249. /**
  76250. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76251. */
  76252. /**
  76253. * Sets the current filter to "PCF" (percentage closer filtering).
  76254. */
  76255. usePercentageCloserFiltering: boolean;
  76256. private _filteringQuality;
  76257. /**
  76258. * Gets the PCF or PCSS Quality.
  76259. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76260. */
  76261. /**
  76262. * Sets the PCF or PCSS Quality.
  76263. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76264. */
  76265. filteringQuality: number;
  76266. /**
  76267. * Gets if the current filter is set to "PCSS" (contact hardening).
  76268. */
  76269. /**
  76270. * Sets the current filter to "PCSS" (contact hardening).
  76271. */
  76272. useContactHardeningShadow: boolean;
  76273. private _contactHardeningLightSizeUVRatio;
  76274. /**
  76275. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76276. * Using a ratio helps keeping shape stability independently of the map size.
  76277. *
  76278. * It does not account for the light projection as it was having too much
  76279. * instability during the light setup or during light position changes.
  76280. *
  76281. * Only valid if useContactHardeningShadow is true.
  76282. */
  76283. /**
  76284. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76285. * Using a ratio helps keeping shape stability independently of the map size.
  76286. *
  76287. * It does not account for the light projection as it was having too much
  76288. * instability during the light setup or during light position changes.
  76289. *
  76290. * Only valid if useContactHardeningShadow is true.
  76291. */
  76292. contactHardeningLightSizeUVRatio: number;
  76293. private _darkness;
  76294. /** Gets or sets the actual darkness of a shadow */
  76295. darkness: number;
  76296. /**
  76297. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76298. * 0 means strongest and 1 would means no shadow.
  76299. * @returns the darkness.
  76300. */
  76301. getDarkness(): number;
  76302. /**
  76303. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76304. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76305. * @returns the shadow generator allowing fluent coding.
  76306. */
  76307. setDarkness(darkness: number): ShadowGenerator;
  76308. private _transparencyShadow;
  76309. /** Gets or sets the ability to have transparent shadow */
  76310. transparencyShadow: boolean;
  76311. /**
  76312. * Sets the ability to have transparent shadow (boolean).
  76313. * @param transparent True if transparent else False
  76314. * @returns the shadow generator allowing fluent coding
  76315. */
  76316. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76317. private _shadowMap;
  76318. private _shadowMap2;
  76319. /**
  76320. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76321. * @returns The render target texture if present otherwise, null
  76322. */
  76323. getShadowMap(): Nullable<RenderTargetTexture>;
  76324. /**
  76325. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76326. * @returns The render target texture if the shadow map is present otherwise, null
  76327. */
  76328. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76329. /**
  76330. * Gets the class name of that object
  76331. * @returns "ShadowGenerator"
  76332. */
  76333. getClassName(): string;
  76334. /**
  76335. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76336. * @param mesh Mesh to add
  76337. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76338. * @returns the Shadow Generator itself
  76339. */
  76340. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76341. /**
  76342. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76343. * @param mesh Mesh to remove
  76344. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76345. * @returns the Shadow Generator itself
  76346. */
  76347. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76348. /**
  76349. * Controls the extent to which the shadows fade out at the edge of the frustum
  76350. * Used only by directionals and spots
  76351. */
  76352. frustumEdgeFalloff: number;
  76353. private _light;
  76354. /**
  76355. * Returns the associated light object.
  76356. * @returns the light generating the shadow
  76357. */
  76358. getLight(): IShadowLight;
  76359. /**
  76360. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  76361. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  76362. * It might on the other hand introduce peter panning.
  76363. */
  76364. forceBackFacesOnly: boolean;
  76365. private _scene;
  76366. private _lightDirection;
  76367. private _effect;
  76368. private _viewMatrix;
  76369. private _projectionMatrix;
  76370. private _transformMatrix;
  76371. private _cachedPosition;
  76372. private _cachedDirection;
  76373. private _cachedDefines;
  76374. private _currentRenderID;
  76375. private _boxBlurPostprocess;
  76376. private _kernelBlurXPostprocess;
  76377. private _kernelBlurYPostprocess;
  76378. private _blurPostProcesses;
  76379. private _mapSize;
  76380. private _currentFaceIndex;
  76381. private _currentFaceIndexCache;
  76382. private _textureType;
  76383. private _defaultTextureMatrix;
  76384. private _storedUniqueId;
  76385. /** @hidden */
  76386. static _SceneComponentInitialization: (scene: Scene) => void;
  76387. /**
  76388. * Creates a ShadowGenerator object.
  76389. * A ShadowGenerator is the required tool to use the shadows.
  76390. * Each light casting shadows needs to use its own ShadowGenerator.
  76391. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  76392. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  76393. * @param light The light object generating the shadows.
  76394. * @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.
  76395. */
  76396. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  76397. private _initializeGenerator;
  76398. private _initializeShadowMap;
  76399. private _initializeBlurRTTAndPostProcesses;
  76400. private _renderForShadowMap;
  76401. private _renderSubMeshForShadowMap;
  76402. private _applyFilterValues;
  76403. /**
  76404. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76405. * @param onCompiled Callback triggered at the and of the effects compilation
  76406. * @param options Sets of optional options forcing the compilation with different modes
  76407. */
  76408. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76409. useInstances: boolean;
  76410. }>): void;
  76411. /**
  76412. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76413. * @param options Sets of optional options forcing the compilation with different modes
  76414. * @returns A promise that resolves when the compilation completes
  76415. */
  76416. forceCompilationAsync(options?: Partial<{
  76417. useInstances: boolean;
  76418. }>): Promise<void>;
  76419. /**
  76420. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76421. * @param subMesh The submesh we want to render in the shadow map
  76422. * @param useInstances Defines wether will draw in the map using instances
  76423. * @returns true if ready otherwise, false
  76424. */
  76425. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76426. /**
  76427. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76428. * @param defines Defines of the material we want to update
  76429. * @param lightIndex Index of the light in the enabled light list of the material
  76430. */
  76431. prepareDefines(defines: any, lightIndex: number): void;
  76432. /**
  76433. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76434. * defined in the generator but impacting the effect).
  76435. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76436. * @param effect The effect we are binfing the information for
  76437. */
  76438. bindShadowLight(lightIndex: string, effect: Effect): void;
  76439. /**
  76440. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76441. * (eq to shadow prjection matrix * light transform matrix)
  76442. * @returns The transform matrix used to create the shadow map
  76443. */
  76444. getTransformMatrix(): Matrix;
  76445. /**
  76446. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76447. * Cube and 2D textures for instance.
  76448. */
  76449. recreateShadowMap(): void;
  76450. private _disposeBlurPostProcesses;
  76451. private _disposeRTTandPostProcesses;
  76452. /**
  76453. * Disposes the ShadowGenerator.
  76454. * Returns nothing.
  76455. */
  76456. dispose(): void;
  76457. /**
  76458. * Serializes the shadow generator setup to a json object.
  76459. * @returns The serialized JSON object
  76460. */
  76461. serialize(): any;
  76462. /**
  76463. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  76464. * @param parsedShadowGenerator The JSON object to parse
  76465. * @param scene The scene to create the shadow map for
  76466. * @returns The parsed shadow generator
  76467. */
  76468. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  76469. }
  76470. }
  76471. declare module BABYLON {
  76472. /**
  76473. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  76474. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  76475. * 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.
  76476. */
  76477. export abstract class Light extends Node {
  76478. /**
  76479. * Falloff Default: light is falling off following the material specification:
  76480. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  76481. */
  76482. static readonly FALLOFF_DEFAULT: number;
  76483. /**
  76484. * Falloff Physical: light is falling off following the inverse squared distance law.
  76485. */
  76486. static readonly FALLOFF_PHYSICAL: number;
  76487. /**
  76488. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  76489. * to enhance interoperability with other engines.
  76490. */
  76491. static readonly FALLOFF_GLTF: number;
  76492. /**
  76493. * Falloff Standard: light is falling off like in the standard material
  76494. * to enhance interoperability with other materials.
  76495. */
  76496. static readonly FALLOFF_STANDARD: number;
  76497. /**
  76498. * If every light affecting the material is in this lightmapMode,
  76499. * material.lightmapTexture adds or multiplies
  76500. * (depends on material.useLightmapAsShadowmap)
  76501. * after every other light calculations.
  76502. */
  76503. static readonly LIGHTMAP_DEFAULT: number;
  76504. /**
  76505. * material.lightmapTexture as only diffuse lighting from this light
  76506. * adds only specular lighting from this light
  76507. * adds dynamic shadows
  76508. */
  76509. static readonly LIGHTMAP_SPECULAR: number;
  76510. /**
  76511. * material.lightmapTexture as only lighting
  76512. * no light calculation from this light
  76513. * only adds dynamic shadows from this light
  76514. */
  76515. static readonly LIGHTMAP_SHADOWSONLY: number;
  76516. /**
  76517. * Each light type uses the default quantity according to its type:
  76518. * point/spot lights use luminous intensity
  76519. * directional lights use illuminance
  76520. */
  76521. static readonly INTENSITYMODE_AUTOMATIC: number;
  76522. /**
  76523. * lumen (lm)
  76524. */
  76525. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  76526. /**
  76527. * candela (lm/sr)
  76528. */
  76529. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  76530. /**
  76531. * lux (lm/m^2)
  76532. */
  76533. static readonly INTENSITYMODE_ILLUMINANCE: number;
  76534. /**
  76535. * nit (cd/m^2)
  76536. */
  76537. static readonly INTENSITYMODE_LUMINANCE: number;
  76538. /**
  76539. * Light type const id of the point light.
  76540. */
  76541. static readonly LIGHTTYPEID_POINTLIGHT: number;
  76542. /**
  76543. * Light type const id of the directional light.
  76544. */
  76545. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  76546. /**
  76547. * Light type const id of the spot light.
  76548. */
  76549. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  76550. /**
  76551. * Light type const id of the hemispheric light.
  76552. */
  76553. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  76554. /**
  76555. * Diffuse gives the basic color to an object.
  76556. */
  76557. diffuse: Color3;
  76558. /**
  76559. * Specular produces a highlight color on an object.
  76560. * Note: This is note affecting PBR materials.
  76561. */
  76562. specular: Color3;
  76563. /**
  76564. * Defines the falloff type for this light. This lets overrriding how punctual light are
  76565. * falling off base on range or angle.
  76566. * This can be set to any values in Light.FALLOFF_x.
  76567. *
  76568. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  76569. * other types of materials.
  76570. */
  76571. falloffType: number;
  76572. /**
  76573. * Strength of the light.
  76574. * Note: By default it is define in the framework own unit.
  76575. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  76576. */
  76577. intensity: number;
  76578. private _range;
  76579. protected _inverseSquaredRange: number;
  76580. /**
  76581. * Defines how far from the source the light is impacting in scene units.
  76582. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76583. */
  76584. /**
  76585. * Defines how far from the source the light is impacting in scene units.
  76586. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76587. */
  76588. range: number;
  76589. /**
  76590. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  76591. * of light.
  76592. */
  76593. private _photometricScale;
  76594. private _intensityMode;
  76595. /**
  76596. * Gets the photometric scale used to interpret the intensity.
  76597. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76598. */
  76599. /**
  76600. * Sets the photometric scale used to interpret the intensity.
  76601. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76602. */
  76603. intensityMode: number;
  76604. private _radius;
  76605. /**
  76606. * Gets the light radius used by PBR Materials to simulate soft area lights.
  76607. */
  76608. /**
  76609. * sets the light radius used by PBR Materials to simulate soft area lights.
  76610. */
  76611. radius: number;
  76612. private _renderPriority;
  76613. /**
  76614. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  76615. * exceeding the number allowed of the materials.
  76616. */
  76617. renderPriority: number;
  76618. private _shadowEnabled;
  76619. /**
  76620. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76621. * the current shadow generator.
  76622. */
  76623. /**
  76624. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76625. * the current shadow generator.
  76626. */
  76627. shadowEnabled: boolean;
  76628. private _includedOnlyMeshes;
  76629. /**
  76630. * Gets the only meshes impacted by this light.
  76631. */
  76632. /**
  76633. * Sets the only meshes impacted by this light.
  76634. */
  76635. includedOnlyMeshes: AbstractMesh[];
  76636. private _excludedMeshes;
  76637. /**
  76638. * Gets the meshes not impacted by this light.
  76639. */
  76640. /**
  76641. * Sets the meshes not impacted by this light.
  76642. */
  76643. excludedMeshes: AbstractMesh[];
  76644. private _excludeWithLayerMask;
  76645. /**
  76646. * Gets the layer id use to find what meshes are not impacted by the light.
  76647. * Inactive if 0
  76648. */
  76649. /**
  76650. * Sets the layer id use to find what meshes are not impacted by the light.
  76651. * Inactive if 0
  76652. */
  76653. excludeWithLayerMask: number;
  76654. private _includeOnlyWithLayerMask;
  76655. /**
  76656. * Gets the layer id use to find what meshes are impacted by the light.
  76657. * Inactive if 0
  76658. */
  76659. /**
  76660. * Sets the layer id use to find what meshes are impacted by the light.
  76661. * Inactive if 0
  76662. */
  76663. includeOnlyWithLayerMask: number;
  76664. private _lightmapMode;
  76665. /**
  76666. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76667. */
  76668. /**
  76669. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76670. */
  76671. lightmapMode: number;
  76672. /**
  76673. * Shadow generator associted to the light.
  76674. * @hidden Internal use only.
  76675. */
  76676. _shadowGenerator: Nullable<IShadowGenerator>;
  76677. /**
  76678. * @hidden Internal use only.
  76679. */
  76680. _excludedMeshesIds: string[];
  76681. /**
  76682. * @hidden Internal use only.
  76683. */
  76684. _includedOnlyMeshesIds: string[];
  76685. /**
  76686. * The current light unifom buffer.
  76687. * @hidden Internal use only.
  76688. */
  76689. _uniformBuffer: UniformBuffer;
  76690. /**
  76691. * Creates a Light object in the scene.
  76692. * Documentation : https://doc.babylonjs.com/babylon101/lights
  76693. * @param name The firendly name of the light
  76694. * @param scene The scene the light belongs too
  76695. */
  76696. constructor(name: string, scene: Scene);
  76697. protected abstract _buildUniformLayout(): void;
  76698. /**
  76699. * Sets the passed Effect "effect" with the Light information.
  76700. * @param effect The effect to update
  76701. * @param lightIndex The index of the light in the effect to update
  76702. * @returns The light
  76703. */
  76704. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  76705. /**
  76706. * Sets the passed Effect "effect" with the Light information.
  76707. * @param effect The effect to update
  76708. * @param lightDataUniformName The uniform used to store light data (position or direction)
  76709. * @returns The light
  76710. */
  76711. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  76712. /**
  76713. * Returns the string "Light".
  76714. * @returns the class name
  76715. */
  76716. getClassName(): string;
  76717. /** @hidden */
  76718. readonly _isLight: boolean;
  76719. /**
  76720. * Converts the light information to a readable string for debug purpose.
  76721. * @param fullDetails Supports for multiple levels of logging within scene loading
  76722. * @returns the human readable light info
  76723. */
  76724. toString(fullDetails?: boolean): string;
  76725. /** @hidden */
  76726. protected _syncParentEnabledState(): void;
  76727. /**
  76728. * Set the enabled state of this node.
  76729. * @param value - the new enabled state
  76730. */
  76731. setEnabled(value: boolean): void;
  76732. /**
  76733. * Returns the Light associated shadow generator if any.
  76734. * @return the associated shadow generator.
  76735. */
  76736. getShadowGenerator(): Nullable<IShadowGenerator>;
  76737. /**
  76738. * Returns a Vector3, the absolute light position in the World.
  76739. * @returns the world space position of the light
  76740. */
  76741. getAbsolutePosition(): Vector3;
  76742. /**
  76743. * Specifies if the light will affect the passed mesh.
  76744. * @param mesh The mesh to test against the light
  76745. * @return true the mesh is affected otherwise, false.
  76746. */
  76747. canAffectMesh(mesh: AbstractMesh): boolean;
  76748. /**
  76749. * Sort function to order lights for rendering.
  76750. * @param a First Light object to compare to second.
  76751. * @param b Second Light object to compare first.
  76752. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  76753. */
  76754. static CompareLightsPriority(a: Light, b: Light): number;
  76755. /**
  76756. * Releases resources associated with this node.
  76757. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76758. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76759. */
  76760. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76761. /**
  76762. * Returns the light type ID (integer).
  76763. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  76764. */
  76765. getTypeID(): number;
  76766. /**
  76767. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  76768. * @returns the scaled intensity in intensity mode unit
  76769. */
  76770. getScaledIntensity(): number;
  76771. /**
  76772. * Returns a new Light object, named "name", from the current one.
  76773. * @param name The name of the cloned light
  76774. * @returns the new created light
  76775. */
  76776. clone(name: string): Nullable<Light>;
  76777. /**
  76778. * Serializes the current light into a Serialization object.
  76779. * @returns the serialized object.
  76780. */
  76781. serialize(): any;
  76782. /**
  76783. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  76784. * This new light is named "name" and added to the passed scene.
  76785. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  76786. * @param name The friendly name of the light
  76787. * @param scene The scene the new light will belong to
  76788. * @returns the constructor function
  76789. */
  76790. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  76791. /**
  76792. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  76793. * @param parsedLight The JSON representation of the light
  76794. * @param scene The scene to create the parsed light in
  76795. * @returns the created light after parsing
  76796. */
  76797. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  76798. private _hookArrayForExcluded;
  76799. private _hookArrayForIncludedOnly;
  76800. private _resyncMeshes;
  76801. /**
  76802. * Forces the meshes to update their light related information in their rendering used effects
  76803. * @hidden Internal Use Only
  76804. */
  76805. _markMeshesAsLightDirty(): void;
  76806. /**
  76807. * Recomputes the cached photometric scale if needed.
  76808. */
  76809. private _computePhotometricScale;
  76810. /**
  76811. * Returns the Photometric Scale according to the light type and intensity mode.
  76812. */
  76813. private _getPhotometricScale;
  76814. /**
  76815. * Reorder the light in the scene according to their defined priority.
  76816. * @hidden Internal Use Only
  76817. */
  76818. _reorderLightsInScene(): void;
  76819. /**
  76820. * Prepares the list of defines specific to the light type.
  76821. * @param defines the list of defines
  76822. * @param lightIndex defines the index of the light for the effect
  76823. */
  76824. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  76825. }
  76826. }
  76827. declare module BABYLON {
  76828. /**
  76829. * Interface used to define Action
  76830. */
  76831. export interface IAction {
  76832. /**
  76833. * Trigger for the action
  76834. */
  76835. trigger: number;
  76836. /** Options of the trigger */
  76837. triggerOptions: any;
  76838. /**
  76839. * Gets the trigger parameters
  76840. * @returns the trigger parameters
  76841. */
  76842. getTriggerParameter(): any;
  76843. /**
  76844. * Internal only - executes current action event
  76845. * @hidden
  76846. */
  76847. _executeCurrent(evt?: ActionEvent): void;
  76848. /**
  76849. * Serialize placeholder for child classes
  76850. * @param parent of child
  76851. * @returns the serialized object
  76852. */
  76853. serialize(parent: any): any;
  76854. /**
  76855. * Internal only
  76856. * @hidden
  76857. */
  76858. _prepare(): void;
  76859. /**
  76860. * Internal only - manager for action
  76861. * @hidden
  76862. */
  76863. _actionManager: AbstractActionManager;
  76864. /**
  76865. * Adds action to chain of actions, may be a DoNothingAction
  76866. * @param action defines the next action to execute
  76867. * @returns The action passed in
  76868. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76869. */
  76870. then(action: IAction): IAction;
  76871. }
  76872. /**
  76873. * The action to be carried out following a trigger
  76874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  76875. */
  76876. export class Action implements IAction {
  76877. /** the trigger, with or without parameters, for the action */
  76878. triggerOptions: any;
  76879. /**
  76880. * Trigger for the action
  76881. */
  76882. trigger: number;
  76883. /**
  76884. * Internal only - manager for action
  76885. * @hidden
  76886. */
  76887. _actionManager: ActionManager;
  76888. private _nextActiveAction;
  76889. private _child;
  76890. private _condition?;
  76891. private _triggerParameter;
  76892. /**
  76893. * An event triggered prior to action being executed.
  76894. */
  76895. onBeforeExecuteObservable: Observable<Action>;
  76896. /**
  76897. * Creates a new Action
  76898. * @param triggerOptions the trigger, with or without parameters, for the action
  76899. * @param condition an optional determinant of action
  76900. */
  76901. constructor(
  76902. /** the trigger, with or without parameters, for the action */
  76903. triggerOptions: any, condition?: Condition);
  76904. /**
  76905. * Internal only
  76906. * @hidden
  76907. */
  76908. _prepare(): void;
  76909. /**
  76910. * Gets the trigger parameters
  76911. * @returns the trigger parameters
  76912. */
  76913. getTriggerParameter(): any;
  76914. /**
  76915. * Internal only - executes current action event
  76916. * @hidden
  76917. */
  76918. _executeCurrent(evt?: ActionEvent): void;
  76919. /**
  76920. * Execute placeholder for child classes
  76921. * @param evt optional action event
  76922. */
  76923. execute(evt?: ActionEvent): void;
  76924. /**
  76925. * Skips to next active action
  76926. */
  76927. skipToNextActiveAction(): void;
  76928. /**
  76929. * Adds action to chain of actions, may be a DoNothingAction
  76930. * @param action defines the next action to execute
  76931. * @returns The action passed in
  76932. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76933. */
  76934. then(action: Action): Action;
  76935. /**
  76936. * Internal only
  76937. * @hidden
  76938. */
  76939. _getProperty(propertyPath: string): string;
  76940. /**
  76941. * Internal only
  76942. * @hidden
  76943. */
  76944. _getEffectiveTarget(target: any, propertyPath: string): any;
  76945. /**
  76946. * Serialize placeholder for child classes
  76947. * @param parent of child
  76948. * @returns the serialized object
  76949. */
  76950. serialize(parent: any): any;
  76951. /**
  76952. * Internal only called by serialize
  76953. * @hidden
  76954. */
  76955. protected _serialize(serializedAction: any, parent?: any): any;
  76956. /**
  76957. * Internal only
  76958. * @hidden
  76959. */
  76960. static _SerializeValueAsString: (value: any) => string;
  76961. /**
  76962. * Internal only
  76963. * @hidden
  76964. */
  76965. static _GetTargetProperty: (target: Node | Scene) => {
  76966. name: string;
  76967. targetType: string;
  76968. value: string;
  76969. };
  76970. }
  76971. }
  76972. declare module BABYLON {
  76973. /**
  76974. * A Condition applied to an Action
  76975. */
  76976. export class Condition {
  76977. /**
  76978. * Internal only - manager for action
  76979. * @hidden
  76980. */
  76981. _actionManager: ActionManager;
  76982. /**
  76983. * Internal only
  76984. * @hidden
  76985. */
  76986. _evaluationId: number;
  76987. /**
  76988. * Internal only
  76989. * @hidden
  76990. */
  76991. _currentResult: boolean;
  76992. /**
  76993. * Creates a new Condition
  76994. * @param actionManager the manager of the action the condition is applied to
  76995. */
  76996. constructor(actionManager: ActionManager);
  76997. /**
  76998. * Check if the current condition is valid
  76999. * @returns a boolean
  77000. */
  77001. isValid(): boolean;
  77002. /**
  77003. * Internal only
  77004. * @hidden
  77005. */
  77006. _getProperty(propertyPath: string): string;
  77007. /**
  77008. * Internal only
  77009. * @hidden
  77010. */
  77011. _getEffectiveTarget(target: any, propertyPath: string): any;
  77012. /**
  77013. * Serialize placeholder for child classes
  77014. * @returns the serialized object
  77015. */
  77016. serialize(): any;
  77017. /**
  77018. * Internal only
  77019. * @hidden
  77020. */
  77021. protected _serialize(serializedCondition: any): any;
  77022. }
  77023. /**
  77024. * Defines specific conditional operators as extensions of Condition
  77025. */
  77026. export class ValueCondition extends Condition {
  77027. /** path to specify the property of the target the conditional operator uses */
  77028. propertyPath: string;
  77029. /** the value compared by the conditional operator against the current value of the property */
  77030. value: any;
  77031. /** the conditional operator, default ValueCondition.IsEqual */
  77032. operator: number;
  77033. /**
  77034. * Internal only
  77035. * @hidden
  77036. */
  77037. private static _IsEqual;
  77038. /**
  77039. * Internal only
  77040. * @hidden
  77041. */
  77042. private static _IsDifferent;
  77043. /**
  77044. * Internal only
  77045. * @hidden
  77046. */
  77047. private static _IsGreater;
  77048. /**
  77049. * Internal only
  77050. * @hidden
  77051. */
  77052. private static _IsLesser;
  77053. /**
  77054. * returns the number for IsEqual
  77055. */
  77056. static readonly IsEqual: number;
  77057. /**
  77058. * Returns the number for IsDifferent
  77059. */
  77060. static readonly IsDifferent: number;
  77061. /**
  77062. * Returns the number for IsGreater
  77063. */
  77064. static readonly IsGreater: number;
  77065. /**
  77066. * Returns the number for IsLesser
  77067. */
  77068. static readonly IsLesser: number;
  77069. /**
  77070. * Internal only The action manager for the condition
  77071. * @hidden
  77072. */
  77073. _actionManager: ActionManager;
  77074. /**
  77075. * Internal only
  77076. * @hidden
  77077. */
  77078. private _target;
  77079. /**
  77080. * Internal only
  77081. * @hidden
  77082. */
  77083. private _effectiveTarget;
  77084. /**
  77085. * Internal only
  77086. * @hidden
  77087. */
  77088. private _property;
  77089. /**
  77090. * Creates a new ValueCondition
  77091. * @param actionManager manager for the action the condition applies to
  77092. * @param target for the action
  77093. * @param propertyPath path to specify the property of the target the conditional operator uses
  77094. * @param value the value compared by the conditional operator against the current value of the property
  77095. * @param operator the conditional operator, default ValueCondition.IsEqual
  77096. */
  77097. constructor(actionManager: ActionManager, target: any,
  77098. /** path to specify the property of the target the conditional operator uses */
  77099. propertyPath: string,
  77100. /** the value compared by the conditional operator against the current value of the property */
  77101. value: any,
  77102. /** the conditional operator, default ValueCondition.IsEqual */
  77103. operator?: number);
  77104. /**
  77105. * Compares the given value with the property value for the specified conditional operator
  77106. * @returns the result of the comparison
  77107. */
  77108. isValid(): boolean;
  77109. /**
  77110. * Serialize the ValueCondition into a JSON compatible object
  77111. * @returns serialization object
  77112. */
  77113. serialize(): any;
  77114. /**
  77115. * Gets the name of the conditional operator for the ValueCondition
  77116. * @param operator the conditional operator
  77117. * @returns the name
  77118. */
  77119. static GetOperatorName(operator: number): string;
  77120. }
  77121. /**
  77122. * Defines a predicate condition as an extension of Condition
  77123. */
  77124. export class PredicateCondition extends Condition {
  77125. /** defines the predicate function used to validate the condition */
  77126. predicate: () => boolean;
  77127. /**
  77128. * Internal only - manager for action
  77129. * @hidden
  77130. */
  77131. _actionManager: ActionManager;
  77132. /**
  77133. * Creates a new PredicateCondition
  77134. * @param actionManager manager for the action the condition applies to
  77135. * @param predicate defines the predicate function used to validate the condition
  77136. */
  77137. constructor(actionManager: ActionManager,
  77138. /** defines the predicate function used to validate the condition */
  77139. predicate: () => boolean);
  77140. /**
  77141. * @returns the validity of the predicate condition
  77142. */
  77143. isValid(): boolean;
  77144. }
  77145. /**
  77146. * Defines a state condition as an extension of Condition
  77147. */
  77148. export class StateCondition extends Condition {
  77149. /** Value to compare with target state */
  77150. value: string;
  77151. /**
  77152. * Internal only - manager for action
  77153. * @hidden
  77154. */
  77155. _actionManager: ActionManager;
  77156. /**
  77157. * Internal only
  77158. * @hidden
  77159. */
  77160. private _target;
  77161. /**
  77162. * Creates a new StateCondition
  77163. * @param actionManager manager for the action the condition applies to
  77164. * @param target of the condition
  77165. * @param value to compare with target state
  77166. */
  77167. constructor(actionManager: ActionManager, target: any,
  77168. /** Value to compare with target state */
  77169. value: string);
  77170. /**
  77171. * Gets a boolean indicating if the current condition is met
  77172. * @returns the validity of the state
  77173. */
  77174. isValid(): boolean;
  77175. /**
  77176. * Serialize the StateCondition into a JSON compatible object
  77177. * @returns serialization object
  77178. */
  77179. serialize(): any;
  77180. }
  77181. }
  77182. declare module BABYLON {
  77183. /**
  77184. * This defines an action responsible to toggle a boolean once triggered.
  77185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77186. */
  77187. export class SwitchBooleanAction extends Action {
  77188. /**
  77189. * The path to the boolean property in the target object
  77190. */
  77191. propertyPath: string;
  77192. private _target;
  77193. private _effectiveTarget;
  77194. private _property;
  77195. /**
  77196. * Instantiate the action
  77197. * @param triggerOptions defines the trigger options
  77198. * @param target defines the object containing the boolean
  77199. * @param propertyPath defines the path to the boolean property in the target object
  77200. * @param condition defines the trigger related conditions
  77201. */
  77202. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77203. /** @hidden */
  77204. _prepare(): void;
  77205. /**
  77206. * Execute the action toggle the boolean value.
  77207. */
  77208. execute(): void;
  77209. /**
  77210. * Serializes the actions and its related information.
  77211. * @param parent defines the object to serialize in
  77212. * @returns the serialized object
  77213. */
  77214. serialize(parent: any): any;
  77215. }
  77216. /**
  77217. * This defines an action responsible to set a the state field of the target
  77218. * to a desired value once triggered.
  77219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77220. */
  77221. export class SetStateAction extends Action {
  77222. /**
  77223. * The value to store in the state field.
  77224. */
  77225. value: string;
  77226. private _target;
  77227. /**
  77228. * Instantiate the action
  77229. * @param triggerOptions defines the trigger options
  77230. * @param target defines the object containing the state property
  77231. * @param value defines the value to store in the state field
  77232. * @param condition defines the trigger related conditions
  77233. */
  77234. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77235. /**
  77236. * Execute the action and store the value on the target state property.
  77237. */
  77238. execute(): void;
  77239. /**
  77240. * Serializes the actions and its related information.
  77241. * @param parent defines the object to serialize in
  77242. * @returns the serialized object
  77243. */
  77244. serialize(parent: any): any;
  77245. }
  77246. /**
  77247. * This defines an action responsible to set a property of the target
  77248. * to a desired value once triggered.
  77249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77250. */
  77251. export class SetValueAction extends Action {
  77252. /**
  77253. * The path of the property to set in the target.
  77254. */
  77255. propertyPath: string;
  77256. /**
  77257. * The value to set in the property
  77258. */
  77259. value: any;
  77260. private _target;
  77261. private _effectiveTarget;
  77262. private _property;
  77263. /**
  77264. * Instantiate the action
  77265. * @param triggerOptions defines the trigger options
  77266. * @param target defines the object containing the property
  77267. * @param propertyPath defines the path of the property to set in the target
  77268. * @param value defines the value to set in the property
  77269. * @param condition defines the trigger related conditions
  77270. */
  77271. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77272. /** @hidden */
  77273. _prepare(): void;
  77274. /**
  77275. * Execute the action and set the targetted property to the desired value.
  77276. */
  77277. execute(): void;
  77278. /**
  77279. * Serializes the actions and its related information.
  77280. * @param parent defines the object to serialize in
  77281. * @returns the serialized object
  77282. */
  77283. serialize(parent: any): any;
  77284. }
  77285. /**
  77286. * This defines an action responsible to increment the target value
  77287. * to a desired value once triggered.
  77288. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77289. */
  77290. export class IncrementValueAction extends Action {
  77291. /**
  77292. * The path of the property to increment in the target.
  77293. */
  77294. propertyPath: string;
  77295. /**
  77296. * The value we should increment the property by.
  77297. */
  77298. value: any;
  77299. private _target;
  77300. private _effectiveTarget;
  77301. private _property;
  77302. /**
  77303. * Instantiate the action
  77304. * @param triggerOptions defines the trigger options
  77305. * @param target defines the object containing the property
  77306. * @param propertyPath defines the path of the property to increment in the target
  77307. * @param value defines the value value we should increment the property by
  77308. * @param condition defines the trigger related conditions
  77309. */
  77310. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77311. /** @hidden */
  77312. _prepare(): void;
  77313. /**
  77314. * Execute the action and increment the target of the value amount.
  77315. */
  77316. execute(): void;
  77317. /**
  77318. * Serializes the actions and its related information.
  77319. * @param parent defines the object to serialize in
  77320. * @returns the serialized object
  77321. */
  77322. serialize(parent: any): any;
  77323. }
  77324. /**
  77325. * This defines an action responsible to start an animation once triggered.
  77326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77327. */
  77328. export class PlayAnimationAction extends Action {
  77329. /**
  77330. * Where the animation should start (animation frame)
  77331. */
  77332. from: number;
  77333. /**
  77334. * Where the animation should stop (animation frame)
  77335. */
  77336. to: number;
  77337. /**
  77338. * Define if the animation should loop or stop after the first play.
  77339. */
  77340. loop?: boolean;
  77341. private _target;
  77342. /**
  77343. * Instantiate the action
  77344. * @param triggerOptions defines the trigger options
  77345. * @param target defines the target animation or animation name
  77346. * @param from defines from where the animation should start (animation frame)
  77347. * @param end defines where the animation should stop (animation frame)
  77348. * @param loop defines if the animation should loop or stop after the first play
  77349. * @param condition defines the trigger related conditions
  77350. */
  77351. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  77352. /** @hidden */
  77353. _prepare(): void;
  77354. /**
  77355. * Execute the action and play the animation.
  77356. */
  77357. execute(): void;
  77358. /**
  77359. * Serializes the actions and its related information.
  77360. * @param parent defines the object to serialize in
  77361. * @returns the serialized object
  77362. */
  77363. serialize(parent: any): any;
  77364. }
  77365. /**
  77366. * This defines an action responsible to stop an animation once triggered.
  77367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77368. */
  77369. export class StopAnimationAction extends Action {
  77370. private _target;
  77371. /**
  77372. * Instantiate the action
  77373. * @param triggerOptions defines the trigger options
  77374. * @param target defines the target animation or animation name
  77375. * @param condition defines the trigger related conditions
  77376. */
  77377. constructor(triggerOptions: any, target: any, condition?: Condition);
  77378. /** @hidden */
  77379. _prepare(): void;
  77380. /**
  77381. * Execute the action and stop the animation.
  77382. */
  77383. execute(): void;
  77384. /**
  77385. * Serializes the actions and its related information.
  77386. * @param parent defines the object to serialize in
  77387. * @returns the serialized object
  77388. */
  77389. serialize(parent: any): any;
  77390. }
  77391. /**
  77392. * This defines an action responsible that does nothing once triggered.
  77393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77394. */
  77395. export class DoNothingAction extends Action {
  77396. /**
  77397. * Instantiate the action
  77398. * @param triggerOptions defines the trigger options
  77399. * @param condition defines the trigger related conditions
  77400. */
  77401. constructor(triggerOptions?: any, condition?: Condition);
  77402. /**
  77403. * Execute the action and do nothing.
  77404. */
  77405. execute(): void;
  77406. /**
  77407. * Serializes the actions and its related information.
  77408. * @param parent defines the object to serialize in
  77409. * @returns the serialized object
  77410. */
  77411. serialize(parent: any): any;
  77412. }
  77413. /**
  77414. * This defines an action responsible to trigger several actions once triggered.
  77415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77416. */
  77417. export class CombineAction extends Action {
  77418. /**
  77419. * The list of aggregated animations to run.
  77420. */
  77421. children: Action[];
  77422. /**
  77423. * Instantiate the action
  77424. * @param triggerOptions defines the trigger options
  77425. * @param children defines the list of aggregated animations to run
  77426. * @param condition defines the trigger related conditions
  77427. */
  77428. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77429. /** @hidden */
  77430. _prepare(): void;
  77431. /**
  77432. * Execute the action and executes all the aggregated actions.
  77433. */
  77434. execute(evt: ActionEvent): void;
  77435. /**
  77436. * Serializes the actions and its related information.
  77437. * @param parent defines the object to serialize in
  77438. * @returns the serialized object
  77439. */
  77440. serialize(parent: any): any;
  77441. }
  77442. /**
  77443. * This defines an action responsible to run code (external event) once triggered.
  77444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77445. */
  77446. export class ExecuteCodeAction extends Action {
  77447. /**
  77448. * The callback function to run.
  77449. */
  77450. func: (evt: ActionEvent) => void;
  77451. /**
  77452. * Instantiate the action
  77453. * @param triggerOptions defines the trigger options
  77454. * @param func defines the callback function to run
  77455. * @param condition defines the trigger related conditions
  77456. */
  77457. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77458. /**
  77459. * Execute the action and run the attached code.
  77460. */
  77461. execute(evt: ActionEvent): void;
  77462. }
  77463. /**
  77464. * This defines an action responsible to set the parent property of the target once triggered.
  77465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77466. */
  77467. export class SetParentAction extends Action {
  77468. private _parent;
  77469. private _target;
  77470. /**
  77471. * Instantiate the action
  77472. * @param triggerOptions defines the trigger options
  77473. * @param target defines the target containing the parent property
  77474. * @param parent defines from where the animation should start (animation frame)
  77475. * @param condition defines the trigger related conditions
  77476. */
  77477. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  77478. /** @hidden */
  77479. _prepare(): void;
  77480. /**
  77481. * Execute the action and set the parent property.
  77482. */
  77483. execute(): void;
  77484. /**
  77485. * Serializes the actions and its related information.
  77486. * @param parent defines the object to serialize in
  77487. * @returns the serialized object
  77488. */
  77489. serialize(parent: any): any;
  77490. }
  77491. }
  77492. declare module BABYLON {
  77493. /**
  77494. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  77495. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  77496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77497. */
  77498. export class ActionManager extends AbstractActionManager {
  77499. /**
  77500. * Nothing
  77501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77502. */
  77503. static readonly NothingTrigger: number;
  77504. /**
  77505. * On pick
  77506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77507. */
  77508. static readonly OnPickTrigger: number;
  77509. /**
  77510. * On left pick
  77511. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77512. */
  77513. static readonly OnLeftPickTrigger: number;
  77514. /**
  77515. * On right pick
  77516. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77517. */
  77518. static readonly OnRightPickTrigger: number;
  77519. /**
  77520. * On center pick
  77521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77522. */
  77523. static readonly OnCenterPickTrigger: number;
  77524. /**
  77525. * On pick down
  77526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77527. */
  77528. static readonly OnPickDownTrigger: number;
  77529. /**
  77530. * On double pick
  77531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77532. */
  77533. static readonly OnDoublePickTrigger: number;
  77534. /**
  77535. * On pick up
  77536. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77537. */
  77538. static readonly OnPickUpTrigger: number;
  77539. /**
  77540. * On pick out.
  77541. * This trigger will only be raised if you also declared a OnPickDown
  77542. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77543. */
  77544. static readonly OnPickOutTrigger: number;
  77545. /**
  77546. * On long press
  77547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77548. */
  77549. static readonly OnLongPressTrigger: number;
  77550. /**
  77551. * On pointer over
  77552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77553. */
  77554. static readonly OnPointerOverTrigger: number;
  77555. /**
  77556. * On pointer out
  77557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77558. */
  77559. static readonly OnPointerOutTrigger: number;
  77560. /**
  77561. * On every frame
  77562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77563. */
  77564. static readonly OnEveryFrameTrigger: number;
  77565. /**
  77566. * On intersection enter
  77567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77568. */
  77569. static readonly OnIntersectionEnterTrigger: number;
  77570. /**
  77571. * On intersection exit
  77572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77573. */
  77574. static readonly OnIntersectionExitTrigger: number;
  77575. /**
  77576. * On key down
  77577. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77578. */
  77579. static readonly OnKeyDownTrigger: number;
  77580. /**
  77581. * On key up
  77582. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77583. */
  77584. static readonly OnKeyUpTrigger: number;
  77585. private _scene;
  77586. /**
  77587. * Creates a new action manager
  77588. * @param scene defines the hosting scene
  77589. */
  77590. constructor(scene: Scene);
  77591. /**
  77592. * Releases all associated resources
  77593. */
  77594. dispose(): void;
  77595. /**
  77596. * Gets hosting scene
  77597. * @returns the hosting scene
  77598. */
  77599. getScene(): Scene;
  77600. /**
  77601. * Does this action manager handles actions of any of the given triggers
  77602. * @param triggers defines the triggers to be tested
  77603. * @return a boolean indicating whether one (or more) of the triggers is handled
  77604. */
  77605. hasSpecificTriggers(triggers: number[]): boolean;
  77606. /**
  77607. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  77608. * speed.
  77609. * @param triggerA defines the trigger to be tested
  77610. * @param triggerB defines the trigger to be tested
  77611. * @return a boolean indicating whether one (or more) of the triggers is handled
  77612. */
  77613. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  77614. /**
  77615. * Does this action manager handles actions of a given trigger
  77616. * @param trigger defines the trigger to be tested
  77617. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  77618. * @return whether the trigger is handled
  77619. */
  77620. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  77621. /**
  77622. * Does this action manager has pointer triggers
  77623. */
  77624. readonly hasPointerTriggers: boolean;
  77625. /**
  77626. * Does this action manager has pick triggers
  77627. */
  77628. readonly hasPickTriggers: boolean;
  77629. /**
  77630. * Registers an action to this action manager
  77631. * @param action defines the action to be registered
  77632. * @return the action amended (prepared) after registration
  77633. */
  77634. registerAction(action: IAction): Nullable<IAction>;
  77635. /**
  77636. * Unregisters an action to this action manager
  77637. * @param action defines the action to be unregistered
  77638. * @return a boolean indicating whether the action has been unregistered
  77639. */
  77640. unregisterAction(action: IAction): Boolean;
  77641. /**
  77642. * Process a specific trigger
  77643. * @param trigger defines the trigger to process
  77644. * @param evt defines the event details to be processed
  77645. */
  77646. processTrigger(trigger: number, evt?: IActionEvent): void;
  77647. /** @hidden */
  77648. _getEffectiveTarget(target: any, propertyPath: string): any;
  77649. /** @hidden */
  77650. _getProperty(propertyPath: string): string;
  77651. /**
  77652. * Serialize this manager to a JSON object
  77653. * @param name defines the property name to store this manager
  77654. * @returns a JSON representation of this manager
  77655. */
  77656. serialize(name: string): any;
  77657. /**
  77658. * Creates a new ActionManager from a JSON data
  77659. * @param parsedActions defines the JSON data to read from
  77660. * @param object defines the hosting mesh
  77661. * @param scene defines the hosting scene
  77662. */
  77663. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  77664. /**
  77665. * Get a trigger name by index
  77666. * @param trigger defines the trigger index
  77667. * @returns a trigger name
  77668. */
  77669. static GetTriggerName(trigger: number): string;
  77670. }
  77671. }
  77672. declare module BABYLON {
  77673. /**
  77674. * Class representing a ray with position and direction
  77675. */
  77676. export class Ray {
  77677. /** origin point */
  77678. origin: Vector3;
  77679. /** direction */
  77680. direction: Vector3;
  77681. /** length of the ray */
  77682. length: number;
  77683. private static readonly TmpVector3;
  77684. private _tmpRay;
  77685. /**
  77686. * Creates a new ray
  77687. * @param origin origin point
  77688. * @param direction direction
  77689. * @param length length of the ray
  77690. */
  77691. constructor(
  77692. /** origin point */
  77693. origin: Vector3,
  77694. /** direction */
  77695. direction: Vector3,
  77696. /** length of the ray */
  77697. length?: number);
  77698. /**
  77699. * Checks if the ray intersects a box
  77700. * @param minimum bound of the box
  77701. * @param maximum bound of the box
  77702. * @param intersectionTreshold extra extend to be added to the box in all direction
  77703. * @returns if the box was hit
  77704. */
  77705. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  77706. /**
  77707. * Checks if the ray intersects a box
  77708. * @param box the bounding box to check
  77709. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  77710. * @returns if the box was hit
  77711. */
  77712. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  77713. /**
  77714. * If the ray hits a sphere
  77715. * @param sphere the bounding sphere to check
  77716. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  77717. * @returns true if it hits the sphere
  77718. */
  77719. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  77720. /**
  77721. * If the ray hits a triange
  77722. * @param vertex0 triangle vertex
  77723. * @param vertex1 triangle vertex
  77724. * @param vertex2 triangle vertex
  77725. * @returns intersection information if hit
  77726. */
  77727. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  77728. /**
  77729. * Checks if ray intersects a plane
  77730. * @param plane the plane to check
  77731. * @returns the distance away it was hit
  77732. */
  77733. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  77734. /**
  77735. * Calculate the intercept of a ray on a given axis
  77736. * @param axis to check 'x' | 'y' | 'z'
  77737. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  77738. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  77739. */
  77740. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  77741. /**
  77742. * Checks if ray intersects a mesh
  77743. * @param mesh the mesh to check
  77744. * @param fastCheck if only the bounding box should checked
  77745. * @returns picking info of the intersecton
  77746. */
  77747. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  77748. /**
  77749. * Checks if ray intersects a mesh
  77750. * @param meshes the meshes to check
  77751. * @param fastCheck if only the bounding box should checked
  77752. * @param results array to store result in
  77753. * @returns Array of picking infos
  77754. */
  77755. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  77756. private _comparePickingInfo;
  77757. private static smallnum;
  77758. private static rayl;
  77759. /**
  77760. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  77761. * @param sega the first point of the segment to test the intersection against
  77762. * @param segb the second point of the segment to test the intersection against
  77763. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  77764. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  77765. */
  77766. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  77767. /**
  77768. * Update the ray from viewport position
  77769. * @param x position
  77770. * @param y y position
  77771. * @param viewportWidth viewport width
  77772. * @param viewportHeight viewport height
  77773. * @param world world matrix
  77774. * @param view view matrix
  77775. * @param projection projection matrix
  77776. * @returns this ray updated
  77777. */
  77778. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77779. /**
  77780. * Creates a ray with origin and direction of 0,0,0
  77781. * @returns the new ray
  77782. */
  77783. static Zero(): Ray;
  77784. /**
  77785. * Creates a new ray from screen space and viewport
  77786. * @param x position
  77787. * @param y y position
  77788. * @param viewportWidth viewport width
  77789. * @param viewportHeight viewport height
  77790. * @param world world matrix
  77791. * @param view view matrix
  77792. * @param projection projection matrix
  77793. * @returns new ray
  77794. */
  77795. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77796. /**
  77797. * 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
  77798. * transformed to the given world matrix.
  77799. * @param origin The origin point
  77800. * @param end The end point
  77801. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77802. * @returns the new ray
  77803. */
  77804. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77805. /**
  77806. * Transforms a ray by a matrix
  77807. * @param ray ray to transform
  77808. * @param matrix matrix to apply
  77809. * @returns the resulting new ray
  77810. */
  77811. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77812. /**
  77813. * Transforms a ray by a matrix
  77814. * @param ray ray to transform
  77815. * @param matrix matrix to apply
  77816. * @param result ray to store result in
  77817. */
  77818. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77819. /**
  77820. * Unproject a ray from screen space to object space
  77821. * @param sourceX defines the screen space x coordinate to use
  77822. * @param sourceY defines the screen space y coordinate to use
  77823. * @param viewportWidth defines the current width of the viewport
  77824. * @param viewportHeight defines the current height of the viewport
  77825. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77826. * @param view defines the view matrix to use
  77827. * @param projection defines the projection matrix to use
  77828. */
  77829. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77830. }
  77831. /**
  77832. * Type used to define predicate used to select faces when a mesh intersection is detected
  77833. */
  77834. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  77835. interface Scene {
  77836. /** @hidden */
  77837. _tempPickingRay: Nullable<Ray>;
  77838. /** @hidden */
  77839. _cachedRayForTransform: Ray;
  77840. /** @hidden */
  77841. _pickWithRayInverseMatrix: Matrix;
  77842. /** @hidden */
  77843. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  77844. /** @hidden */
  77845. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  77846. }
  77847. }
  77848. declare module BABYLON {
  77849. /**
  77850. * Groups all the scene component constants in one place to ease maintenance.
  77851. * @hidden
  77852. */
  77853. export class SceneComponentConstants {
  77854. static readonly NAME_EFFECTLAYER: string;
  77855. static readonly NAME_LAYER: string;
  77856. static readonly NAME_LENSFLARESYSTEM: string;
  77857. static readonly NAME_BOUNDINGBOXRENDERER: string;
  77858. static readonly NAME_PARTICLESYSTEM: string;
  77859. static readonly NAME_GAMEPAD: string;
  77860. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  77861. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  77862. static readonly NAME_DEPTHRENDERER: string;
  77863. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  77864. static readonly NAME_SPRITE: string;
  77865. static readonly NAME_OUTLINERENDERER: string;
  77866. static readonly NAME_PROCEDURALTEXTURE: string;
  77867. static readonly NAME_SHADOWGENERATOR: string;
  77868. static readonly NAME_OCTREE: string;
  77869. static readonly NAME_PHYSICSENGINE: string;
  77870. static readonly NAME_AUDIO: string;
  77871. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  77872. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77873. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  77874. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77875. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  77876. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  77877. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  77878. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  77879. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  77880. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  77881. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  77882. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  77883. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  77884. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  77885. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  77886. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  77887. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  77888. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  77889. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  77890. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  77891. static readonly STEP_AFTERRENDER_AUDIO: number;
  77892. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  77893. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  77894. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  77895. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  77896. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  77897. static readonly STEP_POINTERMOVE_SPRITE: number;
  77898. static readonly STEP_POINTERDOWN_SPRITE: number;
  77899. static readonly STEP_POINTERUP_SPRITE: number;
  77900. }
  77901. /**
  77902. * This represents a scene component.
  77903. *
  77904. * This is used to decouple the dependency the scene is having on the different workloads like
  77905. * layers, post processes...
  77906. */
  77907. export interface ISceneComponent {
  77908. /**
  77909. * The name of the component. Each component must have a unique name.
  77910. */
  77911. name: string;
  77912. /**
  77913. * The scene the component belongs to.
  77914. */
  77915. scene: Scene;
  77916. /**
  77917. * Register the component to one instance of a scene.
  77918. */
  77919. register(): void;
  77920. /**
  77921. * Rebuilds the elements related to this component in case of
  77922. * context lost for instance.
  77923. */
  77924. rebuild(): void;
  77925. /**
  77926. * Disposes the component and the associated ressources.
  77927. */
  77928. dispose(): void;
  77929. }
  77930. /**
  77931. * This represents a SERIALIZABLE scene component.
  77932. *
  77933. * This extends Scene Component to add Serialization methods on top.
  77934. */
  77935. export interface ISceneSerializableComponent extends ISceneComponent {
  77936. /**
  77937. * Adds all the elements from the container to the scene
  77938. * @param container the container holding the elements
  77939. */
  77940. addFromContainer(container: AbstractScene): void;
  77941. /**
  77942. * Removes all the elements in the container from the scene
  77943. * @param container contains the elements to remove
  77944. * @param dispose if the removed element should be disposed (default: false)
  77945. */
  77946. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77947. /**
  77948. * Serializes the component data to the specified json object
  77949. * @param serializationObject The object to serialize to
  77950. */
  77951. serialize(serializationObject: any): void;
  77952. }
  77953. /**
  77954. * Strong typing of a Mesh related stage step action
  77955. */
  77956. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  77957. /**
  77958. * Strong typing of a Evaluate Sub Mesh related stage step action
  77959. */
  77960. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  77961. /**
  77962. * Strong typing of a Active Mesh related stage step action
  77963. */
  77964. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  77965. /**
  77966. * Strong typing of a Camera related stage step action
  77967. */
  77968. export type CameraStageAction = (camera: Camera) => void;
  77969. /**
  77970. * Strong typing of a Camera Frame buffer related stage step action
  77971. */
  77972. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  77973. /**
  77974. * Strong typing of a Render Target related stage step action
  77975. */
  77976. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  77977. /**
  77978. * Strong typing of a RenderingGroup related stage step action
  77979. */
  77980. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  77981. /**
  77982. * Strong typing of a Mesh Render related stage step action
  77983. */
  77984. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  77985. /**
  77986. * Strong typing of a simple stage step action
  77987. */
  77988. export type SimpleStageAction = () => void;
  77989. /**
  77990. * Strong typing of a render target action.
  77991. */
  77992. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  77993. /**
  77994. * Strong typing of a pointer move action.
  77995. */
  77996. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  77997. /**
  77998. * Strong typing of a pointer up/down action.
  77999. */
  78000. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  78001. /**
  78002. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  78003. * @hidden
  78004. */
  78005. export class Stage<T extends Function> extends Array<{
  78006. index: number;
  78007. component: ISceneComponent;
  78008. action: T;
  78009. }> {
  78010. /**
  78011. * Hide ctor from the rest of the world.
  78012. * @param items The items to add.
  78013. */
  78014. private constructor();
  78015. /**
  78016. * Creates a new Stage.
  78017. * @returns A new instance of a Stage
  78018. */
  78019. static Create<T extends Function>(): Stage<T>;
  78020. /**
  78021. * Registers a step in an ordered way in the targeted stage.
  78022. * @param index Defines the position to register the step in
  78023. * @param component Defines the component attached to the step
  78024. * @param action Defines the action to launch during the step
  78025. */
  78026. registerStep(index: number, component: ISceneComponent, action: T): void;
  78027. /**
  78028. * Clears all the steps from the stage.
  78029. */
  78030. clear(): void;
  78031. }
  78032. }
  78033. declare module BABYLON {
  78034. interface Scene {
  78035. /** @hidden */
  78036. _pointerOverSprite: Nullable<Sprite>;
  78037. /** @hidden */
  78038. _pickedDownSprite: Nullable<Sprite>;
  78039. /** @hidden */
  78040. _tempSpritePickingRay: Nullable<Ray>;
  78041. /**
  78042. * All of the sprite managers added to this scene
  78043. * @see http://doc.babylonjs.com/babylon101/sprites
  78044. */
  78045. spriteManagers: Array<ISpriteManager>;
  78046. /**
  78047. * An event triggered when sprites rendering is about to start
  78048. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78049. */
  78050. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78051. /**
  78052. * An event triggered when sprites rendering is done
  78053. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78054. */
  78055. onAfterSpritesRenderingObservable: Observable<Scene>;
  78056. /** @hidden */
  78057. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78058. /** Launch a ray to try to pick a sprite in the scene
  78059. * @param x position on screen
  78060. * @param y position on screen
  78061. * @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
  78062. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78063. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78064. * @returns a PickingInfo
  78065. */
  78066. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78067. /** Use the given ray to pick a sprite in the scene
  78068. * @param ray The ray (in world space) to use to pick meshes
  78069. * @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
  78070. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78071. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78072. * @returns a PickingInfo
  78073. */
  78074. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78075. /** @hidden */
  78076. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78077. /** Launch a ray to try to pick sprites in the scene
  78078. * @param x position on screen
  78079. * @param y position on screen
  78080. * @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
  78081. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78082. * @returns a PickingInfo array
  78083. */
  78084. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78085. /** Use the given ray to pick sprites in the scene
  78086. * @param ray The ray (in world space) to use to pick meshes
  78087. * @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
  78088. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78089. * @returns a PickingInfo array
  78090. */
  78091. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78092. /**
  78093. * Force the sprite under the pointer
  78094. * @param sprite defines the sprite to use
  78095. */
  78096. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78097. /**
  78098. * Gets the sprite under the pointer
  78099. * @returns a Sprite or null if no sprite is under the pointer
  78100. */
  78101. getPointerOverSprite(): Nullable<Sprite>;
  78102. }
  78103. /**
  78104. * Defines the sprite scene component responsible to manage sprites
  78105. * in a given scene.
  78106. */
  78107. export class SpriteSceneComponent implements ISceneComponent {
  78108. /**
  78109. * The component name helpfull to identify the component in the list of scene components.
  78110. */
  78111. readonly name: string;
  78112. /**
  78113. * The scene the component belongs to.
  78114. */
  78115. scene: Scene;
  78116. /** @hidden */
  78117. private _spritePredicate;
  78118. /**
  78119. * Creates a new instance of the component for the given scene
  78120. * @param scene Defines the scene to register the component in
  78121. */
  78122. constructor(scene: Scene);
  78123. /**
  78124. * Registers the component in a given scene
  78125. */
  78126. register(): void;
  78127. /**
  78128. * Rebuilds the elements related to this component in case of
  78129. * context lost for instance.
  78130. */
  78131. rebuild(): void;
  78132. /**
  78133. * Disposes the component and the associated ressources.
  78134. */
  78135. dispose(): void;
  78136. private _pickSpriteButKeepRay;
  78137. private _pointerMove;
  78138. private _pointerDown;
  78139. private _pointerUp;
  78140. }
  78141. }
  78142. declare module BABYLON {
  78143. /** @hidden */
  78144. export var fogFragmentDeclaration: {
  78145. name: string;
  78146. shader: string;
  78147. };
  78148. }
  78149. declare module BABYLON {
  78150. /** @hidden */
  78151. export var fogFragment: {
  78152. name: string;
  78153. shader: string;
  78154. };
  78155. }
  78156. declare module BABYLON {
  78157. /** @hidden */
  78158. export var spritesPixelShader: {
  78159. name: string;
  78160. shader: string;
  78161. };
  78162. }
  78163. declare module BABYLON {
  78164. /** @hidden */
  78165. export var fogVertexDeclaration: {
  78166. name: string;
  78167. shader: string;
  78168. };
  78169. }
  78170. declare module BABYLON {
  78171. /** @hidden */
  78172. export var spritesVertexShader: {
  78173. name: string;
  78174. shader: string;
  78175. };
  78176. }
  78177. declare module BABYLON {
  78178. /**
  78179. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78180. */
  78181. export interface ISpriteManager extends IDisposable {
  78182. /**
  78183. * Restricts the camera to viewing objects with the same layerMask.
  78184. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78185. */
  78186. layerMask: number;
  78187. /**
  78188. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78189. */
  78190. isPickable: boolean;
  78191. /**
  78192. * Specifies the rendering group id for this mesh (0 by default)
  78193. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78194. */
  78195. renderingGroupId: number;
  78196. /**
  78197. * Defines the list of sprites managed by the manager.
  78198. */
  78199. sprites: Array<Sprite>;
  78200. /**
  78201. * Tests the intersection of a sprite with a specific ray.
  78202. * @param ray The ray we are sending to test the collision
  78203. * @param camera The camera space we are sending rays in
  78204. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78205. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78206. * @returns picking info or null.
  78207. */
  78208. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78209. /**
  78210. * Intersects the sprites with a ray
  78211. * @param ray defines the ray to intersect with
  78212. * @param camera defines the current active camera
  78213. * @param predicate defines a predicate used to select candidate sprites
  78214. * @returns null if no hit or a PickingInfo array
  78215. */
  78216. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78217. /**
  78218. * Renders the list of sprites on screen.
  78219. */
  78220. render(): void;
  78221. }
  78222. /**
  78223. * Class used to manage multiple sprites on the same spritesheet
  78224. * @see http://doc.babylonjs.com/babylon101/sprites
  78225. */
  78226. export class SpriteManager implements ISpriteManager {
  78227. /** defines the manager's name */
  78228. name: string;
  78229. /** Gets the list of sprites */
  78230. sprites: Sprite[];
  78231. /** Gets or sets the rendering group id (0 by default) */
  78232. renderingGroupId: number;
  78233. /** Gets or sets camera layer mask */
  78234. layerMask: number;
  78235. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78236. fogEnabled: boolean;
  78237. /** Gets or sets a boolean indicating if the sprites are pickable */
  78238. isPickable: boolean;
  78239. /** Defines the default width of a cell in the spritesheet */
  78240. cellWidth: number;
  78241. /** Defines the default height of a cell in the spritesheet */
  78242. cellHeight: number;
  78243. /** Associative array from JSON sprite data file */
  78244. private _cellData;
  78245. /** Array of sprite names from JSON sprite data file */
  78246. private _spriteMap;
  78247. /** True when packed cell data from JSON file is ready*/
  78248. private _packedAndReady;
  78249. /**
  78250. * An event triggered when the manager is disposed.
  78251. */
  78252. onDisposeObservable: Observable<SpriteManager>;
  78253. private _onDisposeObserver;
  78254. /**
  78255. * Callback called when the manager is disposed
  78256. */
  78257. onDispose: () => void;
  78258. private _capacity;
  78259. private _fromPacked;
  78260. private _spriteTexture;
  78261. private _epsilon;
  78262. private _scene;
  78263. private _vertexData;
  78264. private _buffer;
  78265. private _vertexBuffers;
  78266. private _indexBuffer;
  78267. private _effectBase;
  78268. private _effectFog;
  78269. /**
  78270. * Gets or sets the spritesheet texture
  78271. */
  78272. texture: Texture;
  78273. /**
  78274. * Creates a new sprite manager
  78275. * @param name defines the manager's name
  78276. * @param imgUrl defines the sprite sheet url
  78277. * @param capacity defines the maximum allowed number of sprites
  78278. * @param cellSize defines the size of a sprite cell
  78279. * @param scene defines the hosting scene
  78280. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78281. * @param samplingMode defines the smapling mode to use with spritesheet
  78282. * @param fromPacked set to false; do not alter
  78283. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78284. */
  78285. constructor(
  78286. /** defines the manager's name */
  78287. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78288. private _makePacked;
  78289. private _appendSpriteVertex;
  78290. /**
  78291. * Intersects the sprites with a ray
  78292. * @param ray defines the ray to intersect with
  78293. * @param camera defines the current active camera
  78294. * @param predicate defines a predicate used to select candidate sprites
  78295. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78296. * @returns null if no hit or a PickingInfo
  78297. */
  78298. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78299. /**
  78300. * Intersects the sprites with a ray
  78301. * @param ray defines the ray to intersect with
  78302. * @param camera defines the current active camera
  78303. * @param predicate defines a predicate used to select candidate sprites
  78304. * @returns null if no hit or a PickingInfo array
  78305. */
  78306. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78307. /**
  78308. * Render all child sprites
  78309. */
  78310. render(): void;
  78311. /**
  78312. * Release associated resources
  78313. */
  78314. dispose(): void;
  78315. }
  78316. }
  78317. declare module BABYLON {
  78318. /**
  78319. * Class used to represent a sprite
  78320. * @see http://doc.babylonjs.com/babylon101/sprites
  78321. */
  78322. export class Sprite {
  78323. /** defines the name */
  78324. name: string;
  78325. /** Gets or sets the current world position */
  78326. position: Vector3;
  78327. /** Gets or sets the main color */
  78328. color: Color4;
  78329. /** Gets or sets the width */
  78330. width: number;
  78331. /** Gets or sets the height */
  78332. height: number;
  78333. /** Gets or sets rotation angle */
  78334. angle: number;
  78335. /** Gets or sets the cell index in the sprite sheet */
  78336. cellIndex: number;
  78337. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78338. cellRef: string;
  78339. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78340. invertU: number;
  78341. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78342. invertV: number;
  78343. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78344. disposeWhenFinishedAnimating: boolean;
  78345. /** Gets the list of attached animations */
  78346. animations: Animation[];
  78347. /** Gets or sets a boolean indicating if the sprite can be picked */
  78348. isPickable: boolean;
  78349. /**
  78350. * Gets or sets the associated action manager
  78351. */
  78352. actionManager: Nullable<ActionManager>;
  78353. private _animationStarted;
  78354. private _loopAnimation;
  78355. private _fromIndex;
  78356. private _toIndex;
  78357. private _delay;
  78358. private _direction;
  78359. private _manager;
  78360. private _time;
  78361. private _onAnimationEnd;
  78362. /**
  78363. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78364. */
  78365. isVisible: boolean;
  78366. /**
  78367. * Gets or sets the sprite size
  78368. */
  78369. size: number;
  78370. /**
  78371. * Creates a new Sprite
  78372. * @param name defines the name
  78373. * @param manager defines the manager
  78374. */
  78375. constructor(
  78376. /** defines the name */
  78377. name: string, manager: ISpriteManager);
  78378. /**
  78379. * Starts an animation
  78380. * @param from defines the initial key
  78381. * @param to defines the end key
  78382. * @param loop defines if the animation must loop
  78383. * @param delay defines the start delay (in ms)
  78384. * @param onAnimationEnd defines a callback to call when animation ends
  78385. */
  78386. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78387. /** Stops current animation (if any) */
  78388. stopAnimation(): void;
  78389. /** @hidden */
  78390. _animate(deltaTime: number): void;
  78391. /** Release associated resources */
  78392. dispose(): void;
  78393. }
  78394. }
  78395. declare module BABYLON {
  78396. /**
  78397. * Information about the result of picking within a scene
  78398. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78399. */
  78400. export class PickingInfo {
  78401. /** @hidden */
  78402. _pickingUnavailable: boolean;
  78403. /**
  78404. * If the pick collided with an object
  78405. */
  78406. hit: boolean;
  78407. /**
  78408. * Distance away where the pick collided
  78409. */
  78410. distance: number;
  78411. /**
  78412. * The location of pick collision
  78413. */
  78414. pickedPoint: Nullable<Vector3>;
  78415. /**
  78416. * The mesh corresponding the the pick collision
  78417. */
  78418. pickedMesh: Nullable<AbstractMesh>;
  78419. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78420. bu: number;
  78421. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78422. bv: number;
  78423. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78424. faceId: number;
  78425. /** Id of the the submesh that was picked */
  78426. subMeshId: number;
  78427. /** If a sprite was picked, this will be the sprite the pick collided with */
  78428. pickedSprite: Nullable<Sprite>;
  78429. /**
  78430. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78431. */
  78432. originMesh: Nullable<AbstractMesh>;
  78433. /**
  78434. * The ray that was used to perform the picking.
  78435. */
  78436. ray: Nullable<Ray>;
  78437. /**
  78438. * Gets the normal correspodning to the face the pick collided with
  78439. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78440. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78441. * @returns The normal correspodning to the face the pick collided with
  78442. */
  78443. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78444. /**
  78445. * Gets the texture coordinates of where the pick occured
  78446. * @returns the vector containing the coordnates of the texture
  78447. */
  78448. getTextureCoordinates(): Nullable<Vector2>;
  78449. }
  78450. }
  78451. declare module BABYLON {
  78452. /**
  78453. * Gather the list of pointer event types as constants.
  78454. */
  78455. export class PointerEventTypes {
  78456. /**
  78457. * 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.
  78458. */
  78459. static readonly POINTERDOWN: number;
  78460. /**
  78461. * The pointerup event is fired when a pointer is no longer active.
  78462. */
  78463. static readonly POINTERUP: number;
  78464. /**
  78465. * The pointermove event is fired when a pointer changes coordinates.
  78466. */
  78467. static readonly POINTERMOVE: number;
  78468. /**
  78469. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78470. */
  78471. static readonly POINTERWHEEL: number;
  78472. /**
  78473. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78474. */
  78475. static readonly POINTERPICK: number;
  78476. /**
  78477. * The pointertap event is fired when a the object has been touched and released without drag.
  78478. */
  78479. static readonly POINTERTAP: number;
  78480. /**
  78481. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78482. */
  78483. static readonly POINTERDOUBLETAP: number;
  78484. }
  78485. /**
  78486. * Base class of pointer info types.
  78487. */
  78488. export class PointerInfoBase {
  78489. /**
  78490. * Defines the type of event (PointerEventTypes)
  78491. */
  78492. type: number;
  78493. /**
  78494. * Defines the related dom event
  78495. */
  78496. event: PointerEvent | MouseWheelEvent;
  78497. /**
  78498. * Instantiates the base class of pointers info.
  78499. * @param type Defines the type of event (PointerEventTypes)
  78500. * @param event Defines the related dom event
  78501. */
  78502. constructor(
  78503. /**
  78504. * Defines the type of event (PointerEventTypes)
  78505. */
  78506. type: number,
  78507. /**
  78508. * Defines the related dom event
  78509. */
  78510. event: PointerEvent | MouseWheelEvent);
  78511. }
  78512. /**
  78513. * This class is used to store pointer related info for the onPrePointerObservable event.
  78514. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  78515. */
  78516. export class PointerInfoPre extends PointerInfoBase {
  78517. /**
  78518. * Ray from a pointer if availible (eg. 6dof controller)
  78519. */
  78520. ray: Nullable<Ray>;
  78521. /**
  78522. * Defines the local position of the pointer on the canvas.
  78523. */
  78524. localPosition: Vector2;
  78525. /**
  78526. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  78527. */
  78528. skipOnPointerObservable: boolean;
  78529. /**
  78530. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  78531. * @param type Defines the type of event (PointerEventTypes)
  78532. * @param event Defines the related dom event
  78533. * @param localX Defines the local x coordinates of the pointer when the event occured
  78534. * @param localY Defines the local y coordinates of the pointer when the event occured
  78535. */
  78536. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  78537. }
  78538. /**
  78539. * This type contains all the data related to a pointer event in Babylon.js.
  78540. * 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.
  78541. */
  78542. export class PointerInfo extends PointerInfoBase {
  78543. /**
  78544. * Defines the picking info associated to the info (if any)\
  78545. */
  78546. pickInfo: Nullable<PickingInfo>;
  78547. /**
  78548. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  78549. * @param type Defines the type of event (PointerEventTypes)
  78550. * @param event Defines the related dom event
  78551. * @param pickInfo Defines the picking info associated to the info (if any)\
  78552. */
  78553. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  78554. /**
  78555. * Defines the picking info associated to the info (if any)\
  78556. */
  78557. pickInfo: Nullable<PickingInfo>);
  78558. }
  78559. /**
  78560. * Data relating to a touch event on the screen.
  78561. */
  78562. export interface PointerTouch {
  78563. /**
  78564. * X coordinate of touch.
  78565. */
  78566. x: number;
  78567. /**
  78568. * Y coordinate of touch.
  78569. */
  78570. y: number;
  78571. /**
  78572. * Id of touch. Unique for each finger.
  78573. */
  78574. pointerId: number;
  78575. /**
  78576. * Event type passed from DOM.
  78577. */
  78578. type: any;
  78579. }
  78580. }
  78581. declare module BABYLON {
  78582. /**
  78583. * Manage the mouse inputs to control the movement of a free camera.
  78584. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78585. */
  78586. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  78587. /**
  78588. * Define if touch is enabled in the mouse input
  78589. */
  78590. touchEnabled: boolean;
  78591. /**
  78592. * Defines the camera the input is attached to.
  78593. */
  78594. camera: FreeCamera;
  78595. /**
  78596. * Defines the buttons associated with the input to handle camera move.
  78597. */
  78598. buttons: number[];
  78599. /**
  78600. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  78601. */
  78602. angularSensibility: number;
  78603. private _pointerInput;
  78604. private _onMouseMove;
  78605. private _observer;
  78606. private previousPosition;
  78607. /**
  78608. * Observable for when a pointer move event occurs containing the move offset
  78609. */
  78610. onPointerMovedObservable: Observable<{
  78611. offsetX: number;
  78612. offsetY: number;
  78613. }>;
  78614. /**
  78615. * @hidden
  78616. * If the camera should be rotated automatically based on pointer movement
  78617. */
  78618. _allowCameraRotation: boolean;
  78619. /**
  78620. * Manage the mouse inputs to control the movement of a free camera.
  78621. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78622. * @param touchEnabled Defines if touch is enabled or not
  78623. */
  78624. constructor(
  78625. /**
  78626. * Define if touch is enabled in the mouse input
  78627. */
  78628. touchEnabled?: boolean);
  78629. /**
  78630. * Attach the input controls to a specific dom element to get the input from.
  78631. * @param element Defines the element the controls should be listened from
  78632. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78633. */
  78634. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78635. /**
  78636. * Called on JS contextmenu event.
  78637. * Override this method to provide functionality.
  78638. */
  78639. protected onContextMenu(evt: PointerEvent): void;
  78640. /**
  78641. * Detach the current controls from the specified dom element.
  78642. * @param element Defines the element to stop listening the inputs from
  78643. */
  78644. detachControl(element: Nullable<HTMLElement>): void;
  78645. /**
  78646. * Gets the class name of the current intput.
  78647. * @returns the class name
  78648. */
  78649. getClassName(): string;
  78650. /**
  78651. * Get the friendly name associated with the input class.
  78652. * @returns the input friendly name
  78653. */
  78654. getSimpleName(): string;
  78655. }
  78656. }
  78657. declare module BABYLON {
  78658. /**
  78659. * Manage the touch inputs to control the movement of a free camera.
  78660. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78661. */
  78662. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  78663. /**
  78664. * Defines the camera the input is attached to.
  78665. */
  78666. camera: FreeCamera;
  78667. /**
  78668. * Defines the touch sensibility for rotation.
  78669. * The higher the faster.
  78670. */
  78671. touchAngularSensibility: number;
  78672. /**
  78673. * Defines the touch sensibility for move.
  78674. * The higher the faster.
  78675. */
  78676. touchMoveSensibility: number;
  78677. private _offsetX;
  78678. private _offsetY;
  78679. private _pointerPressed;
  78680. private _pointerInput;
  78681. private _observer;
  78682. private _onLostFocus;
  78683. /**
  78684. * Attach the input controls to a specific dom element to get the input from.
  78685. * @param element Defines the element the controls should be listened from
  78686. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78687. */
  78688. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78689. /**
  78690. * Detach the current controls from the specified dom element.
  78691. * @param element Defines the element to stop listening the inputs from
  78692. */
  78693. detachControl(element: Nullable<HTMLElement>): void;
  78694. /**
  78695. * Update the current camera state depending on the inputs that have been used this frame.
  78696. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78697. */
  78698. checkInputs(): void;
  78699. /**
  78700. * Gets the class name of the current intput.
  78701. * @returns the class name
  78702. */
  78703. getClassName(): string;
  78704. /**
  78705. * Get the friendly name associated with the input class.
  78706. * @returns the input friendly name
  78707. */
  78708. getSimpleName(): string;
  78709. }
  78710. }
  78711. declare module BABYLON {
  78712. /**
  78713. * Default Inputs manager for the FreeCamera.
  78714. * It groups all the default supported inputs for ease of use.
  78715. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78716. */
  78717. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  78718. /**
  78719. * @hidden
  78720. */
  78721. _mouseInput: Nullable<FreeCameraMouseInput>;
  78722. /**
  78723. * Instantiates a new FreeCameraInputsManager.
  78724. * @param camera Defines the camera the inputs belong to
  78725. */
  78726. constructor(camera: FreeCamera);
  78727. /**
  78728. * Add keyboard input support to the input manager.
  78729. * @returns the current input manager
  78730. */
  78731. addKeyboard(): FreeCameraInputsManager;
  78732. /**
  78733. * Add mouse input support to the input manager.
  78734. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  78735. * @returns the current input manager
  78736. */
  78737. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  78738. /**
  78739. * Removes the mouse input support from the manager
  78740. * @returns the current input manager
  78741. */
  78742. removeMouse(): FreeCameraInputsManager;
  78743. /**
  78744. * Add touch input support to the input manager.
  78745. * @returns the current input manager
  78746. */
  78747. addTouch(): FreeCameraInputsManager;
  78748. /**
  78749. * Remove all attached input methods from a camera
  78750. */
  78751. clear(): void;
  78752. }
  78753. }
  78754. declare module BABYLON {
  78755. /**
  78756. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78757. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  78758. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78759. */
  78760. export class FreeCamera extends TargetCamera {
  78761. /**
  78762. * Define the collision ellipsoid of the camera.
  78763. * This is helpful to simulate a camera body like the player body around the camera
  78764. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  78765. */
  78766. ellipsoid: Vector3;
  78767. /**
  78768. * Define an offset for the position of the ellipsoid around the camera.
  78769. * This can be helpful to determine the center of the body near the gravity center of the body
  78770. * instead of its head.
  78771. */
  78772. ellipsoidOffset: Vector3;
  78773. /**
  78774. * Enable or disable collisions of the camera with the rest of the scene objects.
  78775. */
  78776. checkCollisions: boolean;
  78777. /**
  78778. * Enable or disable gravity on the camera.
  78779. */
  78780. applyGravity: boolean;
  78781. /**
  78782. * Define the input manager associated to the camera.
  78783. */
  78784. inputs: FreeCameraInputsManager;
  78785. /**
  78786. * Gets the input sensibility for a mouse input. (default is 2000.0)
  78787. * Higher values reduce sensitivity.
  78788. */
  78789. /**
  78790. * Sets the input sensibility for a mouse input. (default is 2000.0)
  78791. * Higher values reduce sensitivity.
  78792. */
  78793. angularSensibility: number;
  78794. /**
  78795. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78796. */
  78797. keysUp: number[];
  78798. /**
  78799. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78800. */
  78801. keysDown: number[];
  78802. /**
  78803. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78804. */
  78805. keysLeft: number[];
  78806. /**
  78807. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78808. */
  78809. keysRight: number[];
  78810. /**
  78811. * Event raised when the camera collide with a mesh in the scene.
  78812. */
  78813. onCollide: (collidedMesh: AbstractMesh) => void;
  78814. private _collider;
  78815. private _needMoveForGravity;
  78816. private _oldPosition;
  78817. private _diffPosition;
  78818. private _newPosition;
  78819. /** @hidden */
  78820. _localDirection: Vector3;
  78821. /** @hidden */
  78822. _transformedDirection: Vector3;
  78823. /**
  78824. * Instantiates a Free Camera.
  78825. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78826. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  78827. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78828. * @param name Define the name of the camera in the scene
  78829. * @param position Define the start position of the camera in the scene
  78830. * @param scene Define the scene the camera belongs to
  78831. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  78832. */
  78833. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  78834. /**
  78835. * Attached controls to the current camera.
  78836. * @param element Defines the element the controls should be listened from
  78837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78838. */
  78839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78840. /**
  78841. * Detach the current controls from the camera.
  78842. * The camera will stop reacting to inputs.
  78843. * @param element Defines the element to stop listening the inputs from
  78844. */
  78845. detachControl(element: HTMLElement): void;
  78846. private _collisionMask;
  78847. /**
  78848. * Define a collision mask to limit the list of object the camera can collide with
  78849. */
  78850. collisionMask: number;
  78851. /** @hidden */
  78852. _collideWithWorld(displacement: Vector3): void;
  78853. private _onCollisionPositionChange;
  78854. /** @hidden */
  78855. _checkInputs(): void;
  78856. /** @hidden */
  78857. _decideIfNeedsToMove(): boolean;
  78858. /** @hidden */
  78859. _updatePosition(): void;
  78860. /**
  78861. * Destroy the camera and release the current resources hold by it.
  78862. */
  78863. dispose(): void;
  78864. /**
  78865. * Gets the current object class name.
  78866. * @return the class name
  78867. */
  78868. getClassName(): string;
  78869. }
  78870. }
  78871. declare module BABYLON {
  78872. /**
  78873. * Represents a gamepad control stick position
  78874. */
  78875. export class StickValues {
  78876. /**
  78877. * The x component of the control stick
  78878. */
  78879. x: number;
  78880. /**
  78881. * The y component of the control stick
  78882. */
  78883. y: number;
  78884. /**
  78885. * Initializes the gamepad x and y control stick values
  78886. * @param x The x component of the gamepad control stick value
  78887. * @param y The y component of the gamepad control stick value
  78888. */
  78889. constructor(
  78890. /**
  78891. * The x component of the control stick
  78892. */
  78893. x: number,
  78894. /**
  78895. * The y component of the control stick
  78896. */
  78897. y: number);
  78898. }
  78899. /**
  78900. * An interface which manages callbacks for gamepad button changes
  78901. */
  78902. export interface GamepadButtonChanges {
  78903. /**
  78904. * Called when a gamepad has been changed
  78905. */
  78906. changed: boolean;
  78907. /**
  78908. * Called when a gamepad press event has been triggered
  78909. */
  78910. pressChanged: boolean;
  78911. /**
  78912. * Called when a touch event has been triggered
  78913. */
  78914. touchChanged: boolean;
  78915. /**
  78916. * Called when a value has changed
  78917. */
  78918. valueChanged: boolean;
  78919. }
  78920. /**
  78921. * Represents a gamepad
  78922. */
  78923. export class Gamepad {
  78924. /**
  78925. * The id of the gamepad
  78926. */
  78927. id: string;
  78928. /**
  78929. * The index of the gamepad
  78930. */
  78931. index: number;
  78932. /**
  78933. * The browser gamepad
  78934. */
  78935. browserGamepad: any;
  78936. /**
  78937. * Specifies what type of gamepad this represents
  78938. */
  78939. type: number;
  78940. private _leftStick;
  78941. private _rightStick;
  78942. /** @hidden */
  78943. _isConnected: boolean;
  78944. private _leftStickAxisX;
  78945. private _leftStickAxisY;
  78946. private _rightStickAxisX;
  78947. private _rightStickAxisY;
  78948. /**
  78949. * Triggered when the left control stick has been changed
  78950. */
  78951. private _onleftstickchanged;
  78952. /**
  78953. * Triggered when the right control stick has been changed
  78954. */
  78955. private _onrightstickchanged;
  78956. /**
  78957. * Represents a gamepad controller
  78958. */
  78959. static GAMEPAD: number;
  78960. /**
  78961. * Represents a generic controller
  78962. */
  78963. static GENERIC: number;
  78964. /**
  78965. * Represents an XBox controller
  78966. */
  78967. static XBOX: number;
  78968. /**
  78969. * Represents a pose-enabled controller
  78970. */
  78971. static POSE_ENABLED: number;
  78972. /**
  78973. * Represents an Dual Shock controller
  78974. */
  78975. static DUALSHOCK: number;
  78976. /**
  78977. * Specifies whether the left control stick should be Y-inverted
  78978. */
  78979. protected _invertLeftStickY: boolean;
  78980. /**
  78981. * Specifies if the gamepad has been connected
  78982. */
  78983. readonly isConnected: boolean;
  78984. /**
  78985. * Initializes the gamepad
  78986. * @param id The id of the gamepad
  78987. * @param index The index of the gamepad
  78988. * @param browserGamepad The browser gamepad
  78989. * @param leftStickX The x component of the left joystick
  78990. * @param leftStickY The y component of the left joystick
  78991. * @param rightStickX The x component of the right joystick
  78992. * @param rightStickY The y component of the right joystick
  78993. */
  78994. constructor(
  78995. /**
  78996. * The id of the gamepad
  78997. */
  78998. id: string,
  78999. /**
  79000. * The index of the gamepad
  79001. */
  79002. index: number,
  79003. /**
  79004. * The browser gamepad
  79005. */
  79006. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79007. /**
  79008. * Callback triggered when the left joystick has changed
  79009. * @param callback
  79010. */
  79011. onleftstickchanged(callback: (values: StickValues) => void): void;
  79012. /**
  79013. * Callback triggered when the right joystick has changed
  79014. * @param callback
  79015. */
  79016. onrightstickchanged(callback: (values: StickValues) => void): void;
  79017. /**
  79018. * Gets the left joystick
  79019. */
  79020. /**
  79021. * Sets the left joystick values
  79022. */
  79023. leftStick: StickValues;
  79024. /**
  79025. * Gets the right joystick
  79026. */
  79027. /**
  79028. * Sets the right joystick value
  79029. */
  79030. rightStick: StickValues;
  79031. /**
  79032. * Updates the gamepad joystick positions
  79033. */
  79034. update(): void;
  79035. /**
  79036. * Disposes the gamepad
  79037. */
  79038. dispose(): void;
  79039. }
  79040. /**
  79041. * Represents a generic gamepad
  79042. */
  79043. export class GenericPad extends Gamepad {
  79044. private _buttons;
  79045. private _onbuttondown;
  79046. private _onbuttonup;
  79047. /**
  79048. * Observable triggered when a button has been pressed
  79049. */
  79050. onButtonDownObservable: Observable<number>;
  79051. /**
  79052. * Observable triggered when a button has been released
  79053. */
  79054. onButtonUpObservable: Observable<number>;
  79055. /**
  79056. * Callback triggered when a button has been pressed
  79057. * @param callback Called when a button has been pressed
  79058. */
  79059. onbuttondown(callback: (buttonPressed: number) => void): void;
  79060. /**
  79061. * Callback triggered when a button has been released
  79062. * @param callback Called when a button has been released
  79063. */
  79064. onbuttonup(callback: (buttonReleased: number) => void): void;
  79065. /**
  79066. * Initializes the generic gamepad
  79067. * @param id The id of the generic gamepad
  79068. * @param index The index of the generic gamepad
  79069. * @param browserGamepad The browser gamepad
  79070. */
  79071. constructor(id: string, index: number, browserGamepad: any);
  79072. private _setButtonValue;
  79073. /**
  79074. * Updates the generic gamepad
  79075. */
  79076. update(): void;
  79077. /**
  79078. * Disposes the generic gamepad
  79079. */
  79080. dispose(): void;
  79081. }
  79082. }
  79083. declare module BABYLON {
  79084. interface Engine {
  79085. /**
  79086. * Creates a raw texture
  79087. * @param data defines the data to store in the texture
  79088. * @param width defines the width of the texture
  79089. * @param height defines the height of the texture
  79090. * @param format defines the format of the data
  79091. * @param generateMipMaps defines if the engine should generate the mip levels
  79092. * @param invertY defines if data must be stored with Y axis inverted
  79093. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79094. * @param compression defines the compression used (null by default)
  79095. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79096. * @returns the raw texture inside an InternalTexture
  79097. */
  79098. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79099. /**
  79100. * Update a raw texture
  79101. * @param texture defines the texture to update
  79102. * @param data defines the data to store in the texture
  79103. * @param format defines the format of the data
  79104. * @param invertY defines if data must be stored with Y axis inverted
  79105. */
  79106. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79107. /**
  79108. * Update a raw texture
  79109. * @param texture defines the texture to update
  79110. * @param data defines the data to store in the texture
  79111. * @param format defines the format of the data
  79112. * @param invertY defines if data must be stored with Y axis inverted
  79113. * @param compression defines the compression used (null by default)
  79114. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79115. */
  79116. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79117. /**
  79118. * Creates a new raw cube texture
  79119. * @param data defines the array of data to use to create each face
  79120. * @param size defines the size of the textures
  79121. * @param format defines the format of the data
  79122. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79123. * @param generateMipMaps defines if the engine should generate the mip levels
  79124. * @param invertY defines if data must be stored with Y axis inverted
  79125. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79126. * @param compression defines the compression used (null by default)
  79127. * @returns the cube texture as an InternalTexture
  79128. */
  79129. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79130. /**
  79131. * Update a raw cube texture
  79132. * @param texture defines the texture to udpdate
  79133. * @param data defines the data to store
  79134. * @param format defines the data format
  79135. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79136. * @param invertY defines if data must be stored with Y axis inverted
  79137. */
  79138. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79139. /**
  79140. * Update a raw cube texture
  79141. * @param texture defines the texture to udpdate
  79142. * @param data defines the data to store
  79143. * @param format defines the data format
  79144. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79145. * @param invertY defines if data must be stored with Y axis inverted
  79146. * @param compression defines the compression used (null by default)
  79147. */
  79148. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79149. /**
  79150. * Update a raw cube texture
  79151. * @param texture defines the texture to udpdate
  79152. * @param data defines the data to store
  79153. * @param format defines the data format
  79154. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79155. * @param invertY defines if data must be stored with Y axis inverted
  79156. * @param compression defines the compression used (null by default)
  79157. * @param level defines which level of the texture to update
  79158. */
  79159. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79160. /**
  79161. * Creates a new raw cube texture from a specified url
  79162. * @param url defines the url where the data is located
  79163. * @param scene defines the current scene
  79164. * @param size defines the size of the textures
  79165. * @param format defines the format of the data
  79166. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79167. * @param noMipmap defines if the engine should avoid generating the mip levels
  79168. * @param callback defines a callback used to extract texture data from loaded data
  79169. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79170. * @param onLoad defines a callback called when texture is loaded
  79171. * @param onError defines a callback called if there is an error
  79172. * @returns the cube texture as an InternalTexture
  79173. */
  79174. 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;
  79175. /**
  79176. * Creates a new raw cube texture from a specified url
  79177. * @param url defines the url where the data is located
  79178. * @param scene defines the current scene
  79179. * @param size defines the size of the textures
  79180. * @param format defines the format of the data
  79181. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79182. * @param noMipmap defines if the engine should avoid generating the mip levels
  79183. * @param callback defines a callback used to extract texture data from loaded data
  79184. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79185. * @param onLoad defines a callback called when texture is loaded
  79186. * @param onError defines a callback called if there is an error
  79187. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79188. * @param invertY defines if data must be stored with Y axis inverted
  79189. * @returns the cube texture as an InternalTexture
  79190. */
  79191. 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;
  79192. /**
  79193. * Creates a new raw 3D texture
  79194. * @param data defines the data used to create the texture
  79195. * @param width defines the width of the texture
  79196. * @param height defines the height of the texture
  79197. * @param depth defines the depth of the texture
  79198. * @param format defines the format of the texture
  79199. * @param generateMipMaps defines if the engine must generate mip levels
  79200. * @param invertY defines if data must be stored with Y axis inverted
  79201. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79202. * @param compression defines the compressed used (can be null)
  79203. * @param textureType defines the compressed used (can be null)
  79204. * @returns a new raw 3D texture (stored in an InternalTexture)
  79205. */
  79206. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79207. /**
  79208. * Update a raw 3D texture
  79209. * @param texture defines the texture to update
  79210. * @param data defines the data to store
  79211. * @param format defines the data format
  79212. * @param invertY defines if data must be stored with Y axis inverted
  79213. */
  79214. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79215. /**
  79216. * Update a raw 3D texture
  79217. * @param texture defines the texture to update
  79218. * @param data defines the data to store
  79219. * @param format defines the data format
  79220. * @param invertY defines if data must be stored with Y axis inverted
  79221. * @param compression defines the used compression (can be null)
  79222. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79223. */
  79224. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79225. }
  79226. }
  79227. declare module BABYLON {
  79228. /**
  79229. * Raw texture can help creating a texture directly from an array of data.
  79230. * This can be super useful if you either get the data from an uncompressed source or
  79231. * if you wish to create your texture pixel by pixel.
  79232. */
  79233. export class RawTexture extends Texture {
  79234. /**
  79235. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79236. */
  79237. format: number;
  79238. private _engine;
  79239. /**
  79240. * Instantiates a new RawTexture.
  79241. * Raw texture can help creating a texture directly from an array of data.
  79242. * This can be super useful if you either get the data from an uncompressed source or
  79243. * if you wish to create your texture pixel by pixel.
  79244. * @param data define the array of data to use to create the texture
  79245. * @param width define the width of the texture
  79246. * @param height define the height of the texture
  79247. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79248. * @param scene define the scene the texture belongs to
  79249. * @param generateMipMaps define whether mip maps should be generated or not
  79250. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79251. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79252. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79253. */
  79254. constructor(data: ArrayBufferView, width: number, height: number,
  79255. /**
  79256. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79257. */
  79258. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79259. /**
  79260. * Updates the texture underlying data.
  79261. * @param data Define the new data of the texture
  79262. */
  79263. update(data: ArrayBufferView): void;
  79264. /**
  79265. * Creates a luminance texture from some data.
  79266. * @param data Define the texture data
  79267. * @param width Define the width of the texture
  79268. * @param height Define the height of the texture
  79269. * @param scene Define the scene the texture belongs to
  79270. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79271. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79272. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79273. * @returns the luminance texture
  79274. */
  79275. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79276. /**
  79277. * Creates a luminance alpha texture from some data.
  79278. * @param data Define the texture data
  79279. * @param width Define the width of the texture
  79280. * @param height Define the height of the texture
  79281. * @param scene Define the scene the texture belongs to
  79282. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79283. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79284. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79285. * @returns the luminance alpha texture
  79286. */
  79287. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79288. /**
  79289. * Creates an alpha texture from some data.
  79290. * @param data Define the texture data
  79291. * @param width Define the width of the texture
  79292. * @param height Define the height of the texture
  79293. * @param scene Define the scene the texture belongs to
  79294. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79295. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79296. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79297. * @returns the alpha texture
  79298. */
  79299. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79300. /**
  79301. * Creates a RGB texture from some data.
  79302. * @param data Define the texture data
  79303. * @param width Define the width of the texture
  79304. * @param height Define the height of the texture
  79305. * @param scene Define the scene the texture belongs to
  79306. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79307. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79308. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79309. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79310. * @returns the RGB alpha texture
  79311. */
  79312. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79313. /**
  79314. * Creates a RGBA texture from some data.
  79315. * @param data Define the texture data
  79316. * @param width Define the width of the texture
  79317. * @param height Define the height of the texture
  79318. * @param scene Define the scene the texture belongs to
  79319. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79320. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79321. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79322. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79323. * @returns the RGBA texture
  79324. */
  79325. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79326. /**
  79327. * Creates a R texture from some data.
  79328. * @param data Define the texture data
  79329. * @param width Define the width of the texture
  79330. * @param height Define the height of the texture
  79331. * @param scene Define the scene the texture belongs to
  79332. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79333. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79334. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79335. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79336. * @returns the R texture
  79337. */
  79338. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79339. }
  79340. }
  79341. declare module BABYLON {
  79342. /**
  79343. * Interface for the size containing width and height
  79344. */
  79345. export interface ISize {
  79346. /**
  79347. * Width
  79348. */
  79349. width: number;
  79350. /**
  79351. * Heighht
  79352. */
  79353. height: number;
  79354. }
  79355. /**
  79356. * Size containing widht and height
  79357. */
  79358. export class Size implements ISize {
  79359. /**
  79360. * Width
  79361. */
  79362. width: number;
  79363. /**
  79364. * Height
  79365. */
  79366. height: number;
  79367. /**
  79368. * Creates a Size object from the given width and height (floats).
  79369. * @param width width of the new size
  79370. * @param height height of the new size
  79371. */
  79372. constructor(width: number, height: number);
  79373. /**
  79374. * Returns a string with the Size width and height
  79375. * @returns a string with the Size width and height
  79376. */
  79377. toString(): string;
  79378. /**
  79379. * "Size"
  79380. * @returns the string "Size"
  79381. */
  79382. getClassName(): string;
  79383. /**
  79384. * Returns the Size hash code.
  79385. * @returns a hash code for a unique width and height
  79386. */
  79387. getHashCode(): number;
  79388. /**
  79389. * Updates the current size from the given one.
  79390. * @param src the given size
  79391. */
  79392. copyFrom(src: Size): void;
  79393. /**
  79394. * Updates in place the current Size from the given floats.
  79395. * @param width width of the new size
  79396. * @param height height of the new size
  79397. * @returns the updated Size.
  79398. */
  79399. copyFromFloats(width: number, height: number): Size;
  79400. /**
  79401. * Updates in place the current Size from the given floats.
  79402. * @param width width to set
  79403. * @param height height to set
  79404. * @returns the updated Size.
  79405. */
  79406. set(width: number, height: number): Size;
  79407. /**
  79408. * Multiplies the width and height by numbers
  79409. * @param w factor to multiple the width by
  79410. * @param h factor to multiple the height by
  79411. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  79412. */
  79413. multiplyByFloats(w: number, h: number): Size;
  79414. /**
  79415. * Clones the size
  79416. * @returns a new Size copied from the given one.
  79417. */
  79418. clone(): Size;
  79419. /**
  79420. * True if the current Size and the given one width and height are strictly equal.
  79421. * @param other the other size to compare against
  79422. * @returns True if the current Size and the given one width and height are strictly equal.
  79423. */
  79424. equals(other: Size): boolean;
  79425. /**
  79426. * The surface of the Size : width * height (float).
  79427. */
  79428. readonly surface: number;
  79429. /**
  79430. * Create a new size of zero
  79431. * @returns a new Size set to (0.0, 0.0)
  79432. */
  79433. static Zero(): Size;
  79434. /**
  79435. * Sums the width and height of two sizes
  79436. * @param otherSize size to add to this size
  79437. * @returns a new Size set as the addition result of the current Size and the given one.
  79438. */
  79439. add(otherSize: Size): Size;
  79440. /**
  79441. * Subtracts the width and height of two
  79442. * @param otherSize size to subtract to this size
  79443. * @returns a new Size set as the subtraction result of the given one from the current Size.
  79444. */
  79445. subtract(otherSize: Size): Size;
  79446. /**
  79447. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  79448. * @param start starting size to lerp between
  79449. * @param end end size to lerp between
  79450. * @param amount amount to lerp between the start and end values
  79451. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  79452. */
  79453. static Lerp(start: Size, end: Size, amount: number): Size;
  79454. }
  79455. }
  79456. declare module BABYLON {
  79457. /**
  79458. * Defines a runtime animation
  79459. */
  79460. export class RuntimeAnimation {
  79461. private _events;
  79462. /**
  79463. * The current frame of the runtime animation
  79464. */
  79465. private _currentFrame;
  79466. /**
  79467. * The animation used by the runtime animation
  79468. */
  79469. private _animation;
  79470. /**
  79471. * The target of the runtime animation
  79472. */
  79473. private _target;
  79474. /**
  79475. * The initiating animatable
  79476. */
  79477. private _host;
  79478. /**
  79479. * The original value of the runtime animation
  79480. */
  79481. private _originalValue;
  79482. /**
  79483. * The original blend value of the runtime animation
  79484. */
  79485. private _originalBlendValue;
  79486. /**
  79487. * The offsets cache of the runtime animation
  79488. */
  79489. private _offsetsCache;
  79490. /**
  79491. * The high limits cache of the runtime animation
  79492. */
  79493. private _highLimitsCache;
  79494. /**
  79495. * Specifies if the runtime animation has been stopped
  79496. */
  79497. private _stopped;
  79498. /**
  79499. * The blending factor of the runtime animation
  79500. */
  79501. private _blendingFactor;
  79502. /**
  79503. * The BabylonJS scene
  79504. */
  79505. private _scene;
  79506. /**
  79507. * The current value of the runtime animation
  79508. */
  79509. private _currentValue;
  79510. /** @hidden */
  79511. _animationState: _IAnimationState;
  79512. /**
  79513. * The active target of the runtime animation
  79514. */
  79515. private _activeTargets;
  79516. private _currentActiveTarget;
  79517. private _directTarget;
  79518. /**
  79519. * The target path of the runtime animation
  79520. */
  79521. private _targetPath;
  79522. /**
  79523. * The weight of the runtime animation
  79524. */
  79525. private _weight;
  79526. /**
  79527. * The ratio offset of the runtime animation
  79528. */
  79529. private _ratioOffset;
  79530. /**
  79531. * The previous delay of the runtime animation
  79532. */
  79533. private _previousDelay;
  79534. /**
  79535. * The previous ratio of the runtime animation
  79536. */
  79537. private _previousRatio;
  79538. private _enableBlending;
  79539. private _keys;
  79540. private _minFrame;
  79541. private _maxFrame;
  79542. private _minValue;
  79543. private _maxValue;
  79544. private _targetIsArray;
  79545. /**
  79546. * Gets the current frame of the runtime animation
  79547. */
  79548. readonly currentFrame: number;
  79549. /**
  79550. * Gets the weight of the runtime animation
  79551. */
  79552. readonly weight: number;
  79553. /**
  79554. * Gets the current value of the runtime animation
  79555. */
  79556. readonly currentValue: any;
  79557. /**
  79558. * Gets the target path of the runtime animation
  79559. */
  79560. readonly targetPath: string;
  79561. /**
  79562. * Gets the actual target of the runtime animation
  79563. */
  79564. readonly target: any;
  79565. /** @hidden */
  79566. _onLoop: () => void;
  79567. /**
  79568. * Create a new RuntimeAnimation object
  79569. * @param target defines the target of the animation
  79570. * @param animation defines the source animation object
  79571. * @param scene defines the hosting scene
  79572. * @param host defines the initiating Animatable
  79573. */
  79574. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  79575. private _preparePath;
  79576. /**
  79577. * Gets the animation from the runtime animation
  79578. */
  79579. readonly animation: Animation;
  79580. /**
  79581. * Resets the runtime animation to the beginning
  79582. * @param restoreOriginal defines whether to restore the target property to the original value
  79583. */
  79584. reset(restoreOriginal?: boolean): void;
  79585. /**
  79586. * Specifies if the runtime animation is stopped
  79587. * @returns Boolean specifying if the runtime animation is stopped
  79588. */
  79589. isStopped(): boolean;
  79590. /**
  79591. * Disposes of the runtime animation
  79592. */
  79593. dispose(): void;
  79594. /**
  79595. * Apply the interpolated value to the target
  79596. * @param currentValue defines the value computed by the animation
  79597. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  79598. */
  79599. setValue(currentValue: any, weight: number): void;
  79600. private _getOriginalValues;
  79601. private _setValue;
  79602. /**
  79603. * Gets the loop pmode of the runtime animation
  79604. * @returns Loop Mode
  79605. */
  79606. private _getCorrectLoopMode;
  79607. /**
  79608. * Move the current animation to a given frame
  79609. * @param frame defines the frame to move to
  79610. */
  79611. goToFrame(frame: number): void;
  79612. /**
  79613. * @hidden Internal use only
  79614. */
  79615. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  79616. /**
  79617. * Execute the current animation
  79618. * @param delay defines the delay to add to the current frame
  79619. * @param from defines the lower bound of the animation range
  79620. * @param to defines the upper bound of the animation range
  79621. * @param loop defines if the current animation must loop
  79622. * @param speedRatio defines the current speed ratio
  79623. * @param weight defines the weight of the animation (default is -1 so no weight)
  79624. * @param onLoop optional callback called when animation loops
  79625. * @returns a boolean indicating if the animation is running
  79626. */
  79627. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  79628. }
  79629. }
  79630. declare module BABYLON {
  79631. /**
  79632. * Class used to store an actual running animation
  79633. */
  79634. export class Animatable {
  79635. /** defines the target object */
  79636. target: any;
  79637. /** defines the starting frame number (default is 0) */
  79638. fromFrame: number;
  79639. /** defines the ending frame number (default is 100) */
  79640. toFrame: number;
  79641. /** defines if the animation must loop (default is false) */
  79642. loopAnimation: boolean;
  79643. /** defines a callback to call when animation ends if it is not looping */
  79644. onAnimationEnd?: (() => void) | null | undefined;
  79645. /** defines a callback to call when animation loops */
  79646. onAnimationLoop?: (() => void) | null | undefined;
  79647. private _localDelayOffset;
  79648. private _pausedDelay;
  79649. private _runtimeAnimations;
  79650. private _paused;
  79651. private _scene;
  79652. private _speedRatio;
  79653. private _weight;
  79654. private _syncRoot;
  79655. /**
  79656. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  79657. * This will only apply for non looping animation (default is true)
  79658. */
  79659. disposeOnEnd: boolean;
  79660. /**
  79661. * Gets a boolean indicating if the animation has started
  79662. */
  79663. animationStarted: boolean;
  79664. /**
  79665. * Observer raised when the animation ends
  79666. */
  79667. onAnimationEndObservable: Observable<Animatable>;
  79668. /**
  79669. * Observer raised when the animation loops
  79670. */
  79671. onAnimationLoopObservable: Observable<Animatable>;
  79672. /**
  79673. * Gets the root Animatable used to synchronize and normalize animations
  79674. */
  79675. readonly syncRoot: Nullable<Animatable>;
  79676. /**
  79677. * Gets the current frame of the first RuntimeAnimation
  79678. * Used to synchronize Animatables
  79679. */
  79680. readonly masterFrame: number;
  79681. /**
  79682. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  79683. */
  79684. weight: number;
  79685. /**
  79686. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  79687. */
  79688. speedRatio: number;
  79689. /**
  79690. * Creates a new Animatable
  79691. * @param scene defines the hosting scene
  79692. * @param target defines the target object
  79693. * @param fromFrame defines the starting frame number (default is 0)
  79694. * @param toFrame defines the ending frame number (default is 100)
  79695. * @param loopAnimation defines if the animation must loop (default is false)
  79696. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  79697. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  79698. * @param animations defines a group of animation to add to the new Animatable
  79699. * @param onAnimationLoop defines a callback to call when animation loops
  79700. */
  79701. constructor(scene: Scene,
  79702. /** defines the target object */
  79703. target: any,
  79704. /** defines the starting frame number (default is 0) */
  79705. fromFrame?: number,
  79706. /** defines the ending frame number (default is 100) */
  79707. toFrame?: number,
  79708. /** defines if the animation must loop (default is false) */
  79709. loopAnimation?: boolean, speedRatio?: number,
  79710. /** defines a callback to call when animation ends if it is not looping */
  79711. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  79712. /** defines a callback to call when animation loops */
  79713. onAnimationLoop?: (() => void) | null | undefined);
  79714. /**
  79715. * Synchronize and normalize current Animatable with a source Animatable
  79716. * This is useful when using animation weights and when animations are not of the same length
  79717. * @param root defines the root Animatable to synchronize with
  79718. * @returns the current Animatable
  79719. */
  79720. syncWith(root: Animatable): Animatable;
  79721. /**
  79722. * Gets the list of runtime animations
  79723. * @returns an array of RuntimeAnimation
  79724. */
  79725. getAnimations(): RuntimeAnimation[];
  79726. /**
  79727. * Adds more animations to the current animatable
  79728. * @param target defines the target of the animations
  79729. * @param animations defines the new animations to add
  79730. */
  79731. appendAnimations(target: any, animations: Animation[]): void;
  79732. /**
  79733. * Gets the source animation for a specific property
  79734. * @param property defines the propertyu to look for
  79735. * @returns null or the source animation for the given property
  79736. */
  79737. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  79738. /**
  79739. * Gets the runtime animation for a specific property
  79740. * @param property defines the propertyu to look for
  79741. * @returns null or the runtime animation for the given property
  79742. */
  79743. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  79744. /**
  79745. * Resets the animatable to its original state
  79746. */
  79747. reset(): void;
  79748. /**
  79749. * Allows the animatable to blend with current running animations
  79750. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79751. * @param blendingSpeed defines the blending speed to use
  79752. */
  79753. enableBlending(blendingSpeed: number): void;
  79754. /**
  79755. * Disable animation blending
  79756. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79757. */
  79758. disableBlending(): void;
  79759. /**
  79760. * Jump directly to a given frame
  79761. * @param frame defines the frame to jump to
  79762. */
  79763. goToFrame(frame: number): void;
  79764. /**
  79765. * Pause the animation
  79766. */
  79767. pause(): void;
  79768. /**
  79769. * Restart the animation
  79770. */
  79771. restart(): void;
  79772. private _raiseOnAnimationEnd;
  79773. /**
  79774. * Stop and delete the current animation
  79775. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  79776. * @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)
  79777. */
  79778. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  79779. /**
  79780. * Wait asynchronously for the animation to end
  79781. * @returns a promise which will be fullfilled when the animation ends
  79782. */
  79783. waitAsync(): Promise<Animatable>;
  79784. /** @hidden */
  79785. _animate(delay: number): boolean;
  79786. }
  79787. interface Scene {
  79788. /** @hidden */
  79789. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  79790. /** @hidden */
  79791. _processLateAnimationBindingsForMatrices(holder: {
  79792. totalWeight: number;
  79793. animations: RuntimeAnimation[];
  79794. originalValue: Matrix;
  79795. }): any;
  79796. /** @hidden */
  79797. _processLateAnimationBindingsForQuaternions(holder: {
  79798. totalWeight: number;
  79799. animations: RuntimeAnimation[];
  79800. originalValue: Quaternion;
  79801. }, refQuaternion: Quaternion): Quaternion;
  79802. /** @hidden */
  79803. _processLateAnimationBindings(): void;
  79804. /**
  79805. * Will start the animation sequence of a given target
  79806. * @param target defines the target
  79807. * @param from defines from which frame should animation start
  79808. * @param to defines until which frame should animation run.
  79809. * @param weight defines the weight to apply to the animation (1.0 by default)
  79810. * @param loop defines if the animation loops
  79811. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79812. * @param onAnimationEnd defines the function to be executed when the animation ends
  79813. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79814. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79815. * @param onAnimationLoop defines the callback to call when an animation loops
  79816. * @returns the animatable object created for this animation
  79817. */
  79818. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79819. /**
  79820. * Will start the animation sequence of a given target
  79821. * @param target defines the target
  79822. * @param from defines from which frame should animation start
  79823. * @param to defines until which frame should animation run.
  79824. * @param loop defines if the animation loops
  79825. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79826. * @param onAnimationEnd defines the function to be executed when the animation ends
  79827. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79828. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79829. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79830. * @param onAnimationLoop defines the callback to call when an animation loops
  79831. * @returns the animatable object created for this animation
  79832. */
  79833. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79834. /**
  79835. * Will start the animation sequence of a given target and its hierarchy
  79836. * @param target defines the target
  79837. * @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.
  79838. * @param from defines from which frame should animation start
  79839. * @param to defines until which frame should animation run.
  79840. * @param loop defines if the animation loops
  79841. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79842. * @param onAnimationEnd defines the function to be executed when the animation ends
  79843. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79844. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79845. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79846. * @param onAnimationLoop defines the callback to call when an animation loops
  79847. * @returns the list of created animatables
  79848. */
  79849. 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[];
  79850. /**
  79851. * Begin a new animation on a given node
  79852. * @param target defines the target where the animation will take place
  79853. * @param animations defines the list of animations to start
  79854. * @param from defines the initial value
  79855. * @param to defines the final value
  79856. * @param loop defines if you want animation to loop (off by default)
  79857. * @param speedRatio defines the speed ratio to apply to all animations
  79858. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79859. * @param onAnimationLoop defines the callback to call when an animation loops
  79860. * @returns the list of created animatables
  79861. */
  79862. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79863. /**
  79864. * Begin a new animation on a given node and its hierarchy
  79865. * @param target defines the root node where the animation will take place
  79866. * @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.
  79867. * @param animations defines the list of animations to start
  79868. * @param from defines the initial value
  79869. * @param to defines the final value
  79870. * @param loop defines if you want animation to loop (off by default)
  79871. * @param speedRatio defines the speed ratio to apply to all animations
  79872. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79873. * @param onAnimationLoop defines the callback to call when an animation loops
  79874. * @returns the list of animatables created for all nodes
  79875. */
  79876. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79877. /**
  79878. * Gets the animatable associated with a specific target
  79879. * @param target defines the target of the animatable
  79880. * @returns the required animatable if found
  79881. */
  79882. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79883. /**
  79884. * Gets all animatables associated with a given target
  79885. * @param target defines the target to look animatables for
  79886. * @returns an array of Animatables
  79887. */
  79888. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79889. /**
  79890. * Stops and removes all animations that have been applied to the scene
  79891. */
  79892. stopAllAnimations(): void;
  79893. /**
  79894. * Gets the current delta time used by animation engine
  79895. */
  79896. deltaTime: number;
  79897. }
  79898. interface Bone {
  79899. /**
  79900. * Copy an animation range from another bone
  79901. * @param source defines the source bone
  79902. * @param rangeName defines the range name to copy
  79903. * @param frameOffset defines the frame offset
  79904. * @param rescaleAsRequired defines if rescaling must be applied if required
  79905. * @param skelDimensionsRatio defines the scaling ratio
  79906. * @returns true if operation was successful
  79907. */
  79908. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79909. }
  79910. }
  79911. declare module BABYLON {
  79912. /**
  79913. * Class used to override all child animations of a given target
  79914. */
  79915. export class AnimationPropertiesOverride {
  79916. /**
  79917. * Gets or sets a value indicating if animation blending must be used
  79918. */
  79919. enableBlending: boolean;
  79920. /**
  79921. * Gets or sets the blending speed to use when enableBlending is true
  79922. */
  79923. blendingSpeed: number;
  79924. /**
  79925. * Gets or sets the default loop mode to use
  79926. */
  79927. loopMode: number;
  79928. }
  79929. }
  79930. declare module BABYLON {
  79931. /**
  79932. * Class used to handle skinning animations
  79933. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79934. */
  79935. export class Skeleton implements IAnimatable {
  79936. /** defines the skeleton name */
  79937. name: string;
  79938. /** defines the skeleton Id */
  79939. id: string;
  79940. /**
  79941. * Defines the list of child bones
  79942. */
  79943. bones: Bone[];
  79944. /**
  79945. * Defines an estimate of the dimension of the skeleton at rest
  79946. */
  79947. dimensionsAtRest: Vector3;
  79948. /**
  79949. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79950. */
  79951. needInitialSkinMatrix: boolean;
  79952. /**
  79953. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79954. */
  79955. overrideMesh: Nullable<AbstractMesh>;
  79956. /**
  79957. * Gets the list of animations attached to this skeleton
  79958. */
  79959. animations: Array<Animation>;
  79960. private _scene;
  79961. private _isDirty;
  79962. private _transformMatrices;
  79963. private _transformMatrixTexture;
  79964. private _meshesWithPoseMatrix;
  79965. private _animatables;
  79966. private _identity;
  79967. private _synchronizedWithMesh;
  79968. private _ranges;
  79969. private _lastAbsoluteTransformsUpdateId;
  79970. private _canUseTextureForBones;
  79971. private _uniqueId;
  79972. /** @hidden */
  79973. _numBonesWithLinkedTransformNode: number;
  79974. /** @hidden */
  79975. _hasWaitingData: Nullable<boolean>;
  79976. /**
  79977. * Specifies if the skeleton should be serialized
  79978. */
  79979. doNotSerialize: boolean;
  79980. private _useTextureToStoreBoneMatrices;
  79981. /**
  79982. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79983. * Please note that this option is not available if the hardware does not support it
  79984. */
  79985. useTextureToStoreBoneMatrices: boolean;
  79986. private _animationPropertiesOverride;
  79987. /**
  79988. * Gets or sets the animation properties override
  79989. */
  79990. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79991. /**
  79992. * List of inspectable custom properties (used by the Inspector)
  79993. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79994. */
  79995. inspectableCustomProperties: IInspectable[];
  79996. /**
  79997. * An observable triggered before computing the skeleton's matrices
  79998. */
  79999. onBeforeComputeObservable: Observable<Skeleton>;
  80000. /**
  80001. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  80002. */
  80003. readonly isUsingTextureForMatrices: boolean;
  80004. /**
  80005. * Gets the unique ID of this skeleton
  80006. */
  80007. readonly uniqueId: number;
  80008. /**
  80009. * Creates a new skeleton
  80010. * @param name defines the skeleton name
  80011. * @param id defines the skeleton Id
  80012. * @param scene defines the hosting scene
  80013. */
  80014. constructor(
  80015. /** defines the skeleton name */
  80016. name: string,
  80017. /** defines the skeleton Id */
  80018. id: string, scene: Scene);
  80019. /**
  80020. * Gets the current object class name.
  80021. * @return the class name
  80022. */
  80023. getClassName(): string;
  80024. /**
  80025. * Returns an array containing the root bones
  80026. * @returns an array containing the root bones
  80027. */
  80028. getChildren(): Array<Bone>;
  80029. /**
  80030. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80031. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80032. * @returns a Float32Array containing matrices data
  80033. */
  80034. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80035. /**
  80036. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80037. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80038. * @returns a raw texture containing the data
  80039. */
  80040. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80041. /**
  80042. * Gets the current hosting scene
  80043. * @returns a scene object
  80044. */
  80045. getScene(): Scene;
  80046. /**
  80047. * Gets a string representing the current skeleton data
  80048. * @param fullDetails defines a boolean indicating if we want a verbose version
  80049. * @returns a string representing the current skeleton data
  80050. */
  80051. toString(fullDetails?: boolean): string;
  80052. /**
  80053. * Get bone's index searching by name
  80054. * @param name defines bone's name to search for
  80055. * @return the indice of the bone. Returns -1 if not found
  80056. */
  80057. getBoneIndexByName(name: string): number;
  80058. /**
  80059. * Creater a new animation range
  80060. * @param name defines the name of the range
  80061. * @param from defines the start key
  80062. * @param to defines the end key
  80063. */
  80064. createAnimationRange(name: string, from: number, to: number): void;
  80065. /**
  80066. * Delete a specific animation range
  80067. * @param name defines the name of the range
  80068. * @param deleteFrames defines if frames must be removed as well
  80069. */
  80070. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80071. /**
  80072. * Gets a specific animation range
  80073. * @param name defines the name of the range to look for
  80074. * @returns the requested animation range or null if not found
  80075. */
  80076. getAnimationRange(name: string): Nullable<AnimationRange>;
  80077. /**
  80078. * Gets the list of all animation ranges defined on this skeleton
  80079. * @returns an array
  80080. */
  80081. getAnimationRanges(): Nullable<AnimationRange>[];
  80082. /**
  80083. * Copy animation range from a source skeleton.
  80084. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80085. * @param source defines the source skeleton
  80086. * @param name defines the name of the range to copy
  80087. * @param rescaleAsRequired defines if rescaling must be applied if required
  80088. * @returns true if operation was successful
  80089. */
  80090. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80091. /**
  80092. * Forces the skeleton to go to rest pose
  80093. */
  80094. returnToRest(): void;
  80095. private _getHighestAnimationFrame;
  80096. /**
  80097. * Begin a specific animation range
  80098. * @param name defines the name of the range to start
  80099. * @param loop defines if looping must be turned on (false by default)
  80100. * @param speedRatio defines the speed ratio to apply (1 by default)
  80101. * @param onAnimationEnd defines a callback which will be called when animation will end
  80102. * @returns a new animatable
  80103. */
  80104. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80105. /** @hidden */
  80106. _markAsDirty(): void;
  80107. /** @hidden */
  80108. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80109. /** @hidden */
  80110. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80111. private _computeTransformMatrices;
  80112. /**
  80113. * Build all resources required to render a skeleton
  80114. */
  80115. prepare(): void;
  80116. /**
  80117. * Gets the list of animatables currently running for this skeleton
  80118. * @returns an array of animatables
  80119. */
  80120. getAnimatables(): IAnimatable[];
  80121. /**
  80122. * Clone the current skeleton
  80123. * @param name defines the name of the new skeleton
  80124. * @param id defines the id of the new skeleton
  80125. * @returns the new skeleton
  80126. */
  80127. clone(name: string, id: string): Skeleton;
  80128. /**
  80129. * Enable animation blending for this skeleton
  80130. * @param blendingSpeed defines the blending speed to apply
  80131. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80132. */
  80133. enableBlending(blendingSpeed?: number): void;
  80134. /**
  80135. * Releases all resources associated with the current skeleton
  80136. */
  80137. dispose(): void;
  80138. /**
  80139. * Serialize the skeleton in a JSON object
  80140. * @returns a JSON object
  80141. */
  80142. serialize(): any;
  80143. /**
  80144. * Creates a new skeleton from serialized data
  80145. * @param parsedSkeleton defines the serialized data
  80146. * @param scene defines the hosting scene
  80147. * @returns a new skeleton
  80148. */
  80149. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80150. /**
  80151. * Compute all node absolute transforms
  80152. * @param forceUpdate defines if computation must be done even if cache is up to date
  80153. */
  80154. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80155. /**
  80156. * Gets the root pose matrix
  80157. * @returns a matrix
  80158. */
  80159. getPoseMatrix(): Nullable<Matrix>;
  80160. /**
  80161. * Sorts bones per internal index
  80162. */
  80163. sortBones(): void;
  80164. private _sortBones;
  80165. }
  80166. }
  80167. declare module BABYLON {
  80168. /**
  80169. * Class used to store bone information
  80170. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80171. */
  80172. export class Bone extends Node {
  80173. /**
  80174. * defines the bone name
  80175. */
  80176. name: string;
  80177. private static _tmpVecs;
  80178. private static _tmpQuat;
  80179. private static _tmpMats;
  80180. /**
  80181. * Gets the list of child bones
  80182. */
  80183. children: Bone[];
  80184. /** Gets the animations associated with this bone */
  80185. animations: Animation[];
  80186. /**
  80187. * Gets or sets bone length
  80188. */
  80189. length: number;
  80190. /**
  80191. * @hidden Internal only
  80192. * Set this value to map this bone to a different index in the transform matrices
  80193. * Set this value to -1 to exclude the bone from the transform matrices
  80194. */
  80195. _index: Nullable<number>;
  80196. private _skeleton;
  80197. private _localMatrix;
  80198. private _restPose;
  80199. private _baseMatrix;
  80200. private _absoluteTransform;
  80201. private _invertedAbsoluteTransform;
  80202. private _parent;
  80203. private _scalingDeterminant;
  80204. private _worldTransform;
  80205. private _localScaling;
  80206. private _localRotation;
  80207. private _localPosition;
  80208. private _needToDecompose;
  80209. private _needToCompose;
  80210. /** @hidden */
  80211. _linkedTransformNode: Nullable<TransformNode>;
  80212. /** @hidden */
  80213. _waitingTransformNodeId: Nullable<string>;
  80214. /** @hidden */
  80215. /** @hidden */
  80216. _matrix: Matrix;
  80217. /**
  80218. * Create a new bone
  80219. * @param name defines the bone name
  80220. * @param skeleton defines the parent skeleton
  80221. * @param parentBone defines the parent (can be null if the bone is the root)
  80222. * @param localMatrix defines the local matrix
  80223. * @param restPose defines the rest pose matrix
  80224. * @param baseMatrix defines the base matrix
  80225. * @param index defines index of the bone in the hiearchy
  80226. */
  80227. constructor(
  80228. /**
  80229. * defines the bone name
  80230. */
  80231. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80232. /**
  80233. * Gets the current object class name.
  80234. * @return the class name
  80235. */
  80236. getClassName(): string;
  80237. /**
  80238. * Gets the parent skeleton
  80239. * @returns a skeleton
  80240. */
  80241. getSkeleton(): Skeleton;
  80242. /**
  80243. * Gets parent bone
  80244. * @returns a bone or null if the bone is the root of the bone hierarchy
  80245. */
  80246. getParent(): Nullable<Bone>;
  80247. /**
  80248. * Returns an array containing the root bones
  80249. * @returns an array containing the root bones
  80250. */
  80251. getChildren(): Array<Bone>;
  80252. /**
  80253. * Sets the parent bone
  80254. * @param parent defines the parent (can be null if the bone is the root)
  80255. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80256. */
  80257. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80258. /**
  80259. * Gets the local matrix
  80260. * @returns a matrix
  80261. */
  80262. getLocalMatrix(): Matrix;
  80263. /**
  80264. * Gets the base matrix (initial matrix which remains unchanged)
  80265. * @returns a matrix
  80266. */
  80267. getBaseMatrix(): Matrix;
  80268. /**
  80269. * Gets the rest pose matrix
  80270. * @returns a matrix
  80271. */
  80272. getRestPose(): Matrix;
  80273. /**
  80274. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80275. */
  80276. getWorldMatrix(): Matrix;
  80277. /**
  80278. * Sets the local matrix to rest pose matrix
  80279. */
  80280. returnToRest(): void;
  80281. /**
  80282. * Gets the inverse of the absolute transform matrix.
  80283. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80284. * @returns a matrix
  80285. */
  80286. getInvertedAbsoluteTransform(): Matrix;
  80287. /**
  80288. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80289. * @returns a matrix
  80290. */
  80291. getAbsoluteTransform(): Matrix;
  80292. /**
  80293. * Links with the given transform node.
  80294. * The local matrix of this bone is copied from the transform node every frame.
  80295. * @param transformNode defines the transform node to link to
  80296. */
  80297. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80298. /**
  80299. * Gets the node used to drive the bone's transformation
  80300. * @returns a transform node or null
  80301. */
  80302. getTransformNode(): Nullable<TransformNode>;
  80303. /** Gets or sets current position (in local space) */
  80304. position: Vector3;
  80305. /** Gets or sets current rotation (in local space) */
  80306. rotation: Vector3;
  80307. /** Gets or sets current rotation quaternion (in local space) */
  80308. rotationQuaternion: Quaternion;
  80309. /** Gets or sets current scaling (in local space) */
  80310. scaling: Vector3;
  80311. /**
  80312. * Gets the animation properties override
  80313. */
  80314. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80315. private _decompose;
  80316. private _compose;
  80317. /**
  80318. * Update the base and local matrices
  80319. * @param matrix defines the new base or local matrix
  80320. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80321. * @param updateLocalMatrix defines if the local matrix should be updated
  80322. */
  80323. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80324. /** @hidden */
  80325. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80326. /**
  80327. * Flag the bone as dirty (Forcing it to update everything)
  80328. */
  80329. markAsDirty(): void;
  80330. /** @hidden */
  80331. _markAsDirtyAndCompose(): void;
  80332. private _markAsDirtyAndDecompose;
  80333. /**
  80334. * Translate the bone in local or world space
  80335. * @param vec The amount to translate the bone
  80336. * @param space The space that the translation is in
  80337. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80338. */
  80339. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80340. /**
  80341. * Set the postion of the bone in local or world space
  80342. * @param position The position to set the bone
  80343. * @param space The space that the position is in
  80344. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80345. */
  80346. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80347. /**
  80348. * Set the absolute position of the bone (world space)
  80349. * @param position The position to set the bone
  80350. * @param mesh The mesh that this bone is attached to
  80351. */
  80352. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80353. /**
  80354. * Scale the bone on the x, y and z axes (in local space)
  80355. * @param x The amount to scale the bone on the x axis
  80356. * @param y The amount to scale the bone on the y axis
  80357. * @param z The amount to scale the bone on the z axis
  80358. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80359. */
  80360. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80361. /**
  80362. * Set the bone scaling in local space
  80363. * @param scale defines the scaling vector
  80364. */
  80365. setScale(scale: Vector3): void;
  80366. /**
  80367. * Gets the current scaling in local space
  80368. * @returns the current scaling vector
  80369. */
  80370. getScale(): Vector3;
  80371. /**
  80372. * Gets the current scaling in local space and stores it in a target vector
  80373. * @param result defines the target vector
  80374. */
  80375. getScaleToRef(result: Vector3): void;
  80376. /**
  80377. * Set the yaw, pitch, and roll of the bone in local or world space
  80378. * @param yaw The rotation of the bone on the y axis
  80379. * @param pitch The rotation of the bone on the x axis
  80380. * @param roll The rotation of the bone on the z axis
  80381. * @param space The space that the axes of rotation are in
  80382. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80383. */
  80384. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80385. /**
  80386. * Add a rotation to the bone on an axis in local or world space
  80387. * @param axis The axis to rotate the bone on
  80388. * @param amount The amount to rotate the bone
  80389. * @param space The space that the axis is in
  80390. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80391. */
  80392. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80393. /**
  80394. * Set the rotation of the bone to a particular axis angle in local or world space
  80395. * @param axis The axis to rotate the bone on
  80396. * @param angle The angle that the bone should be rotated to
  80397. * @param space The space that the axis is in
  80398. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80399. */
  80400. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80401. /**
  80402. * Set the euler rotation of the bone in local of world space
  80403. * @param rotation The euler rotation that the bone should be set to
  80404. * @param space The space that the rotation is in
  80405. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80406. */
  80407. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80408. /**
  80409. * Set the quaternion rotation of the bone in local of world space
  80410. * @param quat The quaternion rotation that the bone should be set to
  80411. * @param space The space that the rotation is in
  80412. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80413. */
  80414. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80415. /**
  80416. * Set the rotation matrix of the bone in local of world space
  80417. * @param rotMat The rotation matrix that the bone should be set to
  80418. * @param space The space that the rotation is in
  80419. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80420. */
  80421. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80422. private _rotateWithMatrix;
  80423. private _getNegativeRotationToRef;
  80424. /**
  80425. * Get the position of the bone in local or world space
  80426. * @param space The space that the returned position is in
  80427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80428. * @returns The position of the bone
  80429. */
  80430. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80431. /**
  80432. * Copy the position of the bone to a vector3 in local or world space
  80433. * @param space The space that the returned position is in
  80434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80435. * @param result The vector3 to copy the position to
  80436. */
  80437. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80438. /**
  80439. * Get the absolute position of the bone (world space)
  80440. * @param mesh The mesh that this bone is attached to
  80441. * @returns The absolute position of the bone
  80442. */
  80443. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80444. /**
  80445. * Copy the absolute position of the bone (world space) to the result param
  80446. * @param mesh The mesh that this bone is attached to
  80447. * @param result The vector3 to copy the absolute position to
  80448. */
  80449. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80450. /**
  80451. * Compute the absolute transforms of this bone and its children
  80452. */
  80453. computeAbsoluteTransforms(): void;
  80454. /**
  80455. * Get the world direction from an axis that is in the local space of the bone
  80456. * @param localAxis The local direction that is used to compute the world direction
  80457. * @param mesh The mesh that this bone is attached to
  80458. * @returns The world direction
  80459. */
  80460. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80461. /**
  80462. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80463. * @param localAxis The local direction that is used to compute the world direction
  80464. * @param mesh The mesh that this bone is attached to
  80465. * @param result The vector3 that the world direction will be copied to
  80466. */
  80467. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80468. /**
  80469. * Get the euler rotation of the bone in local or world space
  80470. * @param space The space that the rotation should be in
  80471. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80472. * @returns The euler rotation
  80473. */
  80474. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80475. /**
  80476. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80477. * @param space The space that the rotation should be in
  80478. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80479. * @param result The vector3 that the rotation should be copied to
  80480. */
  80481. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80482. /**
  80483. * Get the quaternion rotation of the bone in either local or world space
  80484. * @param space The space that the rotation should be in
  80485. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80486. * @returns The quaternion rotation
  80487. */
  80488. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80489. /**
  80490. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80491. * @param space The space that the rotation should be in
  80492. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80493. * @param result The quaternion that the rotation should be copied to
  80494. */
  80495. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80496. /**
  80497. * Get the rotation matrix of the bone in local or world space
  80498. * @param space The space that the rotation should be in
  80499. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80500. * @returns The rotation matrix
  80501. */
  80502. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80503. /**
  80504. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80505. * @param space The space that the rotation should be in
  80506. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80507. * @param result The quaternion that the rotation should be copied to
  80508. */
  80509. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80510. /**
  80511. * Get the world position of a point that is in the local space of the bone
  80512. * @param position The local position
  80513. * @param mesh The mesh that this bone is attached to
  80514. * @returns The world position
  80515. */
  80516. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80517. /**
  80518. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80519. * @param position The local position
  80520. * @param mesh The mesh that this bone is attached to
  80521. * @param result The vector3 that the world position should be copied to
  80522. */
  80523. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80524. /**
  80525. * Get the local position of a point that is in world space
  80526. * @param position The world position
  80527. * @param mesh The mesh that this bone is attached to
  80528. * @returns The local position
  80529. */
  80530. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80531. /**
  80532. * Get the local position of a point that is in world space and copy it to the result param
  80533. * @param position The world position
  80534. * @param mesh The mesh that this bone is attached to
  80535. * @param result The vector3 that the local position should be copied to
  80536. */
  80537. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80538. }
  80539. }
  80540. declare module BABYLON {
  80541. /**
  80542. * 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.
  80543. * @see https://doc.babylonjs.com/how_to/transformnode
  80544. */
  80545. export class TransformNode extends Node {
  80546. /**
  80547. * Object will not rotate to face the camera
  80548. */
  80549. static BILLBOARDMODE_NONE: number;
  80550. /**
  80551. * Object will rotate to face the camera but only on the x axis
  80552. */
  80553. static BILLBOARDMODE_X: number;
  80554. /**
  80555. * Object will rotate to face the camera but only on the y axis
  80556. */
  80557. static BILLBOARDMODE_Y: number;
  80558. /**
  80559. * Object will rotate to face the camera but only on the z axis
  80560. */
  80561. static BILLBOARDMODE_Z: number;
  80562. /**
  80563. * Object will rotate to face the camera
  80564. */
  80565. static BILLBOARDMODE_ALL: number;
  80566. /**
  80567. * Object will rotate to face the camera's position instead of orientation
  80568. */
  80569. static BILLBOARDMODE_USE_POSITION: number;
  80570. private _forward;
  80571. private _forwardInverted;
  80572. private _up;
  80573. private _right;
  80574. private _rightInverted;
  80575. private _position;
  80576. private _rotation;
  80577. private _rotationQuaternion;
  80578. protected _scaling: Vector3;
  80579. protected _isDirty: boolean;
  80580. private _transformToBoneReferal;
  80581. private _isAbsoluteSynced;
  80582. private _billboardMode;
  80583. /**
  80584. * Gets or sets the billboard mode. Default is 0.
  80585. *
  80586. * | Value | Type | Description |
  80587. * | --- | --- | --- |
  80588. * | 0 | BILLBOARDMODE_NONE | |
  80589. * | 1 | BILLBOARDMODE_X | |
  80590. * | 2 | BILLBOARDMODE_Y | |
  80591. * | 4 | BILLBOARDMODE_Z | |
  80592. * | 7 | BILLBOARDMODE_ALL | |
  80593. *
  80594. */
  80595. billboardMode: number;
  80596. private _preserveParentRotationForBillboard;
  80597. /**
  80598. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  80599. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  80600. */
  80601. preserveParentRotationForBillboard: boolean;
  80602. /**
  80603. * 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
  80604. */
  80605. scalingDeterminant: number;
  80606. private _infiniteDistance;
  80607. /**
  80608. * Gets or sets the distance of the object to max, often used by skybox
  80609. */
  80610. infiniteDistance: boolean;
  80611. /**
  80612. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  80613. * By default the system will update normals to compensate
  80614. */
  80615. ignoreNonUniformScaling: boolean;
  80616. /**
  80617. * 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
  80618. */
  80619. reIntegrateRotationIntoRotationQuaternion: boolean;
  80620. /** @hidden */
  80621. _poseMatrix: Nullable<Matrix>;
  80622. /** @hidden */
  80623. _localMatrix: Matrix;
  80624. private _usePivotMatrix;
  80625. private _absolutePosition;
  80626. private _absoluteScaling;
  80627. private _absoluteRotationQuaternion;
  80628. private _pivotMatrix;
  80629. private _pivotMatrixInverse;
  80630. protected _postMultiplyPivotMatrix: boolean;
  80631. protected _isWorldMatrixFrozen: boolean;
  80632. /** @hidden */
  80633. _indexInSceneTransformNodesArray: number;
  80634. /**
  80635. * An event triggered after the world matrix is updated
  80636. */
  80637. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  80638. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  80639. /**
  80640. * Gets a string identifying the name of the class
  80641. * @returns "TransformNode" string
  80642. */
  80643. getClassName(): string;
  80644. /**
  80645. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  80646. */
  80647. position: Vector3;
  80648. /**
  80649. * 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)).
  80650. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  80651. */
  80652. rotation: Vector3;
  80653. /**
  80654. * 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)).
  80655. */
  80656. scaling: Vector3;
  80657. /**
  80658. * 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).
  80659. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  80660. */
  80661. rotationQuaternion: Nullable<Quaternion>;
  80662. /**
  80663. * The forward direction of that transform in world space.
  80664. */
  80665. readonly forward: Vector3;
  80666. /**
  80667. * The up direction of that transform in world space.
  80668. */
  80669. readonly up: Vector3;
  80670. /**
  80671. * The right direction of that transform in world space.
  80672. */
  80673. readonly right: Vector3;
  80674. /**
  80675. * Copies the parameter passed Matrix into the mesh Pose matrix.
  80676. * @param matrix the matrix to copy the pose from
  80677. * @returns this TransformNode.
  80678. */
  80679. updatePoseMatrix(matrix: Matrix): TransformNode;
  80680. /**
  80681. * Returns the mesh Pose matrix.
  80682. * @returns the pose matrix
  80683. */
  80684. getPoseMatrix(): Matrix;
  80685. /** @hidden */
  80686. _isSynchronized(): boolean;
  80687. /** @hidden */
  80688. _initCache(): void;
  80689. /**
  80690. * Flag the transform node as dirty (Forcing it to update everything)
  80691. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  80692. * @returns this transform node
  80693. */
  80694. markAsDirty(property: string): TransformNode;
  80695. /**
  80696. * Returns the current mesh absolute position.
  80697. * Returns a Vector3.
  80698. */
  80699. readonly absolutePosition: Vector3;
  80700. /**
  80701. * Returns the current mesh absolute scaling.
  80702. * Returns a Vector3.
  80703. */
  80704. readonly absoluteScaling: Vector3;
  80705. /**
  80706. * Returns the current mesh absolute rotation.
  80707. * Returns a Quaternion.
  80708. */
  80709. readonly absoluteRotationQuaternion: Quaternion;
  80710. /**
  80711. * Sets a new matrix to apply before all other transformation
  80712. * @param matrix defines the transform matrix
  80713. * @returns the current TransformNode
  80714. */
  80715. setPreTransformMatrix(matrix: Matrix): TransformNode;
  80716. /**
  80717. * Sets a new pivot matrix to the current node
  80718. * @param matrix defines the new pivot matrix to use
  80719. * @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
  80720. * @returns the current TransformNode
  80721. */
  80722. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  80723. /**
  80724. * Returns the mesh pivot matrix.
  80725. * Default : Identity.
  80726. * @returns the matrix
  80727. */
  80728. getPivotMatrix(): Matrix;
  80729. /**
  80730. * Instantiate (when possible) or clone that node with its hierarchy
  80731. * @param newParent defines the new parent to use for the instance (or clone)
  80732. * @returns an instance (or a clone) of the current node with its hiearchy
  80733. */
  80734. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  80735. /**
  80736. * Prevents the World matrix to be computed any longer
  80737. * @param newWorldMatrix defines an optional matrix to use as world matrix
  80738. * @returns the TransformNode.
  80739. */
  80740. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  80741. /**
  80742. * Allows back the World matrix computation.
  80743. * @returns the TransformNode.
  80744. */
  80745. unfreezeWorldMatrix(): this;
  80746. /**
  80747. * True if the World matrix has been frozen.
  80748. */
  80749. readonly isWorldMatrixFrozen: boolean;
  80750. /**
  80751. * Retuns the mesh absolute position in the World.
  80752. * @returns a Vector3.
  80753. */
  80754. getAbsolutePosition(): Vector3;
  80755. /**
  80756. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  80757. * @param absolutePosition the absolute position to set
  80758. * @returns the TransformNode.
  80759. */
  80760. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80761. /**
  80762. * Sets the mesh position in its local space.
  80763. * @param vector3 the position to set in localspace
  80764. * @returns the TransformNode.
  80765. */
  80766. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  80767. /**
  80768. * Returns the mesh position in the local space from the current World matrix values.
  80769. * @returns a new Vector3.
  80770. */
  80771. getPositionExpressedInLocalSpace(): Vector3;
  80772. /**
  80773. * Translates the mesh along the passed Vector3 in its local space.
  80774. * @param vector3 the distance to translate in localspace
  80775. * @returns the TransformNode.
  80776. */
  80777. locallyTranslate(vector3: Vector3): TransformNode;
  80778. private static _lookAtVectorCache;
  80779. /**
  80780. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  80781. * @param targetPoint the position (must be in same space as current mesh) to look at
  80782. * @param yawCor optional yaw (y-axis) correction in radians
  80783. * @param pitchCor optional pitch (x-axis) correction in radians
  80784. * @param rollCor optional roll (z-axis) correction in radians
  80785. * @param space the choosen space of the target
  80786. * @returns the TransformNode.
  80787. */
  80788. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  80789. /**
  80790. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80791. * This Vector3 is expressed in the World space.
  80792. * @param localAxis axis to rotate
  80793. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80794. */
  80795. getDirection(localAxis: Vector3): Vector3;
  80796. /**
  80797. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  80798. * localAxis is expressed in the mesh local space.
  80799. * result is computed in the Wordl space from the mesh World matrix.
  80800. * @param localAxis axis to rotate
  80801. * @param result the resulting transformnode
  80802. * @returns this TransformNode.
  80803. */
  80804. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  80805. /**
  80806. * Sets this transform node rotation to the given local axis.
  80807. * @param localAxis the axis in local space
  80808. * @param yawCor optional yaw (y-axis) correction in radians
  80809. * @param pitchCor optional pitch (x-axis) correction in radians
  80810. * @param rollCor optional roll (z-axis) correction in radians
  80811. * @returns this TransformNode
  80812. */
  80813. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  80814. /**
  80815. * Sets a new pivot point to the current node
  80816. * @param point defines the new pivot point to use
  80817. * @param space defines if the point is in world or local space (local by default)
  80818. * @returns the current TransformNode
  80819. */
  80820. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  80821. /**
  80822. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  80823. * @returns the pivot point
  80824. */
  80825. getPivotPoint(): Vector3;
  80826. /**
  80827. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  80828. * @param result the vector3 to store the result
  80829. * @returns this TransformNode.
  80830. */
  80831. getPivotPointToRef(result: Vector3): TransformNode;
  80832. /**
  80833. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  80834. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  80835. */
  80836. getAbsolutePivotPoint(): Vector3;
  80837. /**
  80838. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  80839. * @param result vector3 to store the result
  80840. * @returns this TransformNode.
  80841. */
  80842. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  80843. /**
  80844. * Defines the passed node as the parent of the current node.
  80845. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  80846. * @see https://doc.babylonjs.com/how_to/parenting
  80847. * @param node the node ot set as the parent
  80848. * @returns this TransformNode.
  80849. */
  80850. setParent(node: Nullable<Node>): TransformNode;
  80851. private _nonUniformScaling;
  80852. /**
  80853. * True if the scaling property of this object is non uniform eg. (1,2,1)
  80854. */
  80855. readonly nonUniformScaling: boolean;
  80856. /** @hidden */
  80857. _updateNonUniformScalingState(value: boolean): boolean;
  80858. /**
  80859. * Attach the current TransformNode to another TransformNode associated with a bone
  80860. * @param bone Bone affecting the TransformNode
  80861. * @param affectedTransformNode TransformNode associated with the bone
  80862. * @returns this object
  80863. */
  80864. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  80865. /**
  80866. * Detach the transform node if its associated with a bone
  80867. * @returns this object
  80868. */
  80869. detachFromBone(): TransformNode;
  80870. private static _rotationAxisCache;
  80871. /**
  80872. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  80873. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80874. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80875. * The passed axis is also normalized.
  80876. * @param axis the axis to rotate around
  80877. * @param amount the amount to rotate in radians
  80878. * @param space Space to rotate in (Default: local)
  80879. * @returns the TransformNode.
  80880. */
  80881. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80882. /**
  80883. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  80884. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80885. * The passed axis is also normalized. .
  80886. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  80887. * @param point the point to rotate around
  80888. * @param axis the axis to rotate around
  80889. * @param amount the amount to rotate in radians
  80890. * @returns the TransformNode
  80891. */
  80892. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  80893. /**
  80894. * Translates the mesh along the axis vector for the passed distance in the given space.
  80895. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80896. * @param axis the axis to translate in
  80897. * @param distance the distance to translate
  80898. * @param space Space to rotate in (Default: local)
  80899. * @returns the TransformNode.
  80900. */
  80901. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80902. /**
  80903. * Adds a rotation step to the mesh current rotation.
  80904. * x, y, z are Euler angles expressed in radians.
  80905. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  80906. * This means this rotation is made in the mesh local space only.
  80907. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  80908. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  80909. * ```javascript
  80910. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  80911. * ```
  80912. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  80913. * 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.
  80914. * @param x Rotation to add
  80915. * @param y Rotation to add
  80916. * @param z Rotation to add
  80917. * @returns the TransformNode.
  80918. */
  80919. addRotation(x: number, y: number, z: number): TransformNode;
  80920. /**
  80921. * @hidden
  80922. */
  80923. protected _getEffectiveParent(): Nullable<Node>;
  80924. /**
  80925. * Computes the world matrix of the node
  80926. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80927. * @returns the world matrix
  80928. */
  80929. computeWorldMatrix(force?: boolean): Matrix;
  80930. protected _afterComputeWorldMatrix(): void;
  80931. /**
  80932. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  80933. * @param func callback function to add
  80934. *
  80935. * @returns the TransformNode.
  80936. */
  80937. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80938. /**
  80939. * Removes a registered callback function.
  80940. * @param func callback function to remove
  80941. * @returns the TransformNode.
  80942. */
  80943. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80944. /**
  80945. * Gets the position of the current mesh in camera space
  80946. * @param camera defines the camera to use
  80947. * @returns a position
  80948. */
  80949. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  80950. /**
  80951. * Returns the distance from the mesh to the active camera
  80952. * @param camera defines the camera to use
  80953. * @returns the distance
  80954. */
  80955. getDistanceToCamera(camera?: Nullable<Camera>): number;
  80956. /**
  80957. * Clone the current transform node
  80958. * @param name Name of the new clone
  80959. * @param newParent New parent for the clone
  80960. * @param doNotCloneChildren Do not clone children hierarchy
  80961. * @returns the new transform node
  80962. */
  80963. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  80964. /**
  80965. * Serializes the objects information.
  80966. * @param currentSerializationObject defines the object to serialize in
  80967. * @returns the serialized object
  80968. */
  80969. serialize(currentSerializationObject?: any): any;
  80970. /**
  80971. * Returns a new TransformNode object parsed from the source provided.
  80972. * @param parsedTransformNode is the source.
  80973. * @param scene the scne the object belongs to
  80974. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  80975. * @returns a new TransformNode object parsed from the source provided.
  80976. */
  80977. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  80978. /**
  80979. * Get all child-transformNodes of this node
  80980. * @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
  80981. * @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
  80982. * @returns an array of TransformNode
  80983. */
  80984. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  80985. /**
  80986. * Releases resources associated with this transform node.
  80987. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80988. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80989. */
  80990. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80991. /**
  80992. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80993. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  80994. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  80995. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  80996. * @returns the current mesh
  80997. */
  80998. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  80999. private _syncAbsoluteScalingAndRotation;
  81000. }
  81001. }
  81002. declare module BABYLON {
  81003. /**
  81004. * Defines the types of pose enabled controllers that are supported
  81005. */
  81006. export enum PoseEnabledControllerType {
  81007. /**
  81008. * HTC Vive
  81009. */
  81010. VIVE = 0,
  81011. /**
  81012. * Oculus Rift
  81013. */
  81014. OCULUS = 1,
  81015. /**
  81016. * Windows mixed reality
  81017. */
  81018. WINDOWS = 2,
  81019. /**
  81020. * Samsung gear VR
  81021. */
  81022. GEAR_VR = 3,
  81023. /**
  81024. * Google Daydream
  81025. */
  81026. DAYDREAM = 4,
  81027. /**
  81028. * Generic
  81029. */
  81030. GENERIC = 5
  81031. }
  81032. /**
  81033. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81034. */
  81035. export interface MutableGamepadButton {
  81036. /**
  81037. * Value of the button/trigger
  81038. */
  81039. value: number;
  81040. /**
  81041. * If the button/trigger is currently touched
  81042. */
  81043. touched: boolean;
  81044. /**
  81045. * If the button/trigger is currently pressed
  81046. */
  81047. pressed: boolean;
  81048. }
  81049. /**
  81050. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81051. * @hidden
  81052. */
  81053. export interface ExtendedGamepadButton extends GamepadButton {
  81054. /**
  81055. * If the button/trigger is currently pressed
  81056. */
  81057. readonly pressed: boolean;
  81058. /**
  81059. * If the button/trigger is currently touched
  81060. */
  81061. readonly touched: boolean;
  81062. /**
  81063. * Value of the button/trigger
  81064. */
  81065. readonly value: number;
  81066. }
  81067. /** @hidden */
  81068. export interface _GamePadFactory {
  81069. /**
  81070. * Returns wether or not the current gamepad can be created for this type of controller.
  81071. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81072. * @returns true if it can be created, otherwise false
  81073. */
  81074. canCreate(gamepadInfo: any): boolean;
  81075. /**
  81076. * Creates a new instance of the Gamepad.
  81077. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81078. * @returns the new gamepad instance
  81079. */
  81080. create(gamepadInfo: any): Gamepad;
  81081. }
  81082. /**
  81083. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81084. */
  81085. export class PoseEnabledControllerHelper {
  81086. /** @hidden */
  81087. static _ControllerFactories: _GamePadFactory[];
  81088. /** @hidden */
  81089. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81090. /**
  81091. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81092. * @param vrGamepad the gamepad to initialized
  81093. * @returns a vr controller of the type the gamepad identified as
  81094. */
  81095. static InitiateController(vrGamepad: any): Gamepad;
  81096. }
  81097. /**
  81098. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81099. */
  81100. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81101. /**
  81102. * If the controller is used in a webXR session
  81103. */
  81104. isXR: boolean;
  81105. private _deviceRoomPosition;
  81106. private _deviceRoomRotationQuaternion;
  81107. /**
  81108. * The device position in babylon space
  81109. */
  81110. devicePosition: Vector3;
  81111. /**
  81112. * The device rotation in babylon space
  81113. */
  81114. deviceRotationQuaternion: Quaternion;
  81115. /**
  81116. * The scale factor of the device in babylon space
  81117. */
  81118. deviceScaleFactor: number;
  81119. /**
  81120. * (Likely devicePosition should be used instead) The device position in its room space
  81121. */
  81122. position: Vector3;
  81123. /**
  81124. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81125. */
  81126. rotationQuaternion: Quaternion;
  81127. /**
  81128. * The type of controller (Eg. Windows mixed reality)
  81129. */
  81130. controllerType: PoseEnabledControllerType;
  81131. protected _calculatedPosition: Vector3;
  81132. private _calculatedRotation;
  81133. /**
  81134. * The raw pose from the device
  81135. */
  81136. rawPose: DevicePose;
  81137. private _trackPosition;
  81138. private _maxRotationDistFromHeadset;
  81139. private _draggedRoomRotation;
  81140. /**
  81141. * @hidden
  81142. */
  81143. _disableTrackPosition(fixedPosition: Vector3): void;
  81144. /**
  81145. * Internal, the mesh attached to the controller
  81146. * @hidden
  81147. */
  81148. _mesh: Nullable<AbstractMesh>;
  81149. private _poseControlledCamera;
  81150. private _leftHandSystemQuaternion;
  81151. /**
  81152. * Internal, matrix used to convert room space to babylon space
  81153. * @hidden
  81154. */
  81155. _deviceToWorld: Matrix;
  81156. /**
  81157. * Node to be used when casting a ray from the controller
  81158. * @hidden
  81159. */
  81160. _pointingPoseNode: Nullable<TransformNode>;
  81161. /**
  81162. * Name of the child mesh that can be used to cast a ray from the controller
  81163. */
  81164. static readonly POINTING_POSE: string;
  81165. /**
  81166. * Creates a new PoseEnabledController from a gamepad
  81167. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81168. */
  81169. constructor(browserGamepad: any);
  81170. private _workingMatrix;
  81171. /**
  81172. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81173. */
  81174. update(): void;
  81175. /**
  81176. * Updates only the pose device and mesh without doing any button event checking
  81177. */
  81178. protected _updatePoseAndMesh(): void;
  81179. /**
  81180. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81181. * @param poseData raw pose fromthe device
  81182. */
  81183. updateFromDevice(poseData: DevicePose): void;
  81184. /**
  81185. * @hidden
  81186. */
  81187. _meshAttachedObservable: Observable<AbstractMesh>;
  81188. /**
  81189. * Attaches a mesh to the controller
  81190. * @param mesh the mesh to be attached
  81191. */
  81192. attachToMesh(mesh: AbstractMesh): void;
  81193. /**
  81194. * Attaches the controllers mesh to a camera
  81195. * @param camera the camera the mesh should be attached to
  81196. */
  81197. attachToPoseControlledCamera(camera: TargetCamera): void;
  81198. /**
  81199. * Disposes of the controller
  81200. */
  81201. dispose(): void;
  81202. /**
  81203. * The mesh that is attached to the controller
  81204. */
  81205. readonly mesh: Nullable<AbstractMesh>;
  81206. /**
  81207. * Gets the ray of the controller in the direction the controller is pointing
  81208. * @param length the length the resulting ray should be
  81209. * @returns a ray in the direction the controller is pointing
  81210. */
  81211. getForwardRay(length?: number): Ray;
  81212. }
  81213. }
  81214. declare module BABYLON {
  81215. /**
  81216. * Defines the WebVRController object that represents controllers tracked in 3D space
  81217. */
  81218. export abstract class WebVRController extends PoseEnabledController {
  81219. /**
  81220. * Internal, the default controller model for the controller
  81221. */
  81222. protected _defaultModel: Nullable<AbstractMesh>;
  81223. /**
  81224. * Fired when the trigger state has changed
  81225. */
  81226. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81227. /**
  81228. * Fired when the main button state has changed
  81229. */
  81230. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81231. /**
  81232. * Fired when the secondary button state has changed
  81233. */
  81234. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81235. /**
  81236. * Fired when the pad state has changed
  81237. */
  81238. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81239. /**
  81240. * Fired when controllers stick values have changed
  81241. */
  81242. onPadValuesChangedObservable: Observable<StickValues>;
  81243. /**
  81244. * Array of button availible on the controller
  81245. */
  81246. protected _buttons: Array<MutableGamepadButton>;
  81247. private _onButtonStateChange;
  81248. /**
  81249. * Fired when a controller button's state has changed
  81250. * @param callback the callback containing the button that was modified
  81251. */
  81252. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81253. /**
  81254. * X and Y axis corresponding to the controllers joystick
  81255. */
  81256. pad: StickValues;
  81257. /**
  81258. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81259. */
  81260. hand: string;
  81261. /**
  81262. * The default controller model for the controller
  81263. */
  81264. readonly defaultModel: Nullable<AbstractMesh>;
  81265. /**
  81266. * Creates a new WebVRController from a gamepad
  81267. * @param vrGamepad the gamepad that the WebVRController should be created from
  81268. */
  81269. constructor(vrGamepad: any);
  81270. /**
  81271. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81272. */
  81273. update(): void;
  81274. /**
  81275. * Function to be called when a button is modified
  81276. */
  81277. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81278. /**
  81279. * Loads a mesh and attaches it to the controller
  81280. * @param scene the scene the mesh should be added to
  81281. * @param meshLoaded callback for when the mesh has been loaded
  81282. */
  81283. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81284. private _setButtonValue;
  81285. private _changes;
  81286. private _checkChanges;
  81287. /**
  81288. * Disposes of th webVRCOntroller
  81289. */
  81290. dispose(): void;
  81291. }
  81292. }
  81293. declare module BABYLON {
  81294. /**
  81295. * The HemisphericLight simulates the ambient environment light,
  81296. * so the passed direction is the light reflection direction, not the incoming direction.
  81297. */
  81298. export class HemisphericLight extends Light {
  81299. /**
  81300. * The groundColor is the light in the opposite direction to the one specified during creation.
  81301. * 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.
  81302. */
  81303. groundColor: Color3;
  81304. /**
  81305. * The light reflection direction, not the incoming direction.
  81306. */
  81307. direction: Vector3;
  81308. /**
  81309. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81310. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81311. * The HemisphericLight can't cast shadows.
  81312. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81313. * @param name The friendly name of the light
  81314. * @param direction The direction of the light reflection
  81315. * @param scene The scene the light belongs to
  81316. */
  81317. constructor(name: string, direction: Vector3, scene: Scene);
  81318. protected _buildUniformLayout(): void;
  81319. /**
  81320. * Returns the string "HemisphericLight".
  81321. * @return The class name
  81322. */
  81323. getClassName(): string;
  81324. /**
  81325. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81326. * Returns the updated direction.
  81327. * @param target The target the direction should point to
  81328. * @return The computed direction
  81329. */
  81330. setDirectionToTarget(target: Vector3): Vector3;
  81331. /**
  81332. * Returns the shadow generator associated to the light.
  81333. * @returns Always null for hemispheric lights because it does not support shadows.
  81334. */
  81335. getShadowGenerator(): Nullable<IShadowGenerator>;
  81336. /**
  81337. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81338. * @param effect The effect to update
  81339. * @param lightIndex The index of the light in the effect to update
  81340. * @returns The hemispheric light
  81341. */
  81342. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81343. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81344. /**
  81345. * Computes the world matrix of the node
  81346. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81347. * @param useWasUpdatedFlag defines a reserved property
  81348. * @returns the world matrix
  81349. */
  81350. computeWorldMatrix(): Matrix;
  81351. /**
  81352. * Returns the integer 3.
  81353. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81354. */
  81355. getTypeID(): number;
  81356. /**
  81357. * Prepares the list of defines specific to the light type.
  81358. * @param defines the list of defines
  81359. * @param lightIndex defines the index of the light for the effect
  81360. */
  81361. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81362. }
  81363. }
  81364. declare module BABYLON {
  81365. /** @hidden */
  81366. export var vrMultiviewToSingleviewPixelShader: {
  81367. name: string;
  81368. shader: string;
  81369. };
  81370. }
  81371. declare module BABYLON {
  81372. /**
  81373. * Renders to multiple views with a single draw call
  81374. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  81375. */
  81376. export class MultiviewRenderTarget extends RenderTargetTexture {
  81377. /**
  81378. * Creates a multiview render target
  81379. * @param scene scene used with the render target
  81380. * @param size the size of the render target (used for each view)
  81381. */
  81382. constructor(scene: Scene, size?: number | {
  81383. width: number;
  81384. height: number;
  81385. } | {
  81386. ratio: number;
  81387. });
  81388. /**
  81389. * @hidden
  81390. * @param faceIndex the face index, if its a cube texture
  81391. */
  81392. _bindFrameBuffer(faceIndex?: number): void;
  81393. /**
  81394. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  81395. * @returns the view count
  81396. */
  81397. getViewCount(): number;
  81398. }
  81399. }
  81400. declare module BABYLON {
  81401. /**
  81402. * Represents a camera frustum
  81403. */
  81404. export class Frustum {
  81405. /**
  81406. * Gets the planes representing the frustum
  81407. * @param transform matrix to be applied to the returned planes
  81408. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81409. */
  81410. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  81411. /**
  81412. * Gets the near frustum plane transformed by the transform matrix
  81413. * @param transform transformation matrix to be applied to the resulting frustum plane
  81414. * @param frustumPlane the resuling frustum plane
  81415. */
  81416. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81417. /**
  81418. * Gets the far frustum plane transformed by the transform matrix
  81419. * @param transform transformation matrix to be applied to the resulting frustum plane
  81420. * @param frustumPlane the resuling frustum plane
  81421. */
  81422. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81423. /**
  81424. * Gets the left frustum plane transformed by the transform matrix
  81425. * @param transform transformation matrix to be applied to the resulting frustum plane
  81426. * @param frustumPlane the resuling frustum plane
  81427. */
  81428. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81429. /**
  81430. * Gets the right frustum plane transformed by the transform matrix
  81431. * @param transform transformation matrix to be applied to the resulting frustum plane
  81432. * @param frustumPlane the resuling frustum plane
  81433. */
  81434. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81435. /**
  81436. * Gets the top frustum plane transformed by the transform matrix
  81437. * @param transform transformation matrix to be applied to the resulting frustum plane
  81438. * @param frustumPlane the resuling frustum plane
  81439. */
  81440. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81441. /**
  81442. * Gets the bottom frustum plane transformed by the transform matrix
  81443. * @param transform transformation matrix to be applied to the resulting frustum plane
  81444. * @param frustumPlane the resuling frustum plane
  81445. */
  81446. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81447. /**
  81448. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81449. * @param transform transformation matrix to be applied to the resulting frustum planes
  81450. * @param frustumPlanes the resuling frustum planes
  81451. */
  81452. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  81453. }
  81454. }
  81455. declare module BABYLON {
  81456. interface Engine {
  81457. /**
  81458. * Creates a new multiview render target
  81459. * @param width defines the width of the texture
  81460. * @param height defines the height of the texture
  81461. * @returns the created multiview texture
  81462. */
  81463. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  81464. /**
  81465. * Binds a multiview framebuffer to be drawn to
  81466. * @param multiviewTexture texture to bind
  81467. */
  81468. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  81469. }
  81470. interface Camera {
  81471. /**
  81472. * @hidden
  81473. * 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)
  81474. */
  81475. _useMultiviewToSingleView: boolean;
  81476. /**
  81477. * @hidden
  81478. * 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)
  81479. */
  81480. _multiviewTexture: Nullable<RenderTargetTexture>;
  81481. /**
  81482. * @hidden
  81483. * ensures the multiview texture of the camera exists and has the specified width/height
  81484. * @param width height to set on the multiview texture
  81485. * @param height width to set on the multiview texture
  81486. */
  81487. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  81488. }
  81489. interface Scene {
  81490. /** @hidden */
  81491. _transformMatrixR: Matrix;
  81492. /** @hidden */
  81493. _multiviewSceneUbo: Nullable<UniformBuffer>;
  81494. /** @hidden */
  81495. _createMultiviewUbo(): void;
  81496. /** @hidden */
  81497. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  81498. /** @hidden */
  81499. _renderMultiviewToSingleView(camera: Camera): void;
  81500. }
  81501. }
  81502. declare module BABYLON {
  81503. /**
  81504. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  81505. * This will not be used for webXR as it supports displaying texture arrays directly
  81506. */
  81507. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  81508. /**
  81509. * Initializes a VRMultiviewToSingleview
  81510. * @param name name of the post process
  81511. * @param camera camera to be applied to
  81512. * @param scaleFactor scaling factor to the size of the output texture
  81513. */
  81514. constructor(name: string, camera: Camera, scaleFactor: number);
  81515. }
  81516. }
  81517. declare module BABYLON {
  81518. interface Engine {
  81519. /** @hidden */
  81520. _vrDisplay: any;
  81521. /** @hidden */
  81522. _vrSupported: boolean;
  81523. /** @hidden */
  81524. _oldSize: Size;
  81525. /** @hidden */
  81526. _oldHardwareScaleFactor: number;
  81527. /** @hidden */
  81528. _vrExclusivePointerMode: boolean;
  81529. /** @hidden */
  81530. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  81531. /** @hidden */
  81532. _onVRDisplayPointerRestricted: () => void;
  81533. /** @hidden */
  81534. _onVRDisplayPointerUnrestricted: () => void;
  81535. /** @hidden */
  81536. _onVrDisplayConnect: Nullable<(display: any) => void>;
  81537. /** @hidden */
  81538. _onVrDisplayDisconnect: Nullable<() => void>;
  81539. /** @hidden */
  81540. _onVrDisplayPresentChange: Nullable<() => void>;
  81541. /**
  81542. * Observable signaled when VR display mode changes
  81543. */
  81544. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  81545. /**
  81546. * Observable signaled when VR request present is complete
  81547. */
  81548. onVRRequestPresentComplete: Observable<boolean>;
  81549. /**
  81550. * Observable signaled when VR request present starts
  81551. */
  81552. onVRRequestPresentStart: Observable<Engine>;
  81553. /**
  81554. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  81555. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  81556. */
  81557. isInVRExclusivePointerMode: boolean;
  81558. /**
  81559. * Gets a boolean indicating if a webVR device was detected
  81560. * @returns true if a webVR device was detected
  81561. */
  81562. isVRDevicePresent(): boolean;
  81563. /**
  81564. * Gets the current webVR device
  81565. * @returns the current webVR device (or null)
  81566. */
  81567. getVRDevice(): any;
  81568. /**
  81569. * Initializes a webVR display and starts listening to display change events
  81570. * The onVRDisplayChangedObservable will be notified upon these changes
  81571. * @returns A promise containing a VRDisplay and if vr is supported
  81572. */
  81573. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  81574. /** @hidden */
  81575. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  81576. /**
  81577. * Call this function to switch to webVR mode
  81578. * Will do nothing if webVR is not supported or if there is no webVR device
  81579. * @see http://doc.babylonjs.com/how_to/webvr_camera
  81580. */
  81581. enableVR(): void;
  81582. /** @hidden */
  81583. _onVRFullScreenTriggered(): void;
  81584. }
  81585. }
  81586. declare module BABYLON {
  81587. /**
  81588. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  81589. * IMPORTANT!! The data is right-hand data.
  81590. * @export
  81591. * @interface DevicePose
  81592. */
  81593. export interface DevicePose {
  81594. /**
  81595. * The position of the device, values in array are [x,y,z].
  81596. */
  81597. readonly position: Nullable<Float32Array>;
  81598. /**
  81599. * The linearVelocity of the device, values in array are [x,y,z].
  81600. */
  81601. readonly linearVelocity: Nullable<Float32Array>;
  81602. /**
  81603. * The linearAcceleration of the device, values in array are [x,y,z].
  81604. */
  81605. readonly linearAcceleration: Nullable<Float32Array>;
  81606. /**
  81607. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  81608. */
  81609. readonly orientation: Nullable<Float32Array>;
  81610. /**
  81611. * The angularVelocity of the device, values in array are [x,y,z].
  81612. */
  81613. readonly angularVelocity: Nullable<Float32Array>;
  81614. /**
  81615. * The angularAcceleration of the device, values in array are [x,y,z].
  81616. */
  81617. readonly angularAcceleration: Nullable<Float32Array>;
  81618. }
  81619. /**
  81620. * Interface representing a pose controlled object in Babylon.
  81621. * A pose controlled object has both regular pose values as well as pose values
  81622. * from an external device such as a VR head mounted display
  81623. */
  81624. export interface PoseControlled {
  81625. /**
  81626. * The position of the object in babylon space.
  81627. */
  81628. position: Vector3;
  81629. /**
  81630. * The rotation quaternion of the object in babylon space.
  81631. */
  81632. rotationQuaternion: Quaternion;
  81633. /**
  81634. * The position of the device in babylon space.
  81635. */
  81636. devicePosition?: Vector3;
  81637. /**
  81638. * The rotation quaternion of the device in babylon space.
  81639. */
  81640. deviceRotationQuaternion: Quaternion;
  81641. /**
  81642. * The raw pose coming from the device.
  81643. */
  81644. rawPose: Nullable<DevicePose>;
  81645. /**
  81646. * The scale of the device to be used when translating from device space to babylon space.
  81647. */
  81648. deviceScaleFactor: number;
  81649. /**
  81650. * Updates the poseControlled values based on the input device pose.
  81651. * @param poseData the pose data to update the object with
  81652. */
  81653. updateFromDevice(poseData: DevicePose): void;
  81654. }
  81655. /**
  81656. * Set of options to customize the webVRCamera
  81657. */
  81658. export interface WebVROptions {
  81659. /**
  81660. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  81661. */
  81662. trackPosition?: boolean;
  81663. /**
  81664. * Sets the scale of the vrDevice in babylon space. (default: 1)
  81665. */
  81666. positionScale?: number;
  81667. /**
  81668. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  81669. */
  81670. displayName?: string;
  81671. /**
  81672. * Should the native controller meshes be initialized. (default: true)
  81673. */
  81674. controllerMeshes?: boolean;
  81675. /**
  81676. * Creating a default HemiLight only on controllers. (default: true)
  81677. */
  81678. defaultLightingOnControllers?: boolean;
  81679. /**
  81680. * If you don't want to use the default VR button of the helper. (default: false)
  81681. */
  81682. useCustomVRButton?: boolean;
  81683. /**
  81684. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  81685. */
  81686. customVRButton?: HTMLButtonElement;
  81687. /**
  81688. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  81689. */
  81690. rayLength?: number;
  81691. /**
  81692. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  81693. */
  81694. defaultHeight?: number;
  81695. /**
  81696. * If multiview should be used if availible (default: false)
  81697. */
  81698. useMultiview?: boolean;
  81699. }
  81700. /**
  81701. * This represents a WebVR camera.
  81702. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  81703. * @example http://doc.babylonjs.com/how_to/webvr_camera
  81704. */
  81705. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  81706. private webVROptions;
  81707. /**
  81708. * @hidden
  81709. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  81710. */
  81711. _vrDevice: any;
  81712. /**
  81713. * The rawPose of the vrDevice.
  81714. */
  81715. rawPose: Nullable<DevicePose>;
  81716. private _onVREnabled;
  81717. private _specsVersion;
  81718. private _attached;
  81719. private _frameData;
  81720. protected _descendants: Array<Node>;
  81721. private _deviceRoomPosition;
  81722. /** @hidden */
  81723. _deviceRoomRotationQuaternion: Quaternion;
  81724. private _standingMatrix;
  81725. /**
  81726. * Represents device position in babylon space.
  81727. */
  81728. devicePosition: Vector3;
  81729. /**
  81730. * Represents device rotation in babylon space.
  81731. */
  81732. deviceRotationQuaternion: Quaternion;
  81733. /**
  81734. * The scale of the device to be used when translating from device space to babylon space.
  81735. */
  81736. deviceScaleFactor: number;
  81737. private _deviceToWorld;
  81738. private _worldToDevice;
  81739. /**
  81740. * References to the webVR controllers for the vrDevice.
  81741. */
  81742. controllers: Array<WebVRController>;
  81743. /**
  81744. * Emits an event when a controller is attached.
  81745. */
  81746. onControllersAttachedObservable: Observable<WebVRController[]>;
  81747. /**
  81748. * Emits an event when a controller's mesh has been loaded;
  81749. */
  81750. onControllerMeshLoadedObservable: Observable<WebVRController>;
  81751. /**
  81752. * Emits an event when the HMD's pose has been updated.
  81753. */
  81754. onPoseUpdatedFromDeviceObservable: Observable<any>;
  81755. private _poseSet;
  81756. /**
  81757. * If the rig cameras be used as parent instead of this camera.
  81758. */
  81759. rigParenting: boolean;
  81760. private _lightOnControllers;
  81761. private _defaultHeight?;
  81762. /**
  81763. * Instantiates a WebVRFreeCamera.
  81764. * @param name The name of the WebVRFreeCamera
  81765. * @param position The starting anchor position for the camera
  81766. * @param scene The scene the camera belongs to
  81767. * @param webVROptions a set of customizable options for the webVRCamera
  81768. */
  81769. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  81770. /**
  81771. * Gets the device distance from the ground in meters.
  81772. * @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.
  81773. */
  81774. deviceDistanceToRoomGround(): number;
  81775. /**
  81776. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81777. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  81778. */
  81779. useStandingMatrix(callback?: (bool: boolean) => void): void;
  81780. /**
  81781. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81782. * @returns A promise with a boolean set to if the standing matrix is supported.
  81783. */
  81784. useStandingMatrixAsync(): Promise<boolean>;
  81785. /**
  81786. * Disposes the camera
  81787. */
  81788. dispose(): void;
  81789. /**
  81790. * Gets a vrController by name.
  81791. * @param name The name of the controller to retreive
  81792. * @returns the controller matching the name specified or null if not found
  81793. */
  81794. getControllerByName(name: string): Nullable<WebVRController>;
  81795. private _leftController;
  81796. /**
  81797. * The controller corresponding to the users left hand.
  81798. */
  81799. readonly leftController: Nullable<WebVRController>;
  81800. private _rightController;
  81801. /**
  81802. * The controller corresponding to the users right hand.
  81803. */
  81804. readonly rightController: Nullable<WebVRController>;
  81805. /**
  81806. * Casts a ray forward from the vrCamera's gaze.
  81807. * @param length Length of the ray (default: 100)
  81808. * @returns the ray corresponding to the gaze
  81809. */
  81810. getForwardRay(length?: number): Ray;
  81811. /**
  81812. * @hidden
  81813. * Updates the camera based on device's frame data
  81814. */
  81815. _checkInputs(): void;
  81816. /**
  81817. * Updates the poseControlled values based on the input device pose.
  81818. * @param poseData Pose coming from the device
  81819. */
  81820. updateFromDevice(poseData: DevicePose): void;
  81821. private _htmlElementAttached;
  81822. private _detachIfAttached;
  81823. /**
  81824. * WebVR's attach control will start broadcasting frames to the device.
  81825. * Note that in certain browsers (chrome for example) this function must be called
  81826. * within a user-interaction callback. Example:
  81827. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  81828. *
  81829. * @param element html element to attach the vrDevice to
  81830. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  81831. */
  81832. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81833. /**
  81834. * Detaches the camera from the html element and disables VR
  81835. *
  81836. * @param element html element to detach from
  81837. */
  81838. detachControl(element: HTMLElement): void;
  81839. /**
  81840. * @returns the name of this class
  81841. */
  81842. getClassName(): string;
  81843. /**
  81844. * Calls resetPose on the vrDisplay
  81845. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  81846. */
  81847. resetToCurrentRotation(): void;
  81848. /**
  81849. * @hidden
  81850. * Updates the rig cameras (left and right eye)
  81851. */
  81852. _updateRigCameras(): void;
  81853. private _workingVector;
  81854. private _oneVector;
  81855. private _workingMatrix;
  81856. private updateCacheCalled;
  81857. private _correctPositionIfNotTrackPosition;
  81858. /**
  81859. * @hidden
  81860. * Updates the cached values of the camera
  81861. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  81862. */
  81863. _updateCache(ignoreParentClass?: boolean): void;
  81864. /**
  81865. * @hidden
  81866. * Get current device position in babylon world
  81867. */
  81868. _computeDevicePosition(): void;
  81869. /**
  81870. * Updates the current device position and rotation in the babylon world
  81871. */
  81872. update(): void;
  81873. /**
  81874. * @hidden
  81875. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  81876. * @returns an identity matrix
  81877. */
  81878. _getViewMatrix(): Matrix;
  81879. private _tmpMatrix;
  81880. /**
  81881. * This function is called by the two RIG cameras.
  81882. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  81883. * @hidden
  81884. */
  81885. _getWebVRViewMatrix(): Matrix;
  81886. /** @hidden */
  81887. _getWebVRProjectionMatrix(): Matrix;
  81888. private _onGamepadConnectedObserver;
  81889. private _onGamepadDisconnectedObserver;
  81890. private _updateCacheWhenTrackingDisabledObserver;
  81891. /**
  81892. * Initializes the controllers and their meshes
  81893. */
  81894. initControllers(): void;
  81895. }
  81896. }
  81897. declare module BABYLON {
  81898. /**
  81899. * Size options for a post process
  81900. */
  81901. export type PostProcessOptions = {
  81902. width: number;
  81903. height: number;
  81904. };
  81905. /**
  81906. * PostProcess can be used to apply a shader to a texture after it has been rendered
  81907. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81908. */
  81909. export class PostProcess {
  81910. /** Name of the PostProcess. */
  81911. name: string;
  81912. /**
  81913. * Gets or sets the unique id of the post process
  81914. */
  81915. uniqueId: number;
  81916. /**
  81917. * Width of the texture to apply the post process on
  81918. */
  81919. width: number;
  81920. /**
  81921. * Height of the texture to apply the post process on
  81922. */
  81923. height: number;
  81924. /**
  81925. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  81926. * @hidden
  81927. */
  81928. _outputTexture: Nullable<InternalTexture>;
  81929. /**
  81930. * Sampling mode used by the shader
  81931. * See https://doc.babylonjs.com/classes/3.1/texture
  81932. */
  81933. renderTargetSamplingMode: number;
  81934. /**
  81935. * Clear color to use when screen clearing
  81936. */
  81937. clearColor: Color4;
  81938. /**
  81939. * If the buffer needs to be cleared before applying the post process. (default: true)
  81940. * Should be set to false if shader will overwrite all previous pixels.
  81941. */
  81942. autoClear: boolean;
  81943. /**
  81944. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  81945. */
  81946. alphaMode: number;
  81947. /**
  81948. * Sets the setAlphaBlendConstants of the babylon engine
  81949. */
  81950. alphaConstants: Color4;
  81951. /**
  81952. * Animations to be used for the post processing
  81953. */
  81954. animations: Animation[];
  81955. /**
  81956. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  81957. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  81958. */
  81959. enablePixelPerfectMode: boolean;
  81960. /**
  81961. * Force the postprocess to be applied without taking in account viewport
  81962. */
  81963. forceFullscreenViewport: boolean;
  81964. /**
  81965. * List of inspectable custom properties (used by the Inspector)
  81966. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81967. */
  81968. inspectableCustomProperties: IInspectable[];
  81969. /**
  81970. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  81971. *
  81972. * | Value | Type | Description |
  81973. * | ----- | ----------------------------------- | ----------- |
  81974. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  81975. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  81976. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  81977. *
  81978. */
  81979. scaleMode: number;
  81980. /**
  81981. * Force textures to be a power of two (default: false)
  81982. */
  81983. alwaysForcePOT: boolean;
  81984. private _samples;
  81985. /**
  81986. * Number of sample textures (default: 1)
  81987. */
  81988. samples: number;
  81989. /**
  81990. * Modify the scale of the post process to be the same as the viewport (default: false)
  81991. */
  81992. adaptScaleToCurrentViewport: boolean;
  81993. private _camera;
  81994. private _scene;
  81995. private _engine;
  81996. private _options;
  81997. private _reusable;
  81998. private _textureType;
  81999. /**
  82000. * Smart array of input and output textures for the post process.
  82001. * @hidden
  82002. */
  82003. _textures: SmartArray<InternalTexture>;
  82004. /**
  82005. * The index in _textures that corresponds to the output texture.
  82006. * @hidden
  82007. */
  82008. _currentRenderTextureInd: number;
  82009. private _effect;
  82010. private _samplers;
  82011. private _fragmentUrl;
  82012. private _vertexUrl;
  82013. private _parameters;
  82014. private _scaleRatio;
  82015. protected _indexParameters: any;
  82016. private _shareOutputWithPostProcess;
  82017. private _texelSize;
  82018. private _forcedOutputTexture;
  82019. /**
  82020. * Returns the fragment url or shader name used in the post process.
  82021. * @returns the fragment url or name in the shader store.
  82022. */
  82023. getEffectName(): string;
  82024. /**
  82025. * An event triggered when the postprocess is activated.
  82026. */
  82027. onActivateObservable: Observable<Camera>;
  82028. private _onActivateObserver;
  82029. /**
  82030. * A function that is added to the onActivateObservable
  82031. */
  82032. onActivate: Nullable<(camera: Camera) => void>;
  82033. /**
  82034. * An event triggered when the postprocess changes its size.
  82035. */
  82036. onSizeChangedObservable: Observable<PostProcess>;
  82037. private _onSizeChangedObserver;
  82038. /**
  82039. * A function that is added to the onSizeChangedObservable
  82040. */
  82041. onSizeChanged: (postProcess: PostProcess) => void;
  82042. /**
  82043. * An event triggered when the postprocess applies its effect.
  82044. */
  82045. onApplyObservable: Observable<Effect>;
  82046. private _onApplyObserver;
  82047. /**
  82048. * A function that is added to the onApplyObservable
  82049. */
  82050. onApply: (effect: Effect) => void;
  82051. /**
  82052. * An event triggered before rendering the postprocess
  82053. */
  82054. onBeforeRenderObservable: Observable<Effect>;
  82055. private _onBeforeRenderObserver;
  82056. /**
  82057. * A function that is added to the onBeforeRenderObservable
  82058. */
  82059. onBeforeRender: (effect: Effect) => void;
  82060. /**
  82061. * An event triggered after rendering the postprocess
  82062. */
  82063. onAfterRenderObservable: Observable<Effect>;
  82064. private _onAfterRenderObserver;
  82065. /**
  82066. * A function that is added to the onAfterRenderObservable
  82067. */
  82068. onAfterRender: (efect: Effect) => void;
  82069. /**
  82070. * 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
  82071. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82072. */
  82073. inputTexture: InternalTexture;
  82074. /**
  82075. * Gets the camera which post process is applied to.
  82076. * @returns The camera the post process is applied to.
  82077. */
  82078. getCamera(): Camera;
  82079. /**
  82080. * Gets the texel size of the postprocess.
  82081. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82082. */
  82083. readonly texelSize: Vector2;
  82084. /**
  82085. * Creates a new instance PostProcess
  82086. * @param name The name of the PostProcess.
  82087. * @param fragmentUrl The url of the fragment shader to be used.
  82088. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82089. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82090. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82091. * @param camera The camera to apply the render pass to.
  82092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82093. * @param engine The engine which the post process will be applied. (default: current engine)
  82094. * @param reusable If the post process can be reused on the same frame. (default: false)
  82095. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82096. * @param textureType Type of textures used when performing the post process. (default: 0)
  82097. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82098. * @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
  82099. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82100. */
  82101. constructor(
  82102. /** Name of the PostProcess. */
  82103. 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);
  82104. /**
  82105. * Gets a string idenfifying the name of the class
  82106. * @returns "PostProcess" string
  82107. */
  82108. getClassName(): string;
  82109. /**
  82110. * Gets the engine which this post process belongs to.
  82111. * @returns The engine the post process was enabled with.
  82112. */
  82113. getEngine(): Engine;
  82114. /**
  82115. * The effect that is created when initializing the post process.
  82116. * @returns The created effect corresponding the the postprocess.
  82117. */
  82118. getEffect(): Effect;
  82119. /**
  82120. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82121. * @param postProcess The post process to share the output with.
  82122. * @returns This post process.
  82123. */
  82124. shareOutputWith(postProcess: PostProcess): PostProcess;
  82125. /**
  82126. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82127. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82128. */
  82129. useOwnOutput(): void;
  82130. /**
  82131. * Updates the effect with the current post process compile time values and recompiles the shader.
  82132. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82133. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82134. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82135. * @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
  82136. * @param onCompiled Called when the shader has been compiled.
  82137. * @param onError Called if there is an error when compiling a shader.
  82138. */
  82139. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82140. /**
  82141. * The post process is reusable if it can be used multiple times within one frame.
  82142. * @returns If the post process is reusable
  82143. */
  82144. isReusable(): boolean;
  82145. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82146. markTextureDirty(): void;
  82147. /**
  82148. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82149. * 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.
  82150. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82151. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82152. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82153. * @returns The target texture that was bound to be written to.
  82154. */
  82155. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82156. /**
  82157. * If the post process is supported.
  82158. */
  82159. readonly isSupported: boolean;
  82160. /**
  82161. * The aspect ratio of the output texture.
  82162. */
  82163. readonly aspectRatio: number;
  82164. /**
  82165. * Get a value indicating if the post-process is ready to be used
  82166. * @returns true if the post-process is ready (shader is compiled)
  82167. */
  82168. isReady(): boolean;
  82169. /**
  82170. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82171. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82172. */
  82173. apply(): Nullable<Effect>;
  82174. private _disposeTextures;
  82175. /**
  82176. * Disposes the post process.
  82177. * @param camera The camera to dispose the post process on.
  82178. */
  82179. dispose(camera?: Camera): void;
  82180. }
  82181. }
  82182. declare module BABYLON {
  82183. /** @hidden */
  82184. export var kernelBlurVaryingDeclaration: {
  82185. name: string;
  82186. shader: string;
  82187. };
  82188. }
  82189. declare module BABYLON {
  82190. /** @hidden */
  82191. export var kernelBlurFragment: {
  82192. name: string;
  82193. shader: string;
  82194. };
  82195. }
  82196. declare module BABYLON {
  82197. /** @hidden */
  82198. export var kernelBlurFragment2: {
  82199. name: string;
  82200. shader: string;
  82201. };
  82202. }
  82203. declare module BABYLON {
  82204. /** @hidden */
  82205. export var kernelBlurPixelShader: {
  82206. name: string;
  82207. shader: string;
  82208. };
  82209. }
  82210. declare module BABYLON {
  82211. /** @hidden */
  82212. export var kernelBlurVertex: {
  82213. name: string;
  82214. shader: string;
  82215. };
  82216. }
  82217. declare module BABYLON {
  82218. /** @hidden */
  82219. export var kernelBlurVertexShader: {
  82220. name: string;
  82221. shader: string;
  82222. };
  82223. }
  82224. declare module BABYLON {
  82225. /**
  82226. * The Blur Post Process which blurs an image based on a kernel and direction.
  82227. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82228. */
  82229. export class BlurPostProcess extends PostProcess {
  82230. /** The direction in which to blur the image. */
  82231. direction: Vector2;
  82232. private blockCompilation;
  82233. protected _kernel: number;
  82234. protected _idealKernel: number;
  82235. protected _packedFloat: boolean;
  82236. private _staticDefines;
  82237. /**
  82238. * Sets the length in pixels of the blur sample region
  82239. */
  82240. /**
  82241. * Gets the length in pixels of the blur sample region
  82242. */
  82243. kernel: number;
  82244. /**
  82245. * Sets wether or not the blur needs to unpack/repack floats
  82246. */
  82247. /**
  82248. * Gets wether or not the blur is unpacking/repacking floats
  82249. */
  82250. packedFloat: boolean;
  82251. /**
  82252. * Creates a new instance BlurPostProcess
  82253. * @param name The name of the effect.
  82254. * @param direction The direction in which to blur the image.
  82255. * @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.
  82256. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82257. * @param camera The camera to apply the render pass to.
  82258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82259. * @param engine The engine which the post process will be applied. (default: current engine)
  82260. * @param reusable If the post process can be reused on the same frame. (default: false)
  82261. * @param textureType Type of textures used when performing the post process. (default: 0)
  82262. * @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)
  82263. */
  82264. constructor(name: string,
  82265. /** The direction in which to blur the image. */
  82266. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82267. /**
  82268. * Updates the effect with the current post process compile time values and recompiles the shader.
  82269. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82270. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82271. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82272. * @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
  82273. * @param onCompiled Called when the shader has been compiled.
  82274. * @param onError Called if there is an error when compiling a shader.
  82275. */
  82276. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82277. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82278. /**
  82279. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82280. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82281. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82282. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82283. * The gaps between physical kernels are compensated for in the weighting of the samples
  82284. * @param idealKernel Ideal blur kernel.
  82285. * @return Nearest best kernel.
  82286. */
  82287. protected _nearestBestKernel(idealKernel: number): number;
  82288. /**
  82289. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82290. * @param x The point on the Gaussian distribution to sample.
  82291. * @return the value of the Gaussian function at x.
  82292. */
  82293. protected _gaussianWeight(x: number): number;
  82294. /**
  82295. * Generates a string that can be used as a floating point number in GLSL.
  82296. * @param x Value to print.
  82297. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82298. * @return GLSL float string.
  82299. */
  82300. protected _glslFloat(x: number, decimalFigures?: number): string;
  82301. }
  82302. }
  82303. declare module BABYLON {
  82304. /**
  82305. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82306. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82307. * You can then easily use it as a reflectionTexture on a flat surface.
  82308. * In case the surface is not a plane, please consider relying on reflection probes.
  82309. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82310. */
  82311. export class MirrorTexture extends RenderTargetTexture {
  82312. private scene;
  82313. /**
  82314. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82315. * 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.
  82316. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82317. */
  82318. mirrorPlane: Plane;
  82319. /**
  82320. * Define the blur ratio used to blur the reflection if needed.
  82321. */
  82322. blurRatio: number;
  82323. /**
  82324. * Define the adaptive blur kernel used to blur the reflection if needed.
  82325. * This will autocompute the closest best match for the `blurKernel`
  82326. */
  82327. adaptiveBlurKernel: number;
  82328. /**
  82329. * Define the blur kernel used to blur the reflection if needed.
  82330. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82331. */
  82332. blurKernel: number;
  82333. /**
  82334. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82335. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82336. */
  82337. blurKernelX: number;
  82338. /**
  82339. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82340. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82341. */
  82342. blurKernelY: number;
  82343. private _autoComputeBlurKernel;
  82344. protected _onRatioRescale(): void;
  82345. private _updateGammaSpace;
  82346. private _imageProcessingConfigChangeObserver;
  82347. private _transformMatrix;
  82348. private _mirrorMatrix;
  82349. private _savedViewMatrix;
  82350. private _blurX;
  82351. private _blurY;
  82352. private _adaptiveBlurKernel;
  82353. private _blurKernelX;
  82354. private _blurKernelY;
  82355. private _blurRatio;
  82356. /**
  82357. * Instantiates a Mirror Texture.
  82358. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82359. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82360. * You can then easily use it as a reflectionTexture on a flat surface.
  82361. * In case the surface is not a plane, please consider relying on reflection probes.
  82362. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82363. * @param name
  82364. * @param size
  82365. * @param scene
  82366. * @param generateMipMaps
  82367. * @param type
  82368. * @param samplingMode
  82369. * @param generateDepthBuffer
  82370. */
  82371. constructor(name: string, size: number | {
  82372. width: number;
  82373. height: number;
  82374. } | {
  82375. ratio: number;
  82376. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  82377. private _preparePostProcesses;
  82378. /**
  82379. * Clone the mirror texture.
  82380. * @returns the cloned texture
  82381. */
  82382. clone(): MirrorTexture;
  82383. /**
  82384. * Serialize the texture to a JSON representation you could use in Parse later on
  82385. * @returns the serialized JSON representation
  82386. */
  82387. serialize(): any;
  82388. /**
  82389. * Dispose the texture and release its associated resources.
  82390. */
  82391. dispose(): void;
  82392. }
  82393. }
  82394. declare module BABYLON {
  82395. /**
  82396. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82397. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82398. */
  82399. export class Texture extends BaseTexture {
  82400. /**
  82401. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  82402. */
  82403. static SerializeBuffers: boolean;
  82404. /** @hidden */
  82405. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  82406. /** @hidden */
  82407. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  82408. /** @hidden */
  82409. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  82410. /** nearest is mag = nearest and min = nearest and mip = linear */
  82411. static readonly NEAREST_SAMPLINGMODE: number;
  82412. /** nearest is mag = nearest and min = nearest and mip = linear */
  82413. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  82414. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82415. static readonly BILINEAR_SAMPLINGMODE: number;
  82416. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82417. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  82418. /** Trilinear is mag = linear and min = linear and mip = linear */
  82419. static readonly TRILINEAR_SAMPLINGMODE: number;
  82420. /** Trilinear is mag = linear and min = linear and mip = linear */
  82421. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  82422. /** mag = nearest and min = nearest and mip = nearest */
  82423. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  82424. /** mag = nearest and min = linear and mip = nearest */
  82425. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  82426. /** mag = nearest and min = linear and mip = linear */
  82427. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  82428. /** mag = nearest and min = linear and mip = none */
  82429. static readonly NEAREST_LINEAR: number;
  82430. /** mag = nearest and min = nearest and mip = none */
  82431. static readonly NEAREST_NEAREST: number;
  82432. /** mag = linear and min = nearest and mip = nearest */
  82433. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  82434. /** mag = linear and min = nearest and mip = linear */
  82435. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  82436. /** mag = linear and min = linear and mip = none */
  82437. static readonly LINEAR_LINEAR: number;
  82438. /** mag = linear and min = nearest and mip = none */
  82439. static readonly LINEAR_NEAREST: number;
  82440. /** Explicit coordinates mode */
  82441. static readonly EXPLICIT_MODE: number;
  82442. /** Spherical coordinates mode */
  82443. static readonly SPHERICAL_MODE: number;
  82444. /** Planar coordinates mode */
  82445. static readonly PLANAR_MODE: number;
  82446. /** Cubic coordinates mode */
  82447. static readonly CUBIC_MODE: number;
  82448. /** Projection coordinates mode */
  82449. static readonly PROJECTION_MODE: number;
  82450. /** Inverse Cubic coordinates mode */
  82451. static readonly SKYBOX_MODE: number;
  82452. /** Inverse Cubic coordinates mode */
  82453. static readonly INVCUBIC_MODE: number;
  82454. /** Equirectangular coordinates mode */
  82455. static readonly EQUIRECTANGULAR_MODE: number;
  82456. /** Equirectangular Fixed coordinates mode */
  82457. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  82458. /** Equirectangular Fixed Mirrored coordinates mode */
  82459. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82460. /** Texture is not repeating outside of 0..1 UVs */
  82461. static readonly CLAMP_ADDRESSMODE: number;
  82462. /** Texture is repeating outside of 0..1 UVs */
  82463. static readonly WRAP_ADDRESSMODE: number;
  82464. /** Texture is repeating and mirrored */
  82465. static readonly MIRROR_ADDRESSMODE: number;
  82466. /**
  82467. * 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
  82468. */
  82469. static UseSerializedUrlIfAny: boolean;
  82470. /**
  82471. * Define the url of the texture.
  82472. */
  82473. url: Nullable<string>;
  82474. /**
  82475. * Define an offset on the texture to offset the u coordinates of the UVs
  82476. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82477. */
  82478. uOffset: number;
  82479. /**
  82480. * Define an offset on the texture to offset the v coordinates of the UVs
  82481. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82482. */
  82483. vOffset: number;
  82484. /**
  82485. * Define an offset on the texture to scale the u coordinates of the UVs
  82486. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82487. */
  82488. uScale: number;
  82489. /**
  82490. * Define an offset on the texture to scale the v coordinates of the UVs
  82491. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82492. */
  82493. vScale: number;
  82494. /**
  82495. * Define an offset on the texture to rotate around the u coordinates of the UVs
  82496. * @see http://doc.babylonjs.com/how_to/more_materials
  82497. */
  82498. uAng: number;
  82499. /**
  82500. * Define an offset on the texture to rotate around the v coordinates of the UVs
  82501. * @see http://doc.babylonjs.com/how_to/more_materials
  82502. */
  82503. vAng: number;
  82504. /**
  82505. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  82506. * @see http://doc.babylonjs.com/how_to/more_materials
  82507. */
  82508. wAng: number;
  82509. /**
  82510. * Defines the center of rotation (U)
  82511. */
  82512. uRotationCenter: number;
  82513. /**
  82514. * Defines the center of rotation (V)
  82515. */
  82516. vRotationCenter: number;
  82517. /**
  82518. * Defines the center of rotation (W)
  82519. */
  82520. wRotationCenter: number;
  82521. /**
  82522. * Are mip maps generated for this texture or not.
  82523. */
  82524. readonly noMipmap: boolean;
  82525. /**
  82526. * List of inspectable custom properties (used by the Inspector)
  82527. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82528. */
  82529. inspectableCustomProperties: Nullable<IInspectable[]>;
  82530. private _noMipmap;
  82531. /** @hidden */
  82532. _invertY: boolean;
  82533. private _rowGenerationMatrix;
  82534. private _cachedTextureMatrix;
  82535. private _projectionModeMatrix;
  82536. private _t0;
  82537. private _t1;
  82538. private _t2;
  82539. private _cachedUOffset;
  82540. private _cachedVOffset;
  82541. private _cachedUScale;
  82542. private _cachedVScale;
  82543. private _cachedUAng;
  82544. private _cachedVAng;
  82545. private _cachedWAng;
  82546. private _cachedProjectionMatrixId;
  82547. private _cachedCoordinatesMode;
  82548. /** @hidden */
  82549. protected _initialSamplingMode: number;
  82550. /** @hidden */
  82551. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  82552. private _deleteBuffer;
  82553. protected _format: Nullable<number>;
  82554. private _delayedOnLoad;
  82555. private _delayedOnError;
  82556. /**
  82557. * Observable triggered once the texture has been loaded.
  82558. */
  82559. onLoadObservable: Observable<Texture>;
  82560. protected _isBlocking: boolean;
  82561. /**
  82562. * Is the texture preventing material to render while loading.
  82563. * If false, a default texture will be used instead of the loading one during the preparation step.
  82564. */
  82565. isBlocking: boolean;
  82566. /**
  82567. * Get the current sampling mode associated with the texture.
  82568. */
  82569. readonly samplingMode: number;
  82570. /**
  82571. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  82572. */
  82573. readonly invertY: boolean;
  82574. /**
  82575. * Instantiates a new texture.
  82576. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82577. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82578. * @param url define the url of the picture to load as a texture
  82579. * @param scene define the scene or engine the texture will belong to
  82580. * @param noMipmap define if the texture will require mip maps or not
  82581. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82582. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82583. * @param onLoad define a callback triggered when the texture has been loaded
  82584. * @param onError define a callback triggered when an error occurred during the loading session
  82585. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82586. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82587. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82588. */
  82589. 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);
  82590. /**
  82591. * Update the url (and optional buffer) of this texture if url was null during construction.
  82592. * @param url the url of the texture
  82593. * @param buffer the buffer of the texture (defaults to null)
  82594. * @param onLoad callback called when the texture is loaded (defaults to null)
  82595. */
  82596. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  82597. /**
  82598. * Finish the loading sequence of a texture flagged as delayed load.
  82599. * @hidden
  82600. */
  82601. delayLoad(): void;
  82602. private _prepareRowForTextureGeneration;
  82603. /**
  82604. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  82605. * @returns the transform matrix of the texture.
  82606. */
  82607. getTextureMatrix(): Matrix;
  82608. /**
  82609. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  82610. * @returns The reflection texture transform
  82611. */
  82612. getReflectionTextureMatrix(): Matrix;
  82613. /**
  82614. * Clones the texture.
  82615. * @returns the cloned texture
  82616. */
  82617. clone(): Texture;
  82618. /**
  82619. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  82620. * @returns The JSON representation of the texture
  82621. */
  82622. serialize(): any;
  82623. /**
  82624. * Get the current class name of the texture useful for serialization or dynamic coding.
  82625. * @returns "Texture"
  82626. */
  82627. getClassName(): string;
  82628. /**
  82629. * Dispose the texture and release its associated resources.
  82630. */
  82631. dispose(): void;
  82632. /**
  82633. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  82634. * @param parsedTexture Define the JSON representation of the texture
  82635. * @param scene Define the scene the parsed texture should be instantiated in
  82636. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  82637. * @returns The parsed texture if successful
  82638. */
  82639. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  82640. /**
  82641. * Creates a texture from its base 64 representation.
  82642. * @param data Define the base64 payload without the data: prefix
  82643. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82644. * @param scene Define the scene the texture should belong to
  82645. * @param noMipmap Forces the texture to not create mip map information if true
  82646. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82647. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82648. * @param onLoad define a callback triggered when the texture has been loaded
  82649. * @param onError define a callback triggered when an error occurred during the loading session
  82650. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82651. * @returns the created texture
  82652. */
  82653. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  82654. /**
  82655. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  82656. * @param data Define the base64 payload without the data: prefix
  82657. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82658. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82659. * @param scene Define the scene the texture should belong to
  82660. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82661. * @param noMipmap Forces the texture to not create mip map information if true
  82662. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82663. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82664. * @param onLoad define a callback triggered when the texture has been loaded
  82665. * @param onError define a callback triggered when an error occurred during the loading session
  82666. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82667. * @returns the created texture
  82668. */
  82669. 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;
  82670. }
  82671. }
  82672. declare module BABYLON {
  82673. /**
  82674. * PostProcessManager is used to manage one or more post processes or post process pipelines
  82675. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82676. */
  82677. export class PostProcessManager {
  82678. private _scene;
  82679. private _indexBuffer;
  82680. private _vertexBuffers;
  82681. /**
  82682. * Creates a new instance PostProcess
  82683. * @param scene The scene that the post process is associated with.
  82684. */
  82685. constructor(scene: Scene);
  82686. private _prepareBuffers;
  82687. private _buildIndexBuffer;
  82688. /**
  82689. * Rebuilds the vertex buffers of the manager.
  82690. * @hidden
  82691. */
  82692. _rebuild(): void;
  82693. /**
  82694. * Prepares a frame to be run through a post process.
  82695. * @param sourceTexture The input texture to the post procesess. (default: null)
  82696. * @param postProcesses An array of post processes to be run. (default: null)
  82697. * @returns True if the post processes were able to be run.
  82698. * @hidden
  82699. */
  82700. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  82701. /**
  82702. * Manually render a set of post processes to a texture.
  82703. * @param postProcesses An array of post processes to be run.
  82704. * @param targetTexture The target texture to render to.
  82705. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  82706. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  82707. * @param lodLevel defines which lod of the texture to render to
  82708. */
  82709. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  82710. /**
  82711. * Finalize the result of the output of the postprocesses.
  82712. * @param doNotPresent If true the result will not be displayed to the screen.
  82713. * @param targetTexture The target texture to render to.
  82714. * @param faceIndex The index of the face to bind the target texture to.
  82715. * @param postProcesses The array of post processes to render.
  82716. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  82717. * @hidden
  82718. */
  82719. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  82720. /**
  82721. * Disposes of the post process manager.
  82722. */
  82723. dispose(): void;
  82724. }
  82725. }
  82726. declare module BABYLON {
  82727. /** Interface used by value gradients (color, factor, ...) */
  82728. export interface IValueGradient {
  82729. /**
  82730. * Gets or sets the gradient value (between 0 and 1)
  82731. */
  82732. gradient: number;
  82733. }
  82734. /** Class used to store color4 gradient */
  82735. export class ColorGradient implements IValueGradient {
  82736. /**
  82737. * Gets or sets the gradient value (between 0 and 1)
  82738. */
  82739. gradient: number;
  82740. /**
  82741. * Gets or sets first associated color
  82742. */
  82743. color1: Color4;
  82744. /**
  82745. * Gets or sets second associated color
  82746. */
  82747. color2?: Color4;
  82748. /**
  82749. * Will get a color picked randomly between color1 and color2.
  82750. * If color2 is undefined then color1 will be used
  82751. * @param result defines the target Color4 to store the result in
  82752. */
  82753. getColorToRef(result: Color4): void;
  82754. }
  82755. /** Class used to store color 3 gradient */
  82756. export class Color3Gradient implements IValueGradient {
  82757. /**
  82758. * Gets or sets the gradient value (between 0 and 1)
  82759. */
  82760. gradient: number;
  82761. /**
  82762. * Gets or sets the associated color
  82763. */
  82764. color: Color3;
  82765. }
  82766. /** Class used to store factor gradient */
  82767. export class FactorGradient implements IValueGradient {
  82768. /**
  82769. * Gets or sets the gradient value (between 0 and 1)
  82770. */
  82771. gradient: number;
  82772. /**
  82773. * Gets or sets first associated factor
  82774. */
  82775. factor1: number;
  82776. /**
  82777. * Gets or sets second associated factor
  82778. */
  82779. factor2?: number;
  82780. /**
  82781. * Will get a number picked randomly between factor1 and factor2.
  82782. * If factor2 is undefined then factor1 will be used
  82783. * @returns the picked number
  82784. */
  82785. getFactor(): number;
  82786. }
  82787. /**
  82788. * Helper used to simplify some generic gradient tasks
  82789. */
  82790. export class GradientHelper {
  82791. /**
  82792. * Gets the current gradient from an array of IValueGradient
  82793. * @param ratio defines the current ratio to get
  82794. * @param gradients defines the array of IValueGradient
  82795. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  82796. */
  82797. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  82798. }
  82799. }
  82800. declare module BABYLON {
  82801. interface ThinEngine {
  82802. /**
  82803. * Creates a dynamic texture
  82804. * @param width defines the width of the texture
  82805. * @param height defines the height of the texture
  82806. * @param generateMipMaps defines if the engine should generate the mip levels
  82807. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82808. * @returns the dynamic texture inside an InternalTexture
  82809. */
  82810. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  82811. /**
  82812. * Update the content of a dynamic texture
  82813. * @param texture defines the texture to update
  82814. * @param canvas defines the canvas containing the source
  82815. * @param invertY defines if data must be stored with Y axis inverted
  82816. * @param premulAlpha defines if alpha is stored as premultiplied
  82817. * @param format defines the format of the data
  82818. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  82819. */
  82820. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  82821. }
  82822. }
  82823. declare module BABYLON {
  82824. /**
  82825. * A class extending Texture allowing drawing on a texture
  82826. * @see http://doc.babylonjs.com/how_to/dynamictexture
  82827. */
  82828. export class DynamicTexture extends Texture {
  82829. private _generateMipMaps;
  82830. private _canvas;
  82831. private _context;
  82832. private _engine;
  82833. /**
  82834. * Creates a DynamicTexture
  82835. * @param name defines the name of the texture
  82836. * @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
  82837. * @param scene defines the scene where you want the texture
  82838. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  82839. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82840. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  82841. */
  82842. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  82843. /**
  82844. * Get the current class name of the texture useful for serialization or dynamic coding.
  82845. * @returns "DynamicTexture"
  82846. */
  82847. getClassName(): string;
  82848. /**
  82849. * Gets the current state of canRescale
  82850. */
  82851. readonly canRescale: boolean;
  82852. private _recreate;
  82853. /**
  82854. * Scales the texture
  82855. * @param ratio the scale factor to apply to both width and height
  82856. */
  82857. scale(ratio: number): void;
  82858. /**
  82859. * Resizes the texture
  82860. * @param width the new width
  82861. * @param height the new height
  82862. */
  82863. scaleTo(width: number, height: number): void;
  82864. /**
  82865. * Gets the context of the canvas used by the texture
  82866. * @returns the canvas context of the dynamic texture
  82867. */
  82868. getContext(): CanvasRenderingContext2D;
  82869. /**
  82870. * Clears the texture
  82871. */
  82872. clear(): void;
  82873. /**
  82874. * Updates the texture
  82875. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82876. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  82877. */
  82878. update(invertY?: boolean, premulAlpha?: boolean): void;
  82879. /**
  82880. * Draws text onto the texture
  82881. * @param text defines the text to be drawn
  82882. * @param x defines the placement of the text from the left
  82883. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  82884. * @param font defines the font to be used with font-style, font-size, font-name
  82885. * @param color defines the color used for the text
  82886. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  82887. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82888. * @param update defines whether texture is immediately update (default is true)
  82889. */
  82890. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  82891. /**
  82892. * Clones the texture
  82893. * @returns the clone of the texture.
  82894. */
  82895. clone(): DynamicTexture;
  82896. /**
  82897. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  82898. * @returns a serialized dynamic texture object
  82899. */
  82900. serialize(): any;
  82901. /** @hidden */
  82902. _rebuild(): void;
  82903. }
  82904. }
  82905. declare module BABYLON {
  82906. interface AbstractScene {
  82907. /**
  82908. * The list of procedural textures added to the scene
  82909. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82910. */
  82911. proceduralTextures: Array<ProceduralTexture>;
  82912. }
  82913. /**
  82914. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  82915. * in a given scene.
  82916. */
  82917. export class ProceduralTextureSceneComponent implements ISceneComponent {
  82918. /**
  82919. * The component name helpfull to identify the component in the list of scene components.
  82920. */
  82921. readonly name: string;
  82922. /**
  82923. * The scene the component belongs to.
  82924. */
  82925. scene: Scene;
  82926. /**
  82927. * Creates a new instance of the component for the given scene
  82928. * @param scene Defines the scene to register the component in
  82929. */
  82930. constructor(scene: Scene);
  82931. /**
  82932. * Registers the component in a given scene
  82933. */
  82934. register(): void;
  82935. /**
  82936. * Rebuilds the elements related to this component in case of
  82937. * context lost for instance.
  82938. */
  82939. rebuild(): void;
  82940. /**
  82941. * Disposes the component and the associated ressources.
  82942. */
  82943. dispose(): void;
  82944. private _beforeClear;
  82945. }
  82946. }
  82947. declare module BABYLON {
  82948. interface ThinEngine {
  82949. /**
  82950. * Creates a new render target cube texture
  82951. * @param size defines the size of the texture
  82952. * @param options defines the options used to create the texture
  82953. * @returns a new render target cube texture stored in an InternalTexture
  82954. */
  82955. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  82956. }
  82957. }
  82958. declare module BABYLON {
  82959. /** @hidden */
  82960. export var proceduralVertexShader: {
  82961. name: string;
  82962. shader: string;
  82963. };
  82964. }
  82965. declare module BABYLON {
  82966. /**
  82967. * 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.
  82968. * This is the base class of any Procedural texture and contains most of the shareable code.
  82969. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82970. */
  82971. export class ProceduralTexture extends Texture {
  82972. isCube: boolean;
  82973. /**
  82974. * Define if the texture is enabled or not (disabled texture will not render)
  82975. */
  82976. isEnabled: boolean;
  82977. /**
  82978. * Define if the texture must be cleared before rendering (default is true)
  82979. */
  82980. autoClear: boolean;
  82981. /**
  82982. * Callback called when the texture is generated
  82983. */
  82984. onGenerated: () => void;
  82985. /**
  82986. * Event raised when the texture is generated
  82987. */
  82988. onGeneratedObservable: Observable<ProceduralTexture>;
  82989. /** @hidden */
  82990. _generateMipMaps: boolean;
  82991. /** @hidden **/
  82992. _effect: Effect;
  82993. /** @hidden */
  82994. _textures: {
  82995. [key: string]: Texture;
  82996. };
  82997. private _size;
  82998. private _currentRefreshId;
  82999. private _refreshRate;
  83000. private _vertexBuffers;
  83001. private _indexBuffer;
  83002. private _uniforms;
  83003. private _samplers;
  83004. private _fragment;
  83005. private _floats;
  83006. private _ints;
  83007. private _floatsArrays;
  83008. private _colors3;
  83009. private _colors4;
  83010. private _vectors2;
  83011. private _vectors3;
  83012. private _matrices;
  83013. private _fallbackTexture;
  83014. private _fallbackTextureUsed;
  83015. private _engine;
  83016. private _cachedDefines;
  83017. private _contentUpdateId;
  83018. private _contentData;
  83019. /**
  83020. * Instantiates a new procedural texture.
  83021. * 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.
  83022. * This is the base class of any Procedural texture and contains most of the shareable code.
  83023. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83024. * @param name Define the name of the texture
  83025. * @param size Define the size of the texture to create
  83026. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83027. * @param scene Define the scene the texture belongs to
  83028. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83029. * @param generateMipMaps Define if the texture should creates mip maps or not
  83030. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83031. */
  83032. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83033. /**
  83034. * The effect that is created when initializing the post process.
  83035. * @returns The created effect corresponding the the postprocess.
  83036. */
  83037. getEffect(): Effect;
  83038. /**
  83039. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83040. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83041. */
  83042. getContent(): Nullable<ArrayBufferView>;
  83043. private _createIndexBuffer;
  83044. /** @hidden */
  83045. _rebuild(): void;
  83046. /**
  83047. * Resets the texture in order to recreate its associated resources.
  83048. * This can be called in case of context loss
  83049. */
  83050. reset(): void;
  83051. protected _getDefines(): string;
  83052. /**
  83053. * Is the texture ready to be used ? (rendered at least once)
  83054. * @returns true if ready, otherwise, false.
  83055. */
  83056. isReady(): boolean;
  83057. /**
  83058. * Resets the refresh counter of the texture and start bak from scratch.
  83059. * Could be useful to regenerate the texture if it is setup to render only once.
  83060. */
  83061. resetRefreshCounter(): void;
  83062. /**
  83063. * Set the fragment shader to use in order to render the texture.
  83064. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83065. */
  83066. setFragment(fragment: any): void;
  83067. /**
  83068. * Define the refresh rate of the texture or the rendering frequency.
  83069. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83070. */
  83071. refreshRate: number;
  83072. /** @hidden */
  83073. _shouldRender(): boolean;
  83074. /**
  83075. * Get the size the texture is rendering at.
  83076. * @returns the size (texture is always squared)
  83077. */
  83078. getRenderSize(): number;
  83079. /**
  83080. * Resize the texture to new value.
  83081. * @param size Define the new size the texture should have
  83082. * @param generateMipMaps Define whether the new texture should create mip maps
  83083. */
  83084. resize(size: number, generateMipMaps: boolean): void;
  83085. private _checkUniform;
  83086. /**
  83087. * Set a texture in the shader program used to render.
  83088. * @param name Define the name of the uniform samplers as defined in the shader
  83089. * @param texture Define the texture to bind to this sampler
  83090. * @return the texture itself allowing "fluent" like uniform updates
  83091. */
  83092. setTexture(name: string, texture: Texture): ProceduralTexture;
  83093. /**
  83094. * Set a float in the shader.
  83095. * @param name Define the name of the uniform as defined in the shader
  83096. * @param value Define the value to give to the uniform
  83097. * @return the texture itself allowing "fluent" like uniform updates
  83098. */
  83099. setFloat(name: string, value: number): ProceduralTexture;
  83100. /**
  83101. * Set a int in the shader.
  83102. * @param name Define the name of the uniform as defined in the shader
  83103. * @param value Define the value to give to the uniform
  83104. * @return the texture itself allowing "fluent" like uniform updates
  83105. */
  83106. setInt(name: string, value: number): ProceduralTexture;
  83107. /**
  83108. * Set an array of floats in the shader.
  83109. * @param name Define the name of the uniform as defined in the shader
  83110. * @param value Define the value to give to the uniform
  83111. * @return the texture itself allowing "fluent" like uniform updates
  83112. */
  83113. setFloats(name: string, value: number[]): ProceduralTexture;
  83114. /**
  83115. * Set a vec3 in the shader from a Color3.
  83116. * @param name Define the name of the uniform as defined in the shader
  83117. * @param value Define the value to give to the uniform
  83118. * @return the texture itself allowing "fluent" like uniform updates
  83119. */
  83120. setColor3(name: string, value: Color3): ProceduralTexture;
  83121. /**
  83122. * Set a vec4 in the shader from a Color4.
  83123. * @param name Define the name of the uniform as defined in the shader
  83124. * @param value Define the value to give to the uniform
  83125. * @return the texture itself allowing "fluent" like uniform updates
  83126. */
  83127. setColor4(name: string, value: Color4): ProceduralTexture;
  83128. /**
  83129. * Set a vec2 in the shader from a Vector2.
  83130. * @param name Define the name of the uniform as defined in the shader
  83131. * @param value Define the value to give to the uniform
  83132. * @return the texture itself allowing "fluent" like uniform updates
  83133. */
  83134. setVector2(name: string, value: Vector2): ProceduralTexture;
  83135. /**
  83136. * Set a vec3 in the shader from a Vector3.
  83137. * @param name Define the name of the uniform as defined in the shader
  83138. * @param value Define the value to give to the uniform
  83139. * @return the texture itself allowing "fluent" like uniform updates
  83140. */
  83141. setVector3(name: string, value: Vector3): ProceduralTexture;
  83142. /**
  83143. * Set a mat4 in the shader from a MAtrix.
  83144. * @param name Define the name of the uniform as defined in the shader
  83145. * @param value Define the value to give to the uniform
  83146. * @return the texture itself allowing "fluent" like uniform updates
  83147. */
  83148. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83149. /**
  83150. * Render the texture to its associated render target.
  83151. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83152. */
  83153. render(useCameraPostProcess?: boolean): void;
  83154. /**
  83155. * Clone the texture.
  83156. * @returns the cloned texture
  83157. */
  83158. clone(): ProceduralTexture;
  83159. /**
  83160. * Dispose the texture and release its asoociated resources.
  83161. */
  83162. dispose(): void;
  83163. }
  83164. }
  83165. declare module BABYLON {
  83166. /**
  83167. * This represents the base class for particle system in Babylon.
  83168. * 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.
  83169. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83170. * @example https://doc.babylonjs.com/babylon101/particles
  83171. */
  83172. export class BaseParticleSystem {
  83173. /**
  83174. * Source color is added to the destination color without alpha affecting the result
  83175. */
  83176. static BLENDMODE_ONEONE: number;
  83177. /**
  83178. * Blend current color and particle color using particle’s alpha
  83179. */
  83180. static BLENDMODE_STANDARD: number;
  83181. /**
  83182. * Add current color and particle color multiplied by particle’s alpha
  83183. */
  83184. static BLENDMODE_ADD: number;
  83185. /**
  83186. * Multiply current color with particle color
  83187. */
  83188. static BLENDMODE_MULTIPLY: number;
  83189. /**
  83190. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83191. */
  83192. static BLENDMODE_MULTIPLYADD: number;
  83193. /**
  83194. * List of animations used by the particle system.
  83195. */
  83196. animations: Animation[];
  83197. /**
  83198. * The id of the Particle system.
  83199. */
  83200. id: string;
  83201. /**
  83202. * The friendly name of the Particle system.
  83203. */
  83204. name: string;
  83205. /**
  83206. * The rendering group used by the Particle system to chose when to render.
  83207. */
  83208. renderingGroupId: number;
  83209. /**
  83210. * The emitter represents the Mesh or position we are attaching the particle system to.
  83211. */
  83212. emitter: Nullable<AbstractMesh | Vector3>;
  83213. /**
  83214. * The maximum number of particles to emit per frame
  83215. */
  83216. emitRate: number;
  83217. /**
  83218. * If you want to launch only a few particles at once, that can be done, as well.
  83219. */
  83220. manualEmitCount: number;
  83221. /**
  83222. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83223. */
  83224. updateSpeed: number;
  83225. /**
  83226. * The amount of time the particle system is running (depends of the overall update speed).
  83227. */
  83228. targetStopDuration: number;
  83229. /**
  83230. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83231. */
  83232. disposeOnStop: boolean;
  83233. /**
  83234. * Minimum power of emitting particles.
  83235. */
  83236. minEmitPower: number;
  83237. /**
  83238. * Maximum power of emitting particles.
  83239. */
  83240. maxEmitPower: number;
  83241. /**
  83242. * Minimum life time of emitting particles.
  83243. */
  83244. minLifeTime: number;
  83245. /**
  83246. * Maximum life time of emitting particles.
  83247. */
  83248. maxLifeTime: number;
  83249. /**
  83250. * Minimum Size of emitting particles.
  83251. */
  83252. minSize: number;
  83253. /**
  83254. * Maximum Size of emitting particles.
  83255. */
  83256. maxSize: number;
  83257. /**
  83258. * Minimum scale of emitting particles on X axis.
  83259. */
  83260. minScaleX: number;
  83261. /**
  83262. * Maximum scale of emitting particles on X axis.
  83263. */
  83264. maxScaleX: number;
  83265. /**
  83266. * Minimum scale of emitting particles on Y axis.
  83267. */
  83268. minScaleY: number;
  83269. /**
  83270. * Maximum scale of emitting particles on Y axis.
  83271. */
  83272. maxScaleY: number;
  83273. /**
  83274. * Gets or sets the minimal initial rotation in radians.
  83275. */
  83276. minInitialRotation: number;
  83277. /**
  83278. * Gets or sets the maximal initial rotation in radians.
  83279. */
  83280. maxInitialRotation: number;
  83281. /**
  83282. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83283. */
  83284. minAngularSpeed: number;
  83285. /**
  83286. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83287. */
  83288. maxAngularSpeed: number;
  83289. /**
  83290. * The texture used to render each particle. (this can be a spritesheet)
  83291. */
  83292. particleTexture: Nullable<Texture>;
  83293. /**
  83294. * The layer mask we are rendering the particles through.
  83295. */
  83296. layerMask: number;
  83297. /**
  83298. * This can help using your own shader to render the particle system.
  83299. * The according effect will be created
  83300. */
  83301. customShader: any;
  83302. /**
  83303. * By default particle system starts as soon as they are created. This prevents the
  83304. * automatic start to happen and let you decide when to start emitting particles.
  83305. */
  83306. preventAutoStart: boolean;
  83307. private _noiseTexture;
  83308. /**
  83309. * Gets or sets a texture used to add random noise to particle positions
  83310. */
  83311. noiseTexture: Nullable<ProceduralTexture>;
  83312. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83313. noiseStrength: Vector3;
  83314. /**
  83315. * Callback triggered when the particle animation is ending.
  83316. */
  83317. onAnimationEnd: Nullable<() => void>;
  83318. /**
  83319. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83320. */
  83321. blendMode: number;
  83322. /**
  83323. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83324. * to override the particles.
  83325. */
  83326. forceDepthWrite: boolean;
  83327. /** 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 */
  83328. preWarmCycles: number;
  83329. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83330. preWarmStepOffset: number;
  83331. /**
  83332. * 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)
  83333. */
  83334. spriteCellChangeSpeed: number;
  83335. /**
  83336. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83337. */
  83338. startSpriteCellID: number;
  83339. /**
  83340. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83341. */
  83342. endSpriteCellID: number;
  83343. /**
  83344. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83345. */
  83346. spriteCellWidth: number;
  83347. /**
  83348. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83349. */
  83350. spriteCellHeight: number;
  83351. /**
  83352. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83353. */
  83354. spriteRandomStartCell: boolean;
  83355. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83356. translationPivot: Vector2;
  83357. /** @hidden */
  83358. protected _isAnimationSheetEnabled: boolean;
  83359. /**
  83360. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83361. */
  83362. beginAnimationOnStart: boolean;
  83363. /**
  83364. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83365. */
  83366. beginAnimationFrom: number;
  83367. /**
  83368. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83369. */
  83370. beginAnimationTo: number;
  83371. /**
  83372. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83373. */
  83374. beginAnimationLoop: boolean;
  83375. /**
  83376. * Gets or sets a world offset applied to all particles
  83377. */
  83378. worldOffset: Vector3;
  83379. /**
  83380. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  83381. */
  83382. isAnimationSheetEnabled: boolean;
  83383. /**
  83384. * Get hosting scene
  83385. * @returns the scene
  83386. */
  83387. getScene(): Scene;
  83388. /**
  83389. * You can use gravity if you want to give an orientation to your particles.
  83390. */
  83391. gravity: Vector3;
  83392. protected _colorGradients: Nullable<Array<ColorGradient>>;
  83393. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  83394. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  83395. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  83396. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  83397. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  83398. protected _dragGradients: Nullable<Array<FactorGradient>>;
  83399. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  83400. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  83401. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  83402. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  83403. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  83404. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  83405. /**
  83406. * Defines the delay in milliseconds before starting the system (0 by default)
  83407. */
  83408. startDelay: number;
  83409. /**
  83410. * Gets the current list of drag gradients.
  83411. * You must use addDragGradient and removeDragGradient to udpate this list
  83412. * @returns the list of drag gradients
  83413. */
  83414. getDragGradients(): Nullable<Array<FactorGradient>>;
  83415. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83416. limitVelocityDamping: number;
  83417. /**
  83418. * Gets the current list of limit velocity gradients.
  83419. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83420. * @returns the list of limit velocity gradients
  83421. */
  83422. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83423. /**
  83424. * Gets the current list of color gradients.
  83425. * You must use addColorGradient and removeColorGradient to udpate this list
  83426. * @returns the list of color gradients
  83427. */
  83428. getColorGradients(): Nullable<Array<ColorGradient>>;
  83429. /**
  83430. * Gets the current list of size gradients.
  83431. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83432. * @returns the list of size gradients
  83433. */
  83434. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83435. /**
  83436. * Gets the current list of color remap gradients.
  83437. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83438. * @returns the list of color remap gradients
  83439. */
  83440. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83441. /**
  83442. * Gets the current list of alpha remap gradients.
  83443. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83444. * @returns the list of alpha remap gradients
  83445. */
  83446. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83447. /**
  83448. * Gets the current list of life time gradients.
  83449. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83450. * @returns the list of life time gradients
  83451. */
  83452. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83453. /**
  83454. * Gets the current list of angular speed gradients.
  83455. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83456. * @returns the list of angular speed gradients
  83457. */
  83458. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83459. /**
  83460. * Gets the current list of velocity gradients.
  83461. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83462. * @returns the list of velocity gradients
  83463. */
  83464. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83465. /**
  83466. * Gets the current list of start size gradients.
  83467. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83468. * @returns the list of start size gradients
  83469. */
  83470. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83471. /**
  83472. * Gets the current list of emit rate gradients.
  83473. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83474. * @returns the list of emit rate gradients
  83475. */
  83476. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83477. /**
  83478. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83479. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83480. */
  83481. direction1: Vector3;
  83482. /**
  83483. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83484. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83485. */
  83486. direction2: Vector3;
  83487. /**
  83488. * 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.
  83489. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83490. */
  83491. minEmitBox: Vector3;
  83492. /**
  83493. * 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.
  83494. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83495. */
  83496. maxEmitBox: Vector3;
  83497. /**
  83498. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83499. */
  83500. color1: Color4;
  83501. /**
  83502. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83503. */
  83504. color2: Color4;
  83505. /**
  83506. * Color the particle will have at the end of its lifetime
  83507. */
  83508. colorDead: Color4;
  83509. /**
  83510. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  83511. */
  83512. textureMask: Color4;
  83513. /**
  83514. * The particle emitter type defines the emitter used by the particle system.
  83515. * It can be for example box, sphere, or cone...
  83516. */
  83517. particleEmitterType: IParticleEmitterType;
  83518. /** @hidden */
  83519. _isSubEmitter: boolean;
  83520. /**
  83521. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83522. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83523. */
  83524. billboardMode: number;
  83525. protected _isBillboardBased: boolean;
  83526. /**
  83527. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83528. */
  83529. isBillboardBased: boolean;
  83530. /**
  83531. * The scene the particle system belongs to.
  83532. */
  83533. protected _scene: Scene;
  83534. /**
  83535. * Local cache of defines for image processing.
  83536. */
  83537. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  83538. /**
  83539. * Default configuration related to image processing available in the standard Material.
  83540. */
  83541. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  83542. /**
  83543. * Gets the image processing configuration used either in this material.
  83544. */
  83545. /**
  83546. * Sets the Default image processing configuration used either in the this material.
  83547. *
  83548. * If sets to null, the scene one is in use.
  83549. */
  83550. imageProcessingConfiguration: ImageProcessingConfiguration;
  83551. /**
  83552. * Attaches a new image processing configuration to the Standard Material.
  83553. * @param configuration
  83554. */
  83555. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  83556. /** @hidden */
  83557. protected _reset(): void;
  83558. /** @hidden */
  83559. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  83560. /**
  83561. * Instantiates a particle system.
  83562. * 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.
  83563. * @param name The name of the particle system
  83564. */
  83565. constructor(name: string);
  83566. /**
  83567. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83568. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83569. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83570. * @returns the emitter
  83571. */
  83572. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83573. /**
  83574. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83575. * @param radius The radius of the hemisphere to emit from
  83576. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83577. * @returns the emitter
  83578. */
  83579. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  83580. /**
  83581. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83582. * @param radius The radius of the sphere to emit from
  83583. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83584. * @returns the emitter
  83585. */
  83586. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  83587. /**
  83588. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83589. * @param radius The radius of the sphere to emit from
  83590. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83591. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83592. * @returns the emitter
  83593. */
  83594. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  83595. /**
  83596. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83597. * @param radius The radius of the emission cylinder
  83598. * @param height The height of the emission cylinder
  83599. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83600. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83601. * @returns the emitter
  83602. */
  83603. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  83604. /**
  83605. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83606. * @param radius The radius of the cylinder to emit from
  83607. * @param height The height of the emission cylinder
  83608. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83609. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83610. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83611. * @returns the emitter
  83612. */
  83613. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  83614. /**
  83615. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83616. * @param radius The radius of the cone to emit from
  83617. * @param angle The base angle of the cone
  83618. * @returns the emitter
  83619. */
  83620. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  83621. /**
  83622. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83623. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83624. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83625. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83626. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83627. * @returns the emitter
  83628. */
  83629. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83630. }
  83631. }
  83632. declare module BABYLON {
  83633. /**
  83634. * Type of sub emitter
  83635. */
  83636. export enum SubEmitterType {
  83637. /**
  83638. * Attached to the particle over it's lifetime
  83639. */
  83640. ATTACHED = 0,
  83641. /**
  83642. * Created when the particle dies
  83643. */
  83644. END = 1
  83645. }
  83646. /**
  83647. * Sub emitter class used to emit particles from an existing particle
  83648. */
  83649. export class SubEmitter {
  83650. /**
  83651. * the particle system to be used by the sub emitter
  83652. */
  83653. particleSystem: ParticleSystem;
  83654. /**
  83655. * Type of the submitter (Default: END)
  83656. */
  83657. type: SubEmitterType;
  83658. /**
  83659. * 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)
  83660. * Note: This only is supported when using an emitter of type Mesh
  83661. */
  83662. inheritDirection: boolean;
  83663. /**
  83664. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  83665. */
  83666. inheritedVelocityAmount: number;
  83667. /**
  83668. * Creates a sub emitter
  83669. * @param particleSystem the particle system to be used by the sub emitter
  83670. */
  83671. constructor(
  83672. /**
  83673. * the particle system to be used by the sub emitter
  83674. */
  83675. particleSystem: ParticleSystem);
  83676. /**
  83677. * Clones the sub emitter
  83678. * @returns the cloned sub emitter
  83679. */
  83680. clone(): SubEmitter;
  83681. /**
  83682. * Serialize current object to a JSON object
  83683. * @returns the serialized object
  83684. */
  83685. serialize(): any;
  83686. /** @hidden */
  83687. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  83688. /**
  83689. * Creates a new SubEmitter from a serialized JSON version
  83690. * @param serializationObject defines the JSON object to read from
  83691. * @param scene defines the hosting scene
  83692. * @param rootUrl defines the rootUrl for data loading
  83693. * @returns a new SubEmitter
  83694. */
  83695. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  83696. /** Release associated resources */
  83697. dispose(): void;
  83698. }
  83699. }
  83700. declare module BABYLON {
  83701. /** @hidden */
  83702. export var clipPlaneFragmentDeclaration: {
  83703. name: string;
  83704. shader: string;
  83705. };
  83706. }
  83707. declare module BABYLON {
  83708. /** @hidden */
  83709. export var imageProcessingDeclaration: {
  83710. name: string;
  83711. shader: string;
  83712. };
  83713. }
  83714. declare module BABYLON {
  83715. /** @hidden */
  83716. export var imageProcessingFunctions: {
  83717. name: string;
  83718. shader: string;
  83719. };
  83720. }
  83721. declare module BABYLON {
  83722. /** @hidden */
  83723. export var clipPlaneFragment: {
  83724. name: string;
  83725. shader: string;
  83726. };
  83727. }
  83728. declare module BABYLON {
  83729. /** @hidden */
  83730. export var particlesPixelShader: {
  83731. name: string;
  83732. shader: string;
  83733. };
  83734. }
  83735. declare module BABYLON {
  83736. /** @hidden */
  83737. export var clipPlaneVertexDeclaration: {
  83738. name: string;
  83739. shader: string;
  83740. };
  83741. }
  83742. declare module BABYLON {
  83743. /** @hidden */
  83744. export var clipPlaneVertex: {
  83745. name: string;
  83746. shader: string;
  83747. };
  83748. }
  83749. declare module BABYLON {
  83750. /** @hidden */
  83751. export var particlesVertexShader: {
  83752. name: string;
  83753. shader: string;
  83754. };
  83755. }
  83756. declare module BABYLON {
  83757. /**
  83758. * This represents a particle system in Babylon.
  83759. * 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.
  83760. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83761. * @example https://doc.babylonjs.com/babylon101/particles
  83762. */
  83763. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  83764. /**
  83765. * Billboard mode will only apply to Y axis
  83766. */
  83767. static readonly BILLBOARDMODE_Y: number;
  83768. /**
  83769. * Billboard mode will apply to all axes
  83770. */
  83771. static readonly BILLBOARDMODE_ALL: number;
  83772. /**
  83773. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  83774. */
  83775. static readonly BILLBOARDMODE_STRETCHED: number;
  83776. /**
  83777. * This function can be defined to provide custom update for active particles.
  83778. * This function will be called instead of regular update (age, position, color, etc.).
  83779. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  83780. */
  83781. updateFunction: (particles: Particle[]) => void;
  83782. private _emitterWorldMatrix;
  83783. /**
  83784. * This function can be defined to specify initial direction for every new particle.
  83785. * It by default use the emitterType defined function
  83786. */
  83787. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  83788. /**
  83789. * This function can be defined to specify initial position for every new particle.
  83790. * It by default use the emitterType defined function
  83791. */
  83792. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  83793. /**
  83794. * @hidden
  83795. */
  83796. _inheritedVelocityOffset: Vector3;
  83797. /**
  83798. * An event triggered when the system is disposed
  83799. */
  83800. onDisposeObservable: Observable<ParticleSystem>;
  83801. private _onDisposeObserver;
  83802. /**
  83803. * Sets a callback that will be triggered when the system is disposed
  83804. */
  83805. onDispose: () => void;
  83806. private _particles;
  83807. private _epsilon;
  83808. private _capacity;
  83809. private _stockParticles;
  83810. private _newPartsExcess;
  83811. private _vertexData;
  83812. private _vertexBuffer;
  83813. private _vertexBuffers;
  83814. private _spriteBuffer;
  83815. private _indexBuffer;
  83816. private _effect;
  83817. private _customEffect;
  83818. private _cachedDefines;
  83819. private _scaledColorStep;
  83820. private _colorDiff;
  83821. private _scaledDirection;
  83822. private _scaledGravity;
  83823. private _currentRenderId;
  83824. private _alive;
  83825. private _useInstancing;
  83826. private _started;
  83827. private _stopped;
  83828. private _actualFrame;
  83829. private _scaledUpdateSpeed;
  83830. private _vertexBufferSize;
  83831. /** @hidden */
  83832. _currentEmitRateGradient: Nullable<FactorGradient>;
  83833. /** @hidden */
  83834. _currentEmitRate1: number;
  83835. /** @hidden */
  83836. _currentEmitRate2: number;
  83837. /** @hidden */
  83838. _currentStartSizeGradient: Nullable<FactorGradient>;
  83839. /** @hidden */
  83840. _currentStartSize1: number;
  83841. /** @hidden */
  83842. _currentStartSize2: number;
  83843. private readonly _rawTextureWidth;
  83844. private _rampGradientsTexture;
  83845. private _useRampGradients;
  83846. /** Gets or sets a boolean indicating that ramp gradients must be used
  83847. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83848. */
  83849. useRampGradients: boolean;
  83850. /**
  83851. * 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.
  83852. * 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: [])
  83853. */
  83854. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  83855. private _subEmitters;
  83856. /**
  83857. * @hidden
  83858. * If the particle systems emitter should be disposed when the particle system is disposed
  83859. */
  83860. _disposeEmitterOnDispose: boolean;
  83861. /**
  83862. * The current active Sub-systems, this property is used by the root particle system only.
  83863. */
  83864. activeSubSystems: Array<ParticleSystem>;
  83865. private _rootParticleSystem;
  83866. /**
  83867. * Gets the current list of active particles
  83868. */
  83869. readonly particles: Particle[];
  83870. /**
  83871. * Returns the string "ParticleSystem"
  83872. * @returns a string containing the class name
  83873. */
  83874. getClassName(): string;
  83875. /**
  83876. * Instantiates a particle system.
  83877. * 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.
  83878. * @param name The name of the particle system
  83879. * @param capacity The max number of particles alive at the same time
  83880. * @param scene The scene the particle system belongs to
  83881. * @param customEffect a custom effect used to change the way particles are rendered by default
  83882. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  83883. * @param epsilon Offset used to render the particles
  83884. */
  83885. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  83886. private _addFactorGradient;
  83887. private _removeFactorGradient;
  83888. /**
  83889. * Adds a new life time gradient
  83890. * @param gradient defines the gradient to use (between 0 and 1)
  83891. * @param factor defines the life time factor to affect to the specified gradient
  83892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83893. * @returns the current particle system
  83894. */
  83895. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83896. /**
  83897. * Remove a specific life time gradient
  83898. * @param gradient defines the gradient to remove
  83899. * @returns the current particle system
  83900. */
  83901. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83902. /**
  83903. * Adds a new size gradient
  83904. * @param gradient defines the gradient to use (between 0 and 1)
  83905. * @param factor defines the size factor to affect to the specified gradient
  83906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83907. * @returns the current particle system
  83908. */
  83909. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83910. /**
  83911. * Remove a specific size gradient
  83912. * @param gradient defines the gradient to remove
  83913. * @returns the current particle system
  83914. */
  83915. removeSizeGradient(gradient: number): IParticleSystem;
  83916. /**
  83917. * Adds a new color remap gradient
  83918. * @param gradient defines the gradient to use (between 0 and 1)
  83919. * @param min defines the color remap minimal range
  83920. * @param max defines the color remap maximal range
  83921. * @returns the current particle system
  83922. */
  83923. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83924. /**
  83925. * Remove a specific color remap gradient
  83926. * @param gradient defines the gradient to remove
  83927. * @returns the current particle system
  83928. */
  83929. removeColorRemapGradient(gradient: number): IParticleSystem;
  83930. /**
  83931. * Adds a new alpha remap gradient
  83932. * @param gradient defines the gradient to use (between 0 and 1)
  83933. * @param min defines the alpha remap minimal range
  83934. * @param max defines the alpha remap maximal range
  83935. * @returns the current particle system
  83936. */
  83937. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83938. /**
  83939. * Remove a specific alpha remap gradient
  83940. * @param gradient defines the gradient to remove
  83941. * @returns the current particle system
  83942. */
  83943. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  83944. /**
  83945. * Adds a new angular speed gradient
  83946. * @param gradient defines the gradient to use (between 0 and 1)
  83947. * @param factor defines the angular speed to affect to the specified gradient
  83948. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83949. * @returns the current particle system
  83950. */
  83951. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83952. /**
  83953. * Remove a specific angular speed gradient
  83954. * @param gradient defines the gradient to remove
  83955. * @returns the current particle system
  83956. */
  83957. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83958. /**
  83959. * Adds a new velocity gradient
  83960. * @param gradient defines the gradient to use (between 0 and 1)
  83961. * @param factor defines the velocity to affect to the specified gradient
  83962. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83963. * @returns the current particle system
  83964. */
  83965. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83966. /**
  83967. * Remove a specific velocity gradient
  83968. * @param gradient defines the gradient to remove
  83969. * @returns the current particle system
  83970. */
  83971. removeVelocityGradient(gradient: number): IParticleSystem;
  83972. /**
  83973. * Adds a new limit velocity gradient
  83974. * @param gradient defines the gradient to use (between 0 and 1)
  83975. * @param factor defines the limit velocity value to affect to the specified gradient
  83976. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83977. * @returns the current particle system
  83978. */
  83979. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83980. /**
  83981. * Remove a specific limit velocity gradient
  83982. * @param gradient defines the gradient to remove
  83983. * @returns the current particle system
  83984. */
  83985. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83986. /**
  83987. * Adds a new drag gradient
  83988. * @param gradient defines the gradient to use (between 0 and 1)
  83989. * @param factor defines the drag value to affect to the specified gradient
  83990. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83991. * @returns the current particle system
  83992. */
  83993. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83994. /**
  83995. * Remove a specific drag gradient
  83996. * @param gradient defines the gradient to remove
  83997. * @returns the current particle system
  83998. */
  83999. removeDragGradient(gradient: number): IParticleSystem;
  84000. /**
  84001. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84002. * @param gradient defines the gradient to use (between 0 and 1)
  84003. * @param factor defines the emit rate value to affect to the specified gradient
  84004. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84005. * @returns the current particle system
  84006. */
  84007. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84008. /**
  84009. * Remove a specific emit rate gradient
  84010. * @param gradient defines the gradient to remove
  84011. * @returns the current particle system
  84012. */
  84013. removeEmitRateGradient(gradient: number): IParticleSystem;
  84014. /**
  84015. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84016. * @param gradient defines the gradient to use (between 0 and 1)
  84017. * @param factor defines the start size value to affect to the specified gradient
  84018. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84019. * @returns the current particle system
  84020. */
  84021. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84022. /**
  84023. * Remove a specific start size gradient
  84024. * @param gradient defines the gradient to remove
  84025. * @returns the current particle system
  84026. */
  84027. removeStartSizeGradient(gradient: number): IParticleSystem;
  84028. private _createRampGradientTexture;
  84029. /**
  84030. * Gets the current list of ramp gradients.
  84031. * You must use addRampGradient and removeRampGradient to udpate this list
  84032. * @returns the list of ramp gradients
  84033. */
  84034. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84035. /**
  84036. * Adds a new ramp gradient used to remap particle colors
  84037. * @param gradient defines the gradient to use (between 0 and 1)
  84038. * @param color defines the color to affect to the specified gradient
  84039. * @returns the current particle system
  84040. */
  84041. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84042. /**
  84043. * Remove a specific ramp gradient
  84044. * @param gradient defines the gradient to remove
  84045. * @returns the current particle system
  84046. */
  84047. removeRampGradient(gradient: number): ParticleSystem;
  84048. /**
  84049. * Adds a new color gradient
  84050. * @param gradient defines the gradient to use (between 0 and 1)
  84051. * @param color1 defines the color to affect to the specified gradient
  84052. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84053. * @returns this particle system
  84054. */
  84055. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84056. /**
  84057. * Remove a specific color gradient
  84058. * @param gradient defines the gradient to remove
  84059. * @returns this particle system
  84060. */
  84061. removeColorGradient(gradient: number): IParticleSystem;
  84062. private _fetchR;
  84063. protected _reset(): void;
  84064. private _resetEffect;
  84065. private _createVertexBuffers;
  84066. private _createIndexBuffer;
  84067. /**
  84068. * Gets the maximum number of particles active at the same time.
  84069. * @returns The max number of active particles.
  84070. */
  84071. getCapacity(): number;
  84072. /**
  84073. * Gets whether there are still active particles in the system.
  84074. * @returns True if it is alive, otherwise false.
  84075. */
  84076. isAlive(): boolean;
  84077. /**
  84078. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84079. * @returns True if it has been started, otherwise false.
  84080. */
  84081. isStarted(): boolean;
  84082. private _prepareSubEmitterInternalArray;
  84083. /**
  84084. * Starts the particle system and begins to emit
  84085. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84086. */
  84087. start(delay?: number): void;
  84088. /**
  84089. * Stops the particle system.
  84090. * @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.
  84091. */
  84092. stop(stopSubEmitters?: boolean): void;
  84093. /**
  84094. * Remove all active particles
  84095. */
  84096. reset(): void;
  84097. /**
  84098. * @hidden (for internal use only)
  84099. */
  84100. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84101. /**
  84102. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84103. * Its lifetime will start back at 0.
  84104. */
  84105. recycleParticle: (particle: Particle) => void;
  84106. private _stopSubEmitters;
  84107. private _createParticle;
  84108. private _removeFromRoot;
  84109. private _emitFromParticle;
  84110. private _update;
  84111. /** @hidden */
  84112. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84113. /** @hidden */
  84114. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84115. /** @hidden */
  84116. private _getEffect;
  84117. /**
  84118. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84119. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84120. */
  84121. animate(preWarmOnly?: boolean): void;
  84122. private _appendParticleVertices;
  84123. /**
  84124. * Rebuilds the particle system.
  84125. */
  84126. rebuild(): void;
  84127. /**
  84128. * Is this system ready to be used/rendered
  84129. * @return true if the system is ready
  84130. */
  84131. isReady(): boolean;
  84132. private _render;
  84133. /**
  84134. * Renders the particle system in its current state.
  84135. * @returns the current number of particles
  84136. */
  84137. render(): number;
  84138. /**
  84139. * Disposes the particle system and free the associated resources
  84140. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84141. */
  84142. dispose(disposeTexture?: boolean): void;
  84143. /**
  84144. * Clones the particle system.
  84145. * @param name The name of the cloned object
  84146. * @param newEmitter The new emitter to use
  84147. * @returns the cloned particle system
  84148. */
  84149. clone(name: string, newEmitter: any): ParticleSystem;
  84150. /**
  84151. * Serializes the particle system to a JSON object.
  84152. * @returns the JSON object
  84153. */
  84154. serialize(): any;
  84155. /** @hidden */
  84156. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84157. /** @hidden */
  84158. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84159. /**
  84160. * Parses a JSON object to create a particle system.
  84161. * @param parsedParticleSystem The JSON object to parse
  84162. * @param scene The scene to create the particle system in
  84163. * @param rootUrl The root url to use to load external dependencies like texture
  84164. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84165. * @returns the Parsed particle system
  84166. */
  84167. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84168. }
  84169. }
  84170. declare module BABYLON {
  84171. /**
  84172. * A particle represents one of the element emitted by a particle system.
  84173. * This is mainly define by its coordinates, direction, velocity and age.
  84174. */
  84175. export class Particle {
  84176. /**
  84177. * The particle system the particle belongs to.
  84178. */
  84179. particleSystem: ParticleSystem;
  84180. private static _Count;
  84181. /**
  84182. * Unique ID of the particle
  84183. */
  84184. id: number;
  84185. /**
  84186. * The world position of the particle in the scene.
  84187. */
  84188. position: Vector3;
  84189. /**
  84190. * The world direction of the particle in the scene.
  84191. */
  84192. direction: Vector3;
  84193. /**
  84194. * The color of the particle.
  84195. */
  84196. color: Color4;
  84197. /**
  84198. * The color change of the particle per step.
  84199. */
  84200. colorStep: Color4;
  84201. /**
  84202. * Defines how long will the life of the particle be.
  84203. */
  84204. lifeTime: number;
  84205. /**
  84206. * The current age of the particle.
  84207. */
  84208. age: number;
  84209. /**
  84210. * The current size of the particle.
  84211. */
  84212. size: number;
  84213. /**
  84214. * The current scale of the particle.
  84215. */
  84216. scale: Vector2;
  84217. /**
  84218. * The current angle of the particle.
  84219. */
  84220. angle: number;
  84221. /**
  84222. * Defines how fast is the angle changing.
  84223. */
  84224. angularSpeed: number;
  84225. /**
  84226. * Defines the cell index used by the particle to be rendered from a sprite.
  84227. */
  84228. cellIndex: number;
  84229. /**
  84230. * The information required to support color remapping
  84231. */
  84232. remapData: Vector4;
  84233. /** @hidden */
  84234. _randomCellOffset?: number;
  84235. /** @hidden */
  84236. _initialDirection: Nullable<Vector3>;
  84237. /** @hidden */
  84238. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84239. /** @hidden */
  84240. _initialStartSpriteCellID: number;
  84241. /** @hidden */
  84242. _initialEndSpriteCellID: number;
  84243. /** @hidden */
  84244. _currentColorGradient: Nullable<ColorGradient>;
  84245. /** @hidden */
  84246. _currentColor1: Color4;
  84247. /** @hidden */
  84248. _currentColor2: Color4;
  84249. /** @hidden */
  84250. _currentSizeGradient: Nullable<FactorGradient>;
  84251. /** @hidden */
  84252. _currentSize1: number;
  84253. /** @hidden */
  84254. _currentSize2: number;
  84255. /** @hidden */
  84256. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84257. /** @hidden */
  84258. _currentAngularSpeed1: number;
  84259. /** @hidden */
  84260. _currentAngularSpeed2: number;
  84261. /** @hidden */
  84262. _currentVelocityGradient: Nullable<FactorGradient>;
  84263. /** @hidden */
  84264. _currentVelocity1: number;
  84265. /** @hidden */
  84266. _currentVelocity2: number;
  84267. /** @hidden */
  84268. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84269. /** @hidden */
  84270. _currentLimitVelocity1: number;
  84271. /** @hidden */
  84272. _currentLimitVelocity2: number;
  84273. /** @hidden */
  84274. _currentDragGradient: Nullable<FactorGradient>;
  84275. /** @hidden */
  84276. _currentDrag1: number;
  84277. /** @hidden */
  84278. _currentDrag2: number;
  84279. /** @hidden */
  84280. _randomNoiseCoordinates1: Vector3;
  84281. /** @hidden */
  84282. _randomNoiseCoordinates2: Vector3;
  84283. /**
  84284. * Creates a new instance Particle
  84285. * @param particleSystem the particle system the particle belongs to
  84286. */
  84287. constructor(
  84288. /**
  84289. * The particle system the particle belongs to.
  84290. */
  84291. particleSystem: ParticleSystem);
  84292. private updateCellInfoFromSystem;
  84293. /**
  84294. * Defines how the sprite cell index is updated for the particle
  84295. */
  84296. updateCellIndex(): void;
  84297. /** @hidden */
  84298. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84299. /** @hidden */
  84300. _inheritParticleInfoToSubEmitters(): void;
  84301. /** @hidden */
  84302. _reset(): void;
  84303. /**
  84304. * Copy the properties of particle to another one.
  84305. * @param other the particle to copy the information to.
  84306. */
  84307. copyTo(other: Particle): void;
  84308. }
  84309. }
  84310. declare module BABYLON {
  84311. /**
  84312. * Particle emitter represents a volume emitting particles.
  84313. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84314. */
  84315. export interface IParticleEmitterType {
  84316. /**
  84317. * Called by the particle System when the direction is computed for the created particle.
  84318. * @param worldMatrix is the world matrix of the particle system
  84319. * @param directionToUpdate is the direction vector to update with the result
  84320. * @param particle is the particle we are computed the direction for
  84321. */
  84322. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84323. /**
  84324. * Called by the particle System when the position is computed for the created particle.
  84325. * @param worldMatrix is the world matrix of the particle system
  84326. * @param positionToUpdate is the position vector to update with the result
  84327. * @param particle is the particle we are computed the position for
  84328. */
  84329. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84330. /**
  84331. * Clones the current emitter and returns a copy of it
  84332. * @returns the new emitter
  84333. */
  84334. clone(): IParticleEmitterType;
  84335. /**
  84336. * Called by the GPUParticleSystem to setup the update shader
  84337. * @param effect defines the update shader
  84338. */
  84339. applyToShader(effect: Effect): void;
  84340. /**
  84341. * Returns a string to use to update the GPU particles update shader
  84342. * @returns the effect defines string
  84343. */
  84344. getEffectDefines(): string;
  84345. /**
  84346. * Returns a string representing the class name
  84347. * @returns a string containing the class name
  84348. */
  84349. getClassName(): string;
  84350. /**
  84351. * Serializes the particle system to a JSON object.
  84352. * @returns the JSON object
  84353. */
  84354. serialize(): any;
  84355. /**
  84356. * Parse properties from a JSON object
  84357. * @param serializationObject defines the JSON object
  84358. */
  84359. parse(serializationObject: any): void;
  84360. }
  84361. }
  84362. declare module BABYLON {
  84363. /**
  84364. * Particle emitter emitting particles from the inside of a box.
  84365. * It emits the particles randomly between 2 given directions.
  84366. */
  84367. export class BoxParticleEmitter implements IParticleEmitterType {
  84368. /**
  84369. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84370. */
  84371. direction1: Vector3;
  84372. /**
  84373. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84374. */
  84375. direction2: Vector3;
  84376. /**
  84377. * 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.
  84378. */
  84379. minEmitBox: Vector3;
  84380. /**
  84381. * 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.
  84382. */
  84383. maxEmitBox: Vector3;
  84384. /**
  84385. * Creates a new instance BoxParticleEmitter
  84386. */
  84387. constructor();
  84388. /**
  84389. * Called by the particle System when the direction is computed for the created particle.
  84390. * @param worldMatrix is the world matrix of the particle system
  84391. * @param directionToUpdate is the direction vector to update with the result
  84392. * @param particle is the particle we are computed the direction for
  84393. */
  84394. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84395. /**
  84396. * Called by the particle System when the position is computed for the created particle.
  84397. * @param worldMatrix is the world matrix of the particle system
  84398. * @param positionToUpdate is the position vector to update with the result
  84399. * @param particle is the particle we are computed the position for
  84400. */
  84401. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84402. /**
  84403. * Clones the current emitter and returns a copy of it
  84404. * @returns the new emitter
  84405. */
  84406. clone(): BoxParticleEmitter;
  84407. /**
  84408. * Called by the GPUParticleSystem to setup the update shader
  84409. * @param effect defines the update shader
  84410. */
  84411. applyToShader(effect: Effect): void;
  84412. /**
  84413. * Returns a string to use to update the GPU particles update shader
  84414. * @returns a string containng the defines string
  84415. */
  84416. getEffectDefines(): string;
  84417. /**
  84418. * Returns the string "BoxParticleEmitter"
  84419. * @returns a string containing the class name
  84420. */
  84421. getClassName(): string;
  84422. /**
  84423. * Serializes the particle system to a JSON object.
  84424. * @returns the JSON object
  84425. */
  84426. serialize(): any;
  84427. /**
  84428. * Parse properties from a JSON object
  84429. * @param serializationObject defines the JSON object
  84430. */
  84431. parse(serializationObject: any): void;
  84432. }
  84433. }
  84434. declare module BABYLON {
  84435. /**
  84436. * Particle emitter emitting particles from the inside of a cone.
  84437. * It emits the particles alongside the cone volume from the base to the particle.
  84438. * The emission direction might be randomized.
  84439. */
  84440. export class ConeParticleEmitter implements IParticleEmitterType {
  84441. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84442. directionRandomizer: number;
  84443. private _radius;
  84444. private _angle;
  84445. private _height;
  84446. /**
  84447. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  84448. */
  84449. radiusRange: number;
  84450. /**
  84451. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  84452. */
  84453. heightRange: number;
  84454. /**
  84455. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  84456. */
  84457. emitFromSpawnPointOnly: boolean;
  84458. /**
  84459. * Gets or sets the radius of the emission cone
  84460. */
  84461. radius: number;
  84462. /**
  84463. * Gets or sets the angle of the emission cone
  84464. */
  84465. angle: number;
  84466. private _buildHeight;
  84467. /**
  84468. * Creates a new instance ConeParticleEmitter
  84469. * @param radius the radius of the emission cone (1 by default)
  84470. * @param angle the cone base angle (PI by default)
  84471. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  84472. */
  84473. constructor(radius?: number, angle?: number,
  84474. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84475. directionRandomizer?: number);
  84476. /**
  84477. * Called by the particle System when the direction is computed for the created particle.
  84478. * @param worldMatrix is the world matrix of the particle system
  84479. * @param directionToUpdate is the direction vector to update with the result
  84480. * @param particle is the particle we are computed the direction for
  84481. */
  84482. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84483. /**
  84484. * Called by the particle System when the position is computed for the created particle.
  84485. * @param worldMatrix is the world matrix of the particle system
  84486. * @param positionToUpdate is the position vector to update with the result
  84487. * @param particle is the particle we are computed the position for
  84488. */
  84489. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84490. /**
  84491. * Clones the current emitter and returns a copy of it
  84492. * @returns the new emitter
  84493. */
  84494. clone(): ConeParticleEmitter;
  84495. /**
  84496. * Called by the GPUParticleSystem to setup the update shader
  84497. * @param effect defines the update shader
  84498. */
  84499. applyToShader(effect: Effect): void;
  84500. /**
  84501. * Returns a string to use to update the GPU particles update shader
  84502. * @returns a string containng the defines string
  84503. */
  84504. getEffectDefines(): string;
  84505. /**
  84506. * Returns the string "ConeParticleEmitter"
  84507. * @returns a string containing the class name
  84508. */
  84509. getClassName(): string;
  84510. /**
  84511. * Serializes the particle system to a JSON object.
  84512. * @returns the JSON object
  84513. */
  84514. serialize(): any;
  84515. /**
  84516. * Parse properties from a JSON object
  84517. * @param serializationObject defines the JSON object
  84518. */
  84519. parse(serializationObject: any): void;
  84520. }
  84521. }
  84522. declare module BABYLON {
  84523. /**
  84524. * Particle emitter emitting particles from the inside of a cylinder.
  84525. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  84526. */
  84527. export class CylinderParticleEmitter implements IParticleEmitterType {
  84528. /**
  84529. * The radius of the emission cylinder.
  84530. */
  84531. radius: number;
  84532. /**
  84533. * The height of the emission cylinder.
  84534. */
  84535. height: number;
  84536. /**
  84537. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84538. */
  84539. radiusRange: number;
  84540. /**
  84541. * How much to randomize the particle direction [0-1].
  84542. */
  84543. directionRandomizer: number;
  84544. /**
  84545. * Creates a new instance CylinderParticleEmitter
  84546. * @param radius the radius of the emission cylinder (1 by default)
  84547. * @param height the height of the emission cylinder (1 by default)
  84548. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84549. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84550. */
  84551. constructor(
  84552. /**
  84553. * The radius of the emission cylinder.
  84554. */
  84555. radius?: number,
  84556. /**
  84557. * The height of the emission cylinder.
  84558. */
  84559. height?: number,
  84560. /**
  84561. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84562. */
  84563. radiusRange?: number,
  84564. /**
  84565. * How much to randomize the particle direction [0-1].
  84566. */
  84567. directionRandomizer?: number);
  84568. /**
  84569. * Called by the particle System when the direction is computed for the created particle.
  84570. * @param worldMatrix is the world matrix of the particle system
  84571. * @param directionToUpdate is the direction vector to update with the result
  84572. * @param particle is the particle we are computed the direction for
  84573. */
  84574. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84575. /**
  84576. * Called by the particle System when the position is computed for the created particle.
  84577. * @param worldMatrix is the world matrix of the particle system
  84578. * @param positionToUpdate is the position vector to update with the result
  84579. * @param particle is the particle we are computed the position for
  84580. */
  84581. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84582. /**
  84583. * Clones the current emitter and returns a copy of it
  84584. * @returns the new emitter
  84585. */
  84586. clone(): CylinderParticleEmitter;
  84587. /**
  84588. * Called by the GPUParticleSystem to setup the update shader
  84589. * @param effect defines the update shader
  84590. */
  84591. applyToShader(effect: Effect): void;
  84592. /**
  84593. * Returns a string to use to update the GPU particles update shader
  84594. * @returns a string containng the defines string
  84595. */
  84596. getEffectDefines(): string;
  84597. /**
  84598. * Returns the string "CylinderParticleEmitter"
  84599. * @returns a string containing the class name
  84600. */
  84601. getClassName(): string;
  84602. /**
  84603. * Serializes the particle system to a JSON object.
  84604. * @returns the JSON object
  84605. */
  84606. serialize(): any;
  84607. /**
  84608. * Parse properties from a JSON object
  84609. * @param serializationObject defines the JSON object
  84610. */
  84611. parse(serializationObject: any): void;
  84612. }
  84613. /**
  84614. * Particle emitter emitting particles from the inside of a cylinder.
  84615. * It emits the particles randomly between two vectors.
  84616. */
  84617. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  84618. /**
  84619. * The min limit of the emission direction.
  84620. */
  84621. direction1: Vector3;
  84622. /**
  84623. * The max limit of the emission direction.
  84624. */
  84625. direction2: Vector3;
  84626. /**
  84627. * Creates a new instance CylinderDirectedParticleEmitter
  84628. * @param radius the radius of the emission cylinder (1 by default)
  84629. * @param height the height of the emission cylinder (1 by default)
  84630. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84631. * @param direction1 the min limit of the emission direction (up vector by default)
  84632. * @param direction2 the max limit of the emission direction (up vector by default)
  84633. */
  84634. constructor(radius?: number, height?: number, radiusRange?: number,
  84635. /**
  84636. * The min limit of the emission direction.
  84637. */
  84638. direction1?: Vector3,
  84639. /**
  84640. * The max limit of the emission direction.
  84641. */
  84642. direction2?: Vector3);
  84643. /**
  84644. * Called by the particle System when the direction is computed for the created particle.
  84645. * @param worldMatrix is the world matrix of the particle system
  84646. * @param directionToUpdate is the direction vector to update with the result
  84647. * @param particle is the particle we are computed the direction for
  84648. */
  84649. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84650. /**
  84651. * Clones the current emitter and returns a copy of it
  84652. * @returns the new emitter
  84653. */
  84654. clone(): CylinderDirectedParticleEmitter;
  84655. /**
  84656. * Called by the GPUParticleSystem to setup the update shader
  84657. * @param effect defines the update shader
  84658. */
  84659. applyToShader(effect: Effect): void;
  84660. /**
  84661. * Returns a string to use to update the GPU particles update shader
  84662. * @returns a string containng the defines string
  84663. */
  84664. getEffectDefines(): string;
  84665. /**
  84666. * Returns the string "CylinderDirectedParticleEmitter"
  84667. * @returns a string containing the class name
  84668. */
  84669. getClassName(): string;
  84670. /**
  84671. * Serializes the particle system to a JSON object.
  84672. * @returns the JSON object
  84673. */
  84674. serialize(): any;
  84675. /**
  84676. * Parse properties from a JSON object
  84677. * @param serializationObject defines the JSON object
  84678. */
  84679. parse(serializationObject: any): void;
  84680. }
  84681. }
  84682. declare module BABYLON {
  84683. /**
  84684. * Particle emitter emitting particles from the inside of a hemisphere.
  84685. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  84686. */
  84687. export class HemisphericParticleEmitter implements IParticleEmitterType {
  84688. /**
  84689. * The radius of the emission hemisphere.
  84690. */
  84691. radius: number;
  84692. /**
  84693. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84694. */
  84695. radiusRange: number;
  84696. /**
  84697. * How much to randomize the particle direction [0-1].
  84698. */
  84699. directionRandomizer: number;
  84700. /**
  84701. * Creates a new instance HemisphericParticleEmitter
  84702. * @param radius the radius of the emission hemisphere (1 by default)
  84703. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84704. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84705. */
  84706. constructor(
  84707. /**
  84708. * The radius of the emission hemisphere.
  84709. */
  84710. radius?: number,
  84711. /**
  84712. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84713. */
  84714. radiusRange?: number,
  84715. /**
  84716. * How much to randomize the particle direction [0-1].
  84717. */
  84718. directionRandomizer?: number);
  84719. /**
  84720. * Called by the particle System when the direction is computed for the created particle.
  84721. * @param worldMatrix is the world matrix of the particle system
  84722. * @param directionToUpdate is the direction vector to update with the result
  84723. * @param particle is the particle we are computed the direction for
  84724. */
  84725. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84726. /**
  84727. * Called by the particle System when the position is computed for the created particle.
  84728. * @param worldMatrix is the world matrix of the particle system
  84729. * @param positionToUpdate is the position vector to update with the result
  84730. * @param particle is the particle we are computed the position for
  84731. */
  84732. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84733. /**
  84734. * Clones the current emitter and returns a copy of it
  84735. * @returns the new emitter
  84736. */
  84737. clone(): HemisphericParticleEmitter;
  84738. /**
  84739. * Called by the GPUParticleSystem to setup the update shader
  84740. * @param effect defines the update shader
  84741. */
  84742. applyToShader(effect: Effect): void;
  84743. /**
  84744. * Returns a string to use to update the GPU particles update shader
  84745. * @returns a string containng the defines string
  84746. */
  84747. getEffectDefines(): string;
  84748. /**
  84749. * Returns the string "HemisphericParticleEmitter"
  84750. * @returns a string containing the class name
  84751. */
  84752. getClassName(): string;
  84753. /**
  84754. * Serializes the particle system to a JSON object.
  84755. * @returns the JSON object
  84756. */
  84757. serialize(): any;
  84758. /**
  84759. * Parse properties from a JSON object
  84760. * @param serializationObject defines the JSON object
  84761. */
  84762. parse(serializationObject: any): void;
  84763. }
  84764. }
  84765. declare module BABYLON {
  84766. /**
  84767. * Particle emitter emitting particles from a point.
  84768. * It emits the particles randomly between 2 given directions.
  84769. */
  84770. export class PointParticleEmitter implements IParticleEmitterType {
  84771. /**
  84772. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84773. */
  84774. direction1: Vector3;
  84775. /**
  84776. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84777. */
  84778. direction2: Vector3;
  84779. /**
  84780. * Creates a new instance PointParticleEmitter
  84781. */
  84782. constructor();
  84783. /**
  84784. * Called by the particle System when the direction is computed for the created particle.
  84785. * @param worldMatrix is the world matrix of the particle system
  84786. * @param directionToUpdate is the direction vector to update with the result
  84787. * @param particle is the particle we are computed the direction for
  84788. */
  84789. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84790. /**
  84791. * Called by the particle System when the position is computed for the created particle.
  84792. * @param worldMatrix is the world matrix of the particle system
  84793. * @param positionToUpdate is the position vector to update with the result
  84794. * @param particle is the particle we are computed the position for
  84795. */
  84796. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84797. /**
  84798. * Clones the current emitter and returns a copy of it
  84799. * @returns the new emitter
  84800. */
  84801. clone(): PointParticleEmitter;
  84802. /**
  84803. * Called by the GPUParticleSystem to setup the update shader
  84804. * @param effect defines the update shader
  84805. */
  84806. applyToShader(effect: Effect): void;
  84807. /**
  84808. * Returns a string to use to update the GPU particles update shader
  84809. * @returns a string containng the defines string
  84810. */
  84811. getEffectDefines(): string;
  84812. /**
  84813. * Returns the string "PointParticleEmitter"
  84814. * @returns a string containing the class name
  84815. */
  84816. getClassName(): string;
  84817. /**
  84818. * Serializes the particle system to a JSON object.
  84819. * @returns the JSON object
  84820. */
  84821. serialize(): any;
  84822. /**
  84823. * Parse properties from a JSON object
  84824. * @param serializationObject defines the JSON object
  84825. */
  84826. parse(serializationObject: any): void;
  84827. }
  84828. }
  84829. declare module BABYLON {
  84830. /**
  84831. * Particle emitter emitting particles from the inside of a sphere.
  84832. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  84833. */
  84834. export class SphereParticleEmitter implements IParticleEmitterType {
  84835. /**
  84836. * The radius of the emission sphere.
  84837. */
  84838. radius: number;
  84839. /**
  84840. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84841. */
  84842. radiusRange: number;
  84843. /**
  84844. * How much to randomize the particle direction [0-1].
  84845. */
  84846. directionRandomizer: number;
  84847. /**
  84848. * Creates a new instance SphereParticleEmitter
  84849. * @param radius the radius of the emission sphere (1 by default)
  84850. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84851. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84852. */
  84853. constructor(
  84854. /**
  84855. * The radius of the emission sphere.
  84856. */
  84857. radius?: number,
  84858. /**
  84859. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84860. */
  84861. radiusRange?: number,
  84862. /**
  84863. * How much to randomize the particle direction [0-1].
  84864. */
  84865. directionRandomizer?: number);
  84866. /**
  84867. * Called by the particle System when the direction is computed for the created particle.
  84868. * @param worldMatrix is the world matrix of the particle system
  84869. * @param directionToUpdate is the direction vector to update with the result
  84870. * @param particle is the particle we are computed the direction for
  84871. */
  84872. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84873. /**
  84874. * Called by the particle System when the position is computed for the created particle.
  84875. * @param worldMatrix is the world matrix of the particle system
  84876. * @param positionToUpdate is the position vector to update with the result
  84877. * @param particle is the particle we are computed the position for
  84878. */
  84879. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84880. /**
  84881. * Clones the current emitter and returns a copy of it
  84882. * @returns the new emitter
  84883. */
  84884. clone(): SphereParticleEmitter;
  84885. /**
  84886. * Called by the GPUParticleSystem to setup the update shader
  84887. * @param effect defines the update shader
  84888. */
  84889. applyToShader(effect: Effect): void;
  84890. /**
  84891. * Returns a string to use to update the GPU particles update shader
  84892. * @returns a string containng the defines string
  84893. */
  84894. getEffectDefines(): string;
  84895. /**
  84896. * Returns the string "SphereParticleEmitter"
  84897. * @returns a string containing the class name
  84898. */
  84899. getClassName(): string;
  84900. /**
  84901. * Serializes the particle system to a JSON object.
  84902. * @returns the JSON object
  84903. */
  84904. serialize(): any;
  84905. /**
  84906. * Parse properties from a JSON object
  84907. * @param serializationObject defines the JSON object
  84908. */
  84909. parse(serializationObject: any): void;
  84910. }
  84911. /**
  84912. * Particle emitter emitting particles from the inside of a sphere.
  84913. * It emits the particles randomly between two vectors.
  84914. */
  84915. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  84916. /**
  84917. * The min limit of the emission direction.
  84918. */
  84919. direction1: Vector3;
  84920. /**
  84921. * The max limit of the emission direction.
  84922. */
  84923. direction2: Vector3;
  84924. /**
  84925. * Creates a new instance SphereDirectedParticleEmitter
  84926. * @param radius the radius of the emission sphere (1 by default)
  84927. * @param direction1 the min limit of the emission direction (up vector by default)
  84928. * @param direction2 the max limit of the emission direction (up vector by default)
  84929. */
  84930. constructor(radius?: number,
  84931. /**
  84932. * The min limit of the emission direction.
  84933. */
  84934. direction1?: Vector3,
  84935. /**
  84936. * The max limit of the emission direction.
  84937. */
  84938. direction2?: Vector3);
  84939. /**
  84940. * Called by the particle System when the direction is computed for the created particle.
  84941. * @param worldMatrix is the world matrix of the particle system
  84942. * @param directionToUpdate is the direction vector to update with the result
  84943. * @param particle is the particle we are computed the direction for
  84944. */
  84945. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84946. /**
  84947. * Clones the current emitter and returns a copy of it
  84948. * @returns the new emitter
  84949. */
  84950. clone(): SphereDirectedParticleEmitter;
  84951. /**
  84952. * Called by the GPUParticleSystem to setup the update shader
  84953. * @param effect defines the update shader
  84954. */
  84955. applyToShader(effect: Effect): void;
  84956. /**
  84957. * Returns a string to use to update the GPU particles update shader
  84958. * @returns a string containng the defines string
  84959. */
  84960. getEffectDefines(): string;
  84961. /**
  84962. * Returns the string "SphereDirectedParticleEmitter"
  84963. * @returns a string containing the class name
  84964. */
  84965. getClassName(): string;
  84966. /**
  84967. * Serializes the particle system to a JSON object.
  84968. * @returns the JSON object
  84969. */
  84970. serialize(): any;
  84971. /**
  84972. * Parse properties from a JSON object
  84973. * @param serializationObject defines the JSON object
  84974. */
  84975. parse(serializationObject: any): void;
  84976. }
  84977. }
  84978. declare module BABYLON {
  84979. /**
  84980. * Interface representing a particle system in Babylon.js.
  84981. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  84982. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  84983. */
  84984. export interface IParticleSystem {
  84985. /**
  84986. * List of animations used by the particle system.
  84987. */
  84988. animations: Animation[];
  84989. /**
  84990. * The id of the Particle system.
  84991. */
  84992. id: string;
  84993. /**
  84994. * The name of the Particle system.
  84995. */
  84996. name: string;
  84997. /**
  84998. * The emitter represents the Mesh or position we are attaching the particle system to.
  84999. */
  85000. emitter: Nullable<AbstractMesh | Vector3>;
  85001. /**
  85002. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85003. */
  85004. isBillboardBased: boolean;
  85005. /**
  85006. * The rendering group used by the Particle system to chose when to render.
  85007. */
  85008. renderingGroupId: number;
  85009. /**
  85010. * The layer mask we are rendering the particles through.
  85011. */
  85012. layerMask: number;
  85013. /**
  85014. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85015. */
  85016. updateSpeed: number;
  85017. /**
  85018. * The amount of time the particle system is running (depends of the overall update speed).
  85019. */
  85020. targetStopDuration: number;
  85021. /**
  85022. * The texture used to render each particle. (this can be a spritesheet)
  85023. */
  85024. particleTexture: Nullable<Texture>;
  85025. /**
  85026. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85027. */
  85028. blendMode: number;
  85029. /**
  85030. * Minimum life time of emitting particles.
  85031. */
  85032. minLifeTime: number;
  85033. /**
  85034. * Maximum life time of emitting particles.
  85035. */
  85036. maxLifeTime: number;
  85037. /**
  85038. * Minimum Size of emitting particles.
  85039. */
  85040. minSize: number;
  85041. /**
  85042. * Maximum Size of emitting particles.
  85043. */
  85044. maxSize: number;
  85045. /**
  85046. * Minimum scale of emitting particles on X axis.
  85047. */
  85048. minScaleX: number;
  85049. /**
  85050. * Maximum scale of emitting particles on X axis.
  85051. */
  85052. maxScaleX: number;
  85053. /**
  85054. * Minimum scale of emitting particles on Y axis.
  85055. */
  85056. minScaleY: number;
  85057. /**
  85058. * Maximum scale of emitting particles on Y axis.
  85059. */
  85060. maxScaleY: number;
  85061. /**
  85062. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85063. */
  85064. color1: Color4;
  85065. /**
  85066. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85067. */
  85068. color2: Color4;
  85069. /**
  85070. * Color the particle will have at the end of its lifetime.
  85071. */
  85072. colorDead: Color4;
  85073. /**
  85074. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85075. */
  85076. emitRate: number;
  85077. /**
  85078. * You can use gravity if you want to give an orientation to your particles.
  85079. */
  85080. gravity: Vector3;
  85081. /**
  85082. * Minimum power of emitting particles.
  85083. */
  85084. minEmitPower: number;
  85085. /**
  85086. * Maximum power of emitting particles.
  85087. */
  85088. maxEmitPower: number;
  85089. /**
  85090. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85091. */
  85092. minAngularSpeed: number;
  85093. /**
  85094. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85095. */
  85096. maxAngularSpeed: number;
  85097. /**
  85098. * Gets or sets the minimal initial rotation in radians.
  85099. */
  85100. minInitialRotation: number;
  85101. /**
  85102. * Gets or sets the maximal initial rotation in radians.
  85103. */
  85104. maxInitialRotation: number;
  85105. /**
  85106. * The particle emitter type defines the emitter used by the particle system.
  85107. * It can be for example box, sphere, or cone...
  85108. */
  85109. particleEmitterType: Nullable<IParticleEmitterType>;
  85110. /**
  85111. * Defines the delay in milliseconds before starting the system (0 by default)
  85112. */
  85113. startDelay: number;
  85114. /**
  85115. * 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
  85116. */
  85117. preWarmCycles: number;
  85118. /**
  85119. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85120. */
  85121. preWarmStepOffset: number;
  85122. /**
  85123. * 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)
  85124. */
  85125. spriteCellChangeSpeed: number;
  85126. /**
  85127. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85128. */
  85129. startSpriteCellID: number;
  85130. /**
  85131. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85132. */
  85133. endSpriteCellID: number;
  85134. /**
  85135. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85136. */
  85137. spriteCellWidth: number;
  85138. /**
  85139. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85140. */
  85141. spriteCellHeight: number;
  85142. /**
  85143. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85144. */
  85145. spriteRandomStartCell: boolean;
  85146. /**
  85147. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85148. */
  85149. isAnimationSheetEnabled: boolean;
  85150. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85151. translationPivot: Vector2;
  85152. /**
  85153. * Gets or sets a texture used to add random noise to particle positions
  85154. */
  85155. noiseTexture: Nullable<BaseTexture>;
  85156. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85157. noiseStrength: Vector3;
  85158. /**
  85159. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85160. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85161. */
  85162. billboardMode: number;
  85163. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85164. limitVelocityDamping: number;
  85165. /**
  85166. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85167. */
  85168. beginAnimationOnStart: boolean;
  85169. /**
  85170. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85171. */
  85172. beginAnimationFrom: number;
  85173. /**
  85174. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85175. */
  85176. beginAnimationTo: number;
  85177. /**
  85178. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85179. */
  85180. beginAnimationLoop: boolean;
  85181. /**
  85182. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85183. */
  85184. disposeOnStop: boolean;
  85185. /**
  85186. * Gets the maximum number of particles active at the same time.
  85187. * @returns The max number of active particles.
  85188. */
  85189. getCapacity(): number;
  85190. /**
  85191. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85192. * @returns True if it has been started, otherwise false.
  85193. */
  85194. isStarted(): boolean;
  85195. /**
  85196. * Animates the particle system for this frame.
  85197. */
  85198. animate(): void;
  85199. /**
  85200. * Renders the particle system in its current state.
  85201. * @returns the current number of particles
  85202. */
  85203. render(): number;
  85204. /**
  85205. * Dispose the particle system and frees its associated resources.
  85206. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85207. */
  85208. dispose(disposeTexture?: boolean): void;
  85209. /**
  85210. * Clones the particle system.
  85211. * @param name The name of the cloned object
  85212. * @param newEmitter The new emitter to use
  85213. * @returns the cloned particle system
  85214. */
  85215. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85216. /**
  85217. * Serializes the particle system to a JSON object.
  85218. * @returns the JSON object
  85219. */
  85220. serialize(): any;
  85221. /**
  85222. * Rebuild the particle system
  85223. */
  85224. rebuild(): void;
  85225. /**
  85226. * Starts the particle system and begins to emit
  85227. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85228. */
  85229. start(delay?: number): void;
  85230. /**
  85231. * Stops the particle system.
  85232. */
  85233. stop(): void;
  85234. /**
  85235. * Remove all active particles
  85236. */
  85237. reset(): void;
  85238. /**
  85239. * Is this system ready to be used/rendered
  85240. * @return true if the system is ready
  85241. */
  85242. isReady(): boolean;
  85243. /**
  85244. * Adds a new color gradient
  85245. * @param gradient defines the gradient to use (between 0 and 1)
  85246. * @param color1 defines the color to affect to the specified gradient
  85247. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85248. * @returns the current particle system
  85249. */
  85250. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85251. /**
  85252. * Remove a specific color gradient
  85253. * @param gradient defines the gradient to remove
  85254. * @returns the current particle system
  85255. */
  85256. removeColorGradient(gradient: number): IParticleSystem;
  85257. /**
  85258. * Adds a new size gradient
  85259. * @param gradient defines the gradient to use (between 0 and 1)
  85260. * @param factor defines the size factor to affect to the specified gradient
  85261. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85262. * @returns the current particle system
  85263. */
  85264. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85265. /**
  85266. * Remove a specific size gradient
  85267. * @param gradient defines the gradient to remove
  85268. * @returns the current particle system
  85269. */
  85270. removeSizeGradient(gradient: number): IParticleSystem;
  85271. /**
  85272. * Gets the current list of color gradients.
  85273. * You must use addColorGradient and removeColorGradient to udpate this list
  85274. * @returns the list of color gradients
  85275. */
  85276. getColorGradients(): Nullable<Array<ColorGradient>>;
  85277. /**
  85278. * Gets the current list of size gradients.
  85279. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85280. * @returns the list of size gradients
  85281. */
  85282. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85283. /**
  85284. * Gets the current list of angular speed gradients.
  85285. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85286. * @returns the list of angular speed gradients
  85287. */
  85288. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85289. /**
  85290. * Adds a new angular speed gradient
  85291. * @param gradient defines the gradient to use (between 0 and 1)
  85292. * @param factor defines the angular speed to affect to the specified gradient
  85293. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85294. * @returns the current particle system
  85295. */
  85296. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85297. /**
  85298. * Remove a specific angular speed gradient
  85299. * @param gradient defines the gradient to remove
  85300. * @returns the current particle system
  85301. */
  85302. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85303. /**
  85304. * Gets the current list of velocity gradients.
  85305. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85306. * @returns the list of velocity gradients
  85307. */
  85308. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85309. /**
  85310. * Adds a new velocity gradient
  85311. * @param gradient defines the gradient to use (between 0 and 1)
  85312. * @param factor defines the velocity to affect to the specified gradient
  85313. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85314. * @returns the current particle system
  85315. */
  85316. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85317. /**
  85318. * Remove a specific velocity gradient
  85319. * @param gradient defines the gradient to remove
  85320. * @returns the current particle system
  85321. */
  85322. removeVelocityGradient(gradient: number): IParticleSystem;
  85323. /**
  85324. * Gets the current list of limit velocity gradients.
  85325. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85326. * @returns the list of limit velocity gradients
  85327. */
  85328. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85329. /**
  85330. * Adds a new limit velocity gradient
  85331. * @param gradient defines the gradient to use (between 0 and 1)
  85332. * @param factor defines the limit velocity to affect to the specified gradient
  85333. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85334. * @returns the current particle system
  85335. */
  85336. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85337. /**
  85338. * Remove a specific limit velocity gradient
  85339. * @param gradient defines the gradient to remove
  85340. * @returns the current particle system
  85341. */
  85342. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85343. /**
  85344. * Adds a new drag gradient
  85345. * @param gradient defines the gradient to use (between 0 and 1)
  85346. * @param factor defines the drag to affect to the specified gradient
  85347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85348. * @returns the current particle system
  85349. */
  85350. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85351. /**
  85352. * Remove a specific drag gradient
  85353. * @param gradient defines the gradient to remove
  85354. * @returns the current particle system
  85355. */
  85356. removeDragGradient(gradient: number): IParticleSystem;
  85357. /**
  85358. * Gets the current list of drag gradients.
  85359. * You must use addDragGradient and removeDragGradient to udpate this list
  85360. * @returns the list of drag gradients
  85361. */
  85362. getDragGradients(): Nullable<Array<FactorGradient>>;
  85363. /**
  85364. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85365. * @param gradient defines the gradient to use (between 0 and 1)
  85366. * @param factor defines the emit rate to affect to the specified gradient
  85367. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85368. * @returns the current particle system
  85369. */
  85370. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85371. /**
  85372. * Remove a specific emit rate gradient
  85373. * @param gradient defines the gradient to remove
  85374. * @returns the current particle system
  85375. */
  85376. removeEmitRateGradient(gradient: number): IParticleSystem;
  85377. /**
  85378. * Gets the current list of emit rate gradients.
  85379. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85380. * @returns the list of emit rate gradients
  85381. */
  85382. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85383. /**
  85384. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85385. * @param gradient defines the gradient to use (between 0 and 1)
  85386. * @param factor defines the start size to affect to the specified gradient
  85387. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85388. * @returns the current particle system
  85389. */
  85390. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85391. /**
  85392. * Remove a specific start size gradient
  85393. * @param gradient defines the gradient to remove
  85394. * @returns the current particle system
  85395. */
  85396. removeStartSizeGradient(gradient: number): IParticleSystem;
  85397. /**
  85398. * Gets the current list of start size gradients.
  85399. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85400. * @returns the list of start size gradients
  85401. */
  85402. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85403. /**
  85404. * Adds a new life time gradient
  85405. * @param gradient defines the gradient to use (between 0 and 1)
  85406. * @param factor defines the life time factor to affect to the specified gradient
  85407. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85408. * @returns the current particle system
  85409. */
  85410. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85411. /**
  85412. * Remove a specific life time gradient
  85413. * @param gradient defines the gradient to remove
  85414. * @returns the current particle system
  85415. */
  85416. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85417. /**
  85418. * Gets the current list of life time gradients.
  85419. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85420. * @returns the list of life time gradients
  85421. */
  85422. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85423. /**
  85424. * Gets the current list of color gradients.
  85425. * You must use addColorGradient and removeColorGradient to udpate this list
  85426. * @returns the list of color gradients
  85427. */
  85428. getColorGradients(): Nullable<Array<ColorGradient>>;
  85429. /**
  85430. * Adds a new ramp gradient used to remap particle colors
  85431. * @param gradient defines the gradient to use (between 0 and 1)
  85432. * @param color defines the color to affect to the specified gradient
  85433. * @returns the current particle system
  85434. */
  85435. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  85436. /**
  85437. * Gets the current list of ramp gradients.
  85438. * You must use addRampGradient and removeRampGradient to udpate this list
  85439. * @returns the list of ramp gradients
  85440. */
  85441. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85442. /** Gets or sets a boolean indicating that ramp gradients must be used
  85443. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85444. */
  85445. useRampGradients: boolean;
  85446. /**
  85447. * Adds a new color remap gradient
  85448. * @param gradient defines the gradient to use (between 0 and 1)
  85449. * @param min defines the color remap minimal range
  85450. * @param max defines the color remap maximal range
  85451. * @returns the current particle system
  85452. */
  85453. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85454. /**
  85455. * Gets the current list of color remap gradients.
  85456. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85457. * @returns the list of color remap gradients
  85458. */
  85459. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85460. /**
  85461. * Adds a new alpha remap gradient
  85462. * @param gradient defines the gradient to use (between 0 and 1)
  85463. * @param min defines the alpha remap minimal range
  85464. * @param max defines the alpha remap maximal range
  85465. * @returns the current particle system
  85466. */
  85467. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85468. /**
  85469. * Gets the current list of alpha remap gradients.
  85470. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85471. * @returns the list of alpha remap gradients
  85472. */
  85473. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85474. /**
  85475. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85476. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85477. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85478. * @returns the emitter
  85479. */
  85480. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85481. /**
  85482. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85483. * @param radius The radius of the hemisphere to emit from
  85484. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85485. * @returns the emitter
  85486. */
  85487. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  85488. /**
  85489. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85490. * @param radius The radius of the sphere to emit from
  85491. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85492. * @returns the emitter
  85493. */
  85494. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  85495. /**
  85496. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85497. * @param radius The radius of the sphere to emit from
  85498. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85499. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85500. * @returns the emitter
  85501. */
  85502. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85503. /**
  85504. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85505. * @param radius The radius of the emission cylinder
  85506. * @param height The height of the emission cylinder
  85507. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85508. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85509. * @returns the emitter
  85510. */
  85511. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  85512. /**
  85513. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85514. * @param radius The radius of the cylinder to emit from
  85515. * @param height The height of the emission cylinder
  85516. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85517. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85518. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85519. * @returns the emitter
  85520. */
  85521. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85522. /**
  85523. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85524. * @param radius The radius of the cone to emit from
  85525. * @param angle The base angle of the cone
  85526. * @returns the emitter
  85527. */
  85528. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  85529. /**
  85530. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85531. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85532. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85533. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85534. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85535. * @returns the emitter
  85536. */
  85537. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85538. /**
  85539. * Get hosting scene
  85540. * @returns the scene
  85541. */
  85542. getScene(): Scene;
  85543. }
  85544. }
  85545. declare module BABYLON {
  85546. /**
  85547. * Creates an instance based on a source mesh.
  85548. */
  85549. export class InstancedMesh extends AbstractMesh {
  85550. private _sourceMesh;
  85551. private _currentLOD;
  85552. /** @hidden */
  85553. _indexInSourceMeshInstanceArray: number;
  85554. constructor(name: string, source: Mesh);
  85555. /**
  85556. * Returns the string "InstancedMesh".
  85557. */
  85558. getClassName(): string;
  85559. /** Gets the list of lights affecting that mesh */
  85560. readonly lightSources: Light[];
  85561. _resyncLightSources(): void;
  85562. _resyncLighSource(light: Light): void;
  85563. _removeLightSource(light: Light, dispose: boolean): void;
  85564. /**
  85565. * If the source mesh receives shadows
  85566. */
  85567. readonly receiveShadows: boolean;
  85568. /**
  85569. * The material of the source mesh
  85570. */
  85571. readonly material: Nullable<Material>;
  85572. /**
  85573. * Visibility of the source mesh
  85574. */
  85575. readonly visibility: number;
  85576. /**
  85577. * Skeleton of the source mesh
  85578. */
  85579. readonly skeleton: Nullable<Skeleton>;
  85580. /**
  85581. * Rendering ground id of the source mesh
  85582. */
  85583. renderingGroupId: number;
  85584. /**
  85585. * Returns the total number of vertices (integer).
  85586. */
  85587. getTotalVertices(): number;
  85588. /**
  85589. * Returns a positive integer : the total number of indices in this mesh geometry.
  85590. * @returns the numner of indices or zero if the mesh has no geometry.
  85591. */
  85592. getTotalIndices(): number;
  85593. /**
  85594. * The source mesh of the instance
  85595. */
  85596. readonly sourceMesh: Mesh;
  85597. /**
  85598. * Is this node ready to be used/rendered
  85599. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85600. * @return {boolean} is it ready
  85601. */
  85602. isReady(completeCheck?: boolean): boolean;
  85603. /**
  85604. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85605. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  85606. * @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.
  85607. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  85608. */
  85609. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  85610. /**
  85611. * Sets the vertex data of the mesh geometry for the requested `kind`.
  85612. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  85613. * The `data` are either a numeric array either a Float32Array.
  85614. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  85615. * 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).
  85616. * Note that a new underlying VertexBuffer object is created each call.
  85617. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  85618. *
  85619. * Possible `kind` values :
  85620. * - VertexBuffer.PositionKind
  85621. * - VertexBuffer.UVKind
  85622. * - VertexBuffer.UV2Kind
  85623. * - VertexBuffer.UV3Kind
  85624. * - VertexBuffer.UV4Kind
  85625. * - VertexBuffer.UV5Kind
  85626. * - VertexBuffer.UV6Kind
  85627. * - VertexBuffer.ColorKind
  85628. * - VertexBuffer.MatricesIndicesKind
  85629. * - VertexBuffer.MatricesIndicesExtraKind
  85630. * - VertexBuffer.MatricesWeightsKind
  85631. * - VertexBuffer.MatricesWeightsExtraKind
  85632. *
  85633. * Returns the Mesh.
  85634. */
  85635. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  85636. /**
  85637. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  85638. * If the mesh has no geometry, it is simply returned as it is.
  85639. * The `data` are either a numeric array either a Float32Array.
  85640. * No new underlying VertexBuffer object is created.
  85641. * 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.
  85642. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  85643. *
  85644. * Possible `kind` values :
  85645. * - VertexBuffer.PositionKind
  85646. * - VertexBuffer.UVKind
  85647. * - VertexBuffer.UV2Kind
  85648. * - VertexBuffer.UV3Kind
  85649. * - VertexBuffer.UV4Kind
  85650. * - VertexBuffer.UV5Kind
  85651. * - VertexBuffer.UV6Kind
  85652. * - VertexBuffer.ColorKind
  85653. * - VertexBuffer.MatricesIndicesKind
  85654. * - VertexBuffer.MatricesIndicesExtraKind
  85655. * - VertexBuffer.MatricesWeightsKind
  85656. * - VertexBuffer.MatricesWeightsExtraKind
  85657. *
  85658. * Returns the Mesh.
  85659. */
  85660. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  85661. /**
  85662. * Sets the mesh indices.
  85663. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  85664. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  85665. * This method creates a new index buffer each call.
  85666. * Returns the Mesh.
  85667. */
  85668. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  85669. /**
  85670. * Boolean : True if the mesh owns the requested kind of data.
  85671. */
  85672. isVerticesDataPresent(kind: string): boolean;
  85673. /**
  85674. * Returns an array of indices (IndicesArray).
  85675. */
  85676. getIndices(): Nullable<IndicesArray>;
  85677. readonly _positions: Nullable<Vector3[]>;
  85678. /**
  85679. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85680. * This means the mesh underlying bounding box and sphere are recomputed.
  85681. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85682. * @returns the current mesh
  85683. */
  85684. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  85685. /** @hidden */
  85686. _preActivate(): InstancedMesh;
  85687. /** @hidden */
  85688. _activate(renderId: number, intermediateRendering: boolean): boolean;
  85689. /** @hidden */
  85690. _postActivate(): void;
  85691. getWorldMatrix(): Matrix;
  85692. readonly isAnInstance: boolean;
  85693. /**
  85694. * Returns the current associated LOD AbstractMesh.
  85695. */
  85696. getLOD(camera: Camera): AbstractMesh;
  85697. /** @hidden */
  85698. _syncSubMeshes(): InstancedMesh;
  85699. /** @hidden */
  85700. _generatePointsArray(): boolean;
  85701. /**
  85702. * Creates a new InstancedMesh from the current mesh.
  85703. * - name (string) : the cloned mesh name
  85704. * - newParent (optional Node) : the optional Node to parent the clone to.
  85705. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  85706. *
  85707. * Returns the clone.
  85708. */
  85709. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85710. /**
  85711. * Disposes the InstancedMesh.
  85712. * Returns nothing.
  85713. */
  85714. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85715. }
  85716. }
  85717. declare module BABYLON {
  85718. /**
  85719. * Defines the options associated with the creation of a shader material.
  85720. */
  85721. export interface IShaderMaterialOptions {
  85722. /**
  85723. * Does the material work in alpha blend mode
  85724. */
  85725. needAlphaBlending: boolean;
  85726. /**
  85727. * Does the material work in alpha test mode
  85728. */
  85729. needAlphaTesting: boolean;
  85730. /**
  85731. * The list of attribute names used in the shader
  85732. */
  85733. attributes: string[];
  85734. /**
  85735. * The list of unifrom names used in the shader
  85736. */
  85737. uniforms: string[];
  85738. /**
  85739. * The list of UBO names used in the shader
  85740. */
  85741. uniformBuffers: string[];
  85742. /**
  85743. * The list of sampler names used in the shader
  85744. */
  85745. samplers: string[];
  85746. /**
  85747. * The list of defines used in the shader
  85748. */
  85749. defines: string[];
  85750. }
  85751. /**
  85752. * 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.
  85753. *
  85754. * This returned material effects how the mesh will look based on the code in the shaders.
  85755. *
  85756. * @see http://doc.babylonjs.com/how_to/shader_material
  85757. */
  85758. export class ShaderMaterial extends Material {
  85759. private _shaderPath;
  85760. private _options;
  85761. private _textures;
  85762. private _textureArrays;
  85763. private _floats;
  85764. private _ints;
  85765. private _floatsArrays;
  85766. private _colors3;
  85767. private _colors3Arrays;
  85768. private _colors4;
  85769. private _colors4Arrays;
  85770. private _vectors2;
  85771. private _vectors3;
  85772. private _vectors4;
  85773. private _matrices;
  85774. private _matrices3x3;
  85775. private _matrices2x2;
  85776. private _vectors2Arrays;
  85777. private _vectors3Arrays;
  85778. private _vectors4Arrays;
  85779. private _cachedWorldViewMatrix;
  85780. private _cachedWorldViewProjectionMatrix;
  85781. private _renderId;
  85782. /**
  85783. * Instantiate a new shader material.
  85784. * 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.
  85785. * This returned material effects how the mesh will look based on the code in the shaders.
  85786. * @see http://doc.babylonjs.com/how_to/shader_material
  85787. * @param name Define the name of the material in the scene
  85788. * @param scene Define the scene the material belongs to
  85789. * @param shaderPath Defines the route to the shader code in one of three ways:
  85790. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  85791. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  85792. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  85793. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  85794. * @param options Define the options used to create the shader
  85795. */
  85796. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  85797. /**
  85798. * Gets the options used to compile the shader.
  85799. * They can be modified to trigger a new compilation
  85800. */
  85801. readonly options: IShaderMaterialOptions;
  85802. /**
  85803. * Gets the current class name of the material e.g. "ShaderMaterial"
  85804. * Mainly use in serialization.
  85805. * @returns the class name
  85806. */
  85807. getClassName(): string;
  85808. /**
  85809. * Specifies if the material will require alpha blending
  85810. * @returns a boolean specifying if alpha blending is needed
  85811. */
  85812. needAlphaBlending(): boolean;
  85813. /**
  85814. * Specifies if this material should be rendered in alpha test mode
  85815. * @returns a boolean specifying if an alpha test is needed.
  85816. */
  85817. needAlphaTesting(): boolean;
  85818. private _checkUniform;
  85819. /**
  85820. * Set a texture in the shader.
  85821. * @param name Define the name of the uniform samplers as defined in the shader
  85822. * @param texture Define the texture to bind to this sampler
  85823. * @return the material itself allowing "fluent" like uniform updates
  85824. */
  85825. setTexture(name: string, texture: Texture): ShaderMaterial;
  85826. /**
  85827. * Set a texture array in the shader.
  85828. * @param name Define the name of the uniform sampler array as defined in the shader
  85829. * @param textures Define the list of textures to bind to this sampler
  85830. * @return the material itself allowing "fluent" like uniform updates
  85831. */
  85832. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  85833. /**
  85834. * Set a float in the shader.
  85835. * @param name Define the name of the uniform as defined in the shader
  85836. * @param value Define the value to give to the uniform
  85837. * @return the material itself allowing "fluent" like uniform updates
  85838. */
  85839. setFloat(name: string, value: number): ShaderMaterial;
  85840. /**
  85841. * Set a int in the shader.
  85842. * @param name Define the name of the uniform as defined in the shader
  85843. * @param value Define the value to give to the uniform
  85844. * @return the material itself allowing "fluent" like uniform updates
  85845. */
  85846. setInt(name: string, value: number): ShaderMaterial;
  85847. /**
  85848. * Set an array of floats in the shader.
  85849. * @param name Define the name of the uniform as defined in the shader
  85850. * @param value Define the value to give to the uniform
  85851. * @return the material itself allowing "fluent" like uniform updates
  85852. */
  85853. setFloats(name: string, value: number[]): ShaderMaterial;
  85854. /**
  85855. * Set a vec3 in the shader from a Color3.
  85856. * @param name Define the name of the uniform as defined in the shader
  85857. * @param value Define the value to give to the uniform
  85858. * @return the material itself allowing "fluent" like uniform updates
  85859. */
  85860. setColor3(name: string, value: Color3): ShaderMaterial;
  85861. /**
  85862. * Set a vec3 array in the shader from a Color3 array.
  85863. * @param name Define the name of the uniform as defined in the shader
  85864. * @param value Define the value to give to the uniform
  85865. * @return the material itself allowing "fluent" like uniform updates
  85866. */
  85867. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  85868. /**
  85869. * Set a vec4 in the shader from a Color4.
  85870. * @param name Define the name of the uniform as defined in the shader
  85871. * @param value Define the value to give to the uniform
  85872. * @return the material itself allowing "fluent" like uniform updates
  85873. */
  85874. setColor4(name: string, value: Color4): ShaderMaterial;
  85875. /**
  85876. * Set a vec4 array in the shader from a Color4 array.
  85877. * @param name Define the name of the uniform as defined in the shader
  85878. * @param value Define the value to give to the uniform
  85879. * @return the material itself allowing "fluent" like uniform updates
  85880. */
  85881. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  85882. /**
  85883. * Set a vec2 in the shader from a Vector2.
  85884. * @param name Define the name of the uniform as defined in the shader
  85885. * @param value Define the value to give to the uniform
  85886. * @return the material itself allowing "fluent" like uniform updates
  85887. */
  85888. setVector2(name: string, value: Vector2): ShaderMaterial;
  85889. /**
  85890. * Set a vec3 in the shader from a Vector3.
  85891. * @param name Define the name of the uniform as defined in the shader
  85892. * @param value Define the value to give to the uniform
  85893. * @return the material itself allowing "fluent" like uniform updates
  85894. */
  85895. setVector3(name: string, value: Vector3): ShaderMaterial;
  85896. /**
  85897. * Set a vec4 in the shader from a Vector4.
  85898. * @param name Define the name of the uniform as defined in the shader
  85899. * @param value Define the value to give to the uniform
  85900. * @return the material itself allowing "fluent" like uniform updates
  85901. */
  85902. setVector4(name: string, value: Vector4): ShaderMaterial;
  85903. /**
  85904. * Set a mat4 in the shader from a Matrix.
  85905. * @param name Define the name of the uniform as defined in the shader
  85906. * @param value Define the value to give to the uniform
  85907. * @return the material itself allowing "fluent" like uniform updates
  85908. */
  85909. setMatrix(name: string, value: Matrix): ShaderMaterial;
  85910. /**
  85911. * Set a mat3 in the shader from a Float32Array.
  85912. * @param name Define the name of the uniform as defined in the shader
  85913. * @param value Define the value to give to the uniform
  85914. * @return the material itself allowing "fluent" like uniform updates
  85915. */
  85916. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  85917. /**
  85918. * Set a mat2 in the shader from a Float32Array.
  85919. * @param name Define the name of the uniform as defined in the shader
  85920. * @param value Define the value to give to the uniform
  85921. * @return the material itself allowing "fluent" like uniform updates
  85922. */
  85923. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  85924. /**
  85925. * Set a vec2 array in the shader from a number array.
  85926. * @param name Define the name of the uniform as defined in the shader
  85927. * @param value Define the value to give to the uniform
  85928. * @return the material itself allowing "fluent" like uniform updates
  85929. */
  85930. setArray2(name: string, value: number[]): ShaderMaterial;
  85931. /**
  85932. * Set a vec3 array in the shader from a number array.
  85933. * @param name Define the name of the uniform as defined in the shader
  85934. * @param value Define the value to give to the uniform
  85935. * @return the material itself allowing "fluent" like uniform updates
  85936. */
  85937. setArray3(name: string, value: number[]): ShaderMaterial;
  85938. /**
  85939. * Set a vec4 array in the shader from a number array.
  85940. * @param name Define the name of the uniform as defined in the shader
  85941. * @param value Define the value to give to the uniform
  85942. * @return the material itself allowing "fluent" like uniform updates
  85943. */
  85944. setArray4(name: string, value: number[]): ShaderMaterial;
  85945. private _checkCache;
  85946. /**
  85947. * Specifies that the submesh is ready to be used
  85948. * @param mesh defines the mesh to check
  85949. * @param subMesh defines which submesh to check
  85950. * @param useInstances specifies that instances should be used
  85951. * @returns a boolean indicating that the submesh is ready or not
  85952. */
  85953. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85954. /**
  85955. * Checks if the material is ready to render the requested mesh
  85956. * @param mesh Define the mesh to render
  85957. * @param useInstances Define whether or not the material is used with instances
  85958. * @returns true if ready, otherwise false
  85959. */
  85960. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85961. /**
  85962. * Binds the world matrix to the material
  85963. * @param world defines the world transformation matrix
  85964. */
  85965. bindOnlyWorldMatrix(world: Matrix): void;
  85966. /**
  85967. * Binds the material to the mesh
  85968. * @param world defines the world transformation matrix
  85969. * @param mesh defines the mesh to bind the material to
  85970. */
  85971. bind(world: Matrix, mesh?: Mesh): void;
  85972. /**
  85973. * Gets the active textures from the material
  85974. * @returns an array of textures
  85975. */
  85976. getActiveTextures(): BaseTexture[];
  85977. /**
  85978. * Specifies if the material uses a texture
  85979. * @param texture defines the texture to check against the material
  85980. * @returns a boolean specifying if the material uses the texture
  85981. */
  85982. hasTexture(texture: BaseTexture): boolean;
  85983. /**
  85984. * Makes a duplicate of the material, and gives it a new name
  85985. * @param name defines the new name for the duplicated material
  85986. * @returns the cloned material
  85987. */
  85988. clone(name: string): ShaderMaterial;
  85989. /**
  85990. * Disposes the material
  85991. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85992. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85993. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85994. */
  85995. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85996. /**
  85997. * Serializes this material in a JSON representation
  85998. * @returns the serialized material object
  85999. */
  86000. serialize(): any;
  86001. /**
  86002. * Creates a shader material from parsed shader material data
  86003. * @param source defines the JSON represnetation of the material
  86004. * @param scene defines the hosting scene
  86005. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86006. * @returns a new material
  86007. */
  86008. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  86009. }
  86010. }
  86011. declare module BABYLON {
  86012. /** @hidden */
  86013. export var colorPixelShader: {
  86014. name: string;
  86015. shader: string;
  86016. };
  86017. }
  86018. declare module BABYLON {
  86019. /** @hidden */
  86020. export var colorVertexShader: {
  86021. name: string;
  86022. shader: string;
  86023. };
  86024. }
  86025. declare module BABYLON {
  86026. /**
  86027. * Line mesh
  86028. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  86029. */
  86030. export class LinesMesh extends Mesh {
  86031. /**
  86032. * If vertex color should be applied to the mesh
  86033. */
  86034. readonly useVertexColor?: boolean | undefined;
  86035. /**
  86036. * If vertex alpha should be applied to the mesh
  86037. */
  86038. readonly useVertexAlpha?: boolean | undefined;
  86039. /**
  86040. * Color of the line (Default: White)
  86041. */
  86042. color: Color3;
  86043. /**
  86044. * Alpha of the line (Default: 1)
  86045. */
  86046. alpha: number;
  86047. /**
  86048. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86049. * This margin is expressed in world space coordinates, so its value may vary.
  86050. * Default value is 0.1
  86051. */
  86052. intersectionThreshold: number;
  86053. private _colorShader;
  86054. private color4;
  86055. /**
  86056. * Creates a new LinesMesh
  86057. * @param name defines the name
  86058. * @param scene defines the hosting scene
  86059. * @param parent defines the parent mesh if any
  86060. * @param source defines the optional source LinesMesh used to clone data from
  86061. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86062. * When false, achieved by calling a clone(), also passing False.
  86063. * This will make creation of children, recursive.
  86064. * @param useVertexColor defines if this LinesMesh supports vertex color
  86065. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86066. */
  86067. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  86068. /**
  86069. * If vertex color should be applied to the mesh
  86070. */
  86071. useVertexColor?: boolean | undefined,
  86072. /**
  86073. * If vertex alpha should be applied to the mesh
  86074. */
  86075. useVertexAlpha?: boolean | undefined);
  86076. private _addClipPlaneDefine;
  86077. private _removeClipPlaneDefine;
  86078. isReady(): boolean;
  86079. /**
  86080. * Returns the string "LineMesh"
  86081. */
  86082. getClassName(): string;
  86083. /**
  86084. * @hidden
  86085. */
  86086. /**
  86087. * @hidden
  86088. */
  86089. material: Material;
  86090. /**
  86091. * @hidden
  86092. */
  86093. readonly checkCollisions: boolean;
  86094. /** @hidden */
  86095. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86096. /** @hidden */
  86097. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86098. /**
  86099. * Disposes of the line mesh
  86100. * @param doNotRecurse If children should be disposed
  86101. */
  86102. dispose(doNotRecurse?: boolean): void;
  86103. /**
  86104. * Returns a new LineMesh object cloned from the current one.
  86105. */
  86106. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86107. /**
  86108. * Creates a new InstancedLinesMesh object from the mesh model.
  86109. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86110. * @param name defines the name of the new instance
  86111. * @returns a new InstancedLinesMesh
  86112. */
  86113. createInstance(name: string): InstancedLinesMesh;
  86114. }
  86115. /**
  86116. * Creates an instance based on a source LinesMesh
  86117. */
  86118. export class InstancedLinesMesh extends InstancedMesh {
  86119. /**
  86120. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86121. * This margin is expressed in world space coordinates, so its value may vary.
  86122. * Initilized with the intersectionThreshold value of the source LinesMesh
  86123. */
  86124. intersectionThreshold: number;
  86125. constructor(name: string, source: LinesMesh);
  86126. /**
  86127. * Returns the string "InstancedLinesMesh".
  86128. */
  86129. getClassName(): string;
  86130. }
  86131. }
  86132. declare module BABYLON {
  86133. /** @hidden */
  86134. export var linePixelShader: {
  86135. name: string;
  86136. shader: string;
  86137. };
  86138. }
  86139. declare module BABYLON {
  86140. /** @hidden */
  86141. export var lineVertexShader: {
  86142. name: string;
  86143. shader: string;
  86144. };
  86145. }
  86146. declare module BABYLON {
  86147. interface AbstractMesh {
  86148. /**
  86149. * Gets the edgesRenderer associated with the mesh
  86150. */
  86151. edgesRenderer: Nullable<EdgesRenderer>;
  86152. }
  86153. interface LinesMesh {
  86154. /**
  86155. * Enables the edge rendering mode on the mesh.
  86156. * This mode makes the mesh edges visible
  86157. * @param epsilon defines the maximal distance between two angles to detect a face
  86158. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86159. * @returns the currentAbstractMesh
  86160. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86161. */
  86162. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86163. }
  86164. interface InstancedLinesMesh {
  86165. /**
  86166. * Enables the edge rendering mode on the mesh.
  86167. * This mode makes the mesh edges visible
  86168. * @param epsilon defines the maximal distance between two angles to detect a face
  86169. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86170. * @returns the current InstancedLinesMesh
  86171. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86172. */
  86173. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86174. }
  86175. /**
  86176. * Defines the minimum contract an Edges renderer should follow.
  86177. */
  86178. export interface IEdgesRenderer extends IDisposable {
  86179. /**
  86180. * Gets or sets a boolean indicating if the edgesRenderer is active
  86181. */
  86182. isEnabled: boolean;
  86183. /**
  86184. * Renders the edges of the attached mesh,
  86185. */
  86186. render(): void;
  86187. /**
  86188. * Checks wether or not the edges renderer is ready to render.
  86189. * @return true if ready, otherwise false.
  86190. */
  86191. isReady(): boolean;
  86192. }
  86193. /**
  86194. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86195. */
  86196. export class EdgesRenderer implements IEdgesRenderer {
  86197. /**
  86198. * Define the size of the edges with an orthographic camera
  86199. */
  86200. edgesWidthScalerForOrthographic: number;
  86201. /**
  86202. * Define the size of the edges with a perspective camera
  86203. */
  86204. edgesWidthScalerForPerspective: number;
  86205. protected _source: AbstractMesh;
  86206. protected _linesPositions: number[];
  86207. protected _linesNormals: number[];
  86208. protected _linesIndices: number[];
  86209. protected _epsilon: number;
  86210. protected _indicesCount: number;
  86211. protected _lineShader: ShaderMaterial;
  86212. protected _ib: DataBuffer;
  86213. protected _buffers: {
  86214. [key: string]: Nullable<VertexBuffer>;
  86215. };
  86216. protected _checkVerticesInsteadOfIndices: boolean;
  86217. private _meshRebuildObserver;
  86218. private _meshDisposeObserver;
  86219. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86220. isEnabled: boolean;
  86221. /**
  86222. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86223. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86224. * @param source Mesh used to create edges
  86225. * @param epsilon sum of angles in adjacency to check for edge
  86226. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86227. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86228. */
  86229. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86230. protected _prepareRessources(): void;
  86231. /** @hidden */
  86232. _rebuild(): void;
  86233. /**
  86234. * Releases the required resources for the edges renderer
  86235. */
  86236. dispose(): void;
  86237. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86238. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86239. /**
  86240. * Checks if the pair of p0 and p1 is en edge
  86241. * @param faceIndex
  86242. * @param edge
  86243. * @param faceNormals
  86244. * @param p0
  86245. * @param p1
  86246. * @private
  86247. */
  86248. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86249. /**
  86250. * push line into the position, normal and index buffer
  86251. * @protected
  86252. */
  86253. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86254. /**
  86255. * Generates lines edges from adjacencjes
  86256. * @private
  86257. */
  86258. _generateEdgesLines(): void;
  86259. /**
  86260. * Checks wether or not the edges renderer is ready to render.
  86261. * @return true if ready, otherwise false.
  86262. */
  86263. isReady(): boolean;
  86264. /**
  86265. * Renders the edges of the attached mesh,
  86266. */
  86267. render(): void;
  86268. }
  86269. /**
  86270. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86271. */
  86272. export class LineEdgesRenderer extends EdgesRenderer {
  86273. /**
  86274. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86275. * @param source LineMesh used to generate edges
  86276. * @param epsilon not important (specified angle for edge detection)
  86277. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86278. */
  86279. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86280. /**
  86281. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  86282. */
  86283. _generateEdgesLines(): void;
  86284. }
  86285. }
  86286. declare module BABYLON {
  86287. /**
  86288. * This represents the object necessary to create a rendering group.
  86289. * This is exclusively used and created by the rendering manager.
  86290. * To modify the behavior, you use the available helpers in your scene or meshes.
  86291. * @hidden
  86292. */
  86293. export class RenderingGroup {
  86294. index: number;
  86295. private static _zeroVector;
  86296. private _scene;
  86297. private _opaqueSubMeshes;
  86298. private _transparentSubMeshes;
  86299. private _alphaTestSubMeshes;
  86300. private _depthOnlySubMeshes;
  86301. private _particleSystems;
  86302. private _spriteManagers;
  86303. private _opaqueSortCompareFn;
  86304. private _alphaTestSortCompareFn;
  86305. private _transparentSortCompareFn;
  86306. private _renderOpaque;
  86307. private _renderAlphaTest;
  86308. private _renderTransparent;
  86309. /** @hidden */
  86310. _edgesRenderers: SmartArray<IEdgesRenderer>;
  86311. onBeforeTransparentRendering: () => void;
  86312. /**
  86313. * Set the opaque sort comparison function.
  86314. * If null the sub meshes will be render in the order they were created
  86315. */
  86316. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86317. /**
  86318. * Set the alpha test sort comparison function.
  86319. * If null the sub meshes will be render in the order they were created
  86320. */
  86321. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86322. /**
  86323. * Set the transparent sort comparison function.
  86324. * If null the sub meshes will be render in the order they were created
  86325. */
  86326. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86327. /**
  86328. * Creates a new rendering group.
  86329. * @param index The rendering group index
  86330. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  86331. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  86332. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  86333. */
  86334. 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>);
  86335. /**
  86336. * Render all the sub meshes contained in the group.
  86337. * @param customRenderFunction Used to override the default render behaviour of the group.
  86338. * @returns true if rendered some submeshes.
  86339. */
  86340. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  86341. /**
  86342. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  86343. * @param subMeshes The submeshes to render
  86344. */
  86345. private renderOpaqueSorted;
  86346. /**
  86347. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  86348. * @param subMeshes The submeshes to render
  86349. */
  86350. private renderAlphaTestSorted;
  86351. /**
  86352. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  86353. * @param subMeshes The submeshes to render
  86354. */
  86355. private renderTransparentSorted;
  86356. /**
  86357. * Renders the submeshes in a specified order.
  86358. * @param subMeshes The submeshes to sort before render
  86359. * @param sortCompareFn The comparison function use to sort
  86360. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  86361. * @param transparent Specifies to activate blending if true
  86362. */
  86363. private static renderSorted;
  86364. /**
  86365. * Renders the submeshes in the order they were dispatched (no sort applied).
  86366. * @param subMeshes The submeshes to render
  86367. */
  86368. private static renderUnsorted;
  86369. /**
  86370. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86371. * are rendered back to front if in the same alpha index.
  86372. *
  86373. * @param a The first submesh
  86374. * @param b The second submesh
  86375. * @returns The result of the comparison
  86376. */
  86377. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  86378. /**
  86379. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86380. * are rendered back to front.
  86381. *
  86382. * @param a The first submesh
  86383. * @param b The second submesh
  86384. * @returns The result of the comparison
  86385. */
  86386. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  86387. /**
  86388. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86389. * are rendered front to back (prevent overdraw).
  86390. *
  86391. * @param a The first submesh
  86392. * @param b The second submesh
  86393. * @returns The result of the comparison
  86394. */
  86395. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  86396. /**
  86397. * Resets the different lists of submeshes to prepare a new frame.
  86398. */
  86399. prepare(): void;
  86400. dispose(): void;
  86401. /**
  86402. * Inserts the submesh in its correct queue depending on its material.
  86403. * @param subMesh The submesh to dispatch
  86404. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86405. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86406. */
  86407. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86408. dispatchSprites(spriteManager: ISpriteManager): void;
  86409. dispatchParticles(particleSystem: IParticleSystem): void;
  86410. private _renderParticles;
  86411. private _renderSprites;
  86412. }
  86413. }
  86414. declare module BABYLON {
  86415. /**
  86416. * Interface describing the different options available in the rendering manager
  86417. * regarding Auto Clear between groups.
  86418. */
  86419. export interface IRenderingManagerAutoClearSetup {
  86420. /**
  86421. * Defines whether or not autoclear is enable.
  86422. */
  86423. autoClear: boolean;
  86424. /**
  86425. * Defines whether or not to autoclear the depth buffer.
  86426. */
  86427. depth: boolean;
  86428. /**
  86429. * Defines whether or not to autoclear the stencil buffer.
  86430. */
  86431. stencil: boolean;
  86432. }
  86433. /**
  86434. * This class is used by the onRenderingGroupObservable
  86435. */
  86436. export class RenderingGroupInfo {
  86437. /**
  86438. * The Scene that being rendered
  86439. */
  86440. scene: Scene;
  86441. /**
  86442. * The camera currently used for the rendering pass
  86443. */
  86444. camera: Nullable<Camera>;
  86445. /**
  86446. * The ID of the renderingGroup being processed
  86447. */
  86448. renderingGroupId: number;
  86449. }
  86450. /**
  86451. * This is the manager responsible of all the rendering for meshes sprites and particles.
  86452. * It is enable to manage the different groups as well as the different necessary sort functions.
  86453. * This should not be used directly aside of the few static configurations
  86454. */
  86455. export class RenderingManager {
  86456. /**
  86457. * The max id used for rendering groups (not included)
  86458. */
  86459. static MAX_RENDERINGGROUPS: number;
  86460. /**
  86461. * The min id used for rendering groups (included)
  86462. */
  86463. static MIN_RENDERINGGROUPS: number;
  86464. /**
  86465. * Used to globally prevent autoclearing scenes.
  86466. */
  86467. static AUTOCLEAR: boolean;
  86468. /**
  86469. * @hidden
  86470. */
  86471. _useSceneAutoClearSetup: boolean;
  86472. private _scene;
  86473. private _renderingGroups;
  86474. private _depthStencilBufferAlreadyCleaned;
  86475. private _autoClearDepthStencil;
  86476. private _customOpaqueSortCompareFn;
  86477. private _customAlphaTestSortCompareFn;
  86478. private _customTransparentSortCompareFn;
  86479. private _renderingGroupInfo;
  86480. /**
  86481. * Instantiates a new rendering group for a particular scene
  86482. * @param scene Defines the scene the groups belongs to
  86483. */
  86484. constructor(scene: Scene);
  86485. private _clearDepthStencilBuffer;
  86486. /**
  86487. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  86488. * @hidden
  86489. */
  86490. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  86491. /**
  86492. * Resets the different information of the group to prepare a new frame
  86493. * @hidden
  86494. */
  86495. reset(): void;
  86496. /**
  86497. * Dispose and release the group and its associated resources.
  86498. * @hidden
  86499. */
  86500. dispose(): void;
  86501. /**
  86502. * Clear the info related to rendering groups preventing retention points during dispose.
  86503. */
  86504. freeRenderingGroups(): void;
  86505. private _prepareRenderingGroup;
  86506. /**
  86507. * Add a sprite manager to the rendering manager in order to render it this frame.
  86508. * @param spriteManager Define the sprite manager to render
  86509. */
  86510. dispatchSprites(spriteManager: ISpriteManager): void;
  86511. /**
  86512. * Add a particle system to the rendering manager in order to render it this frame.
  86513. * @param particleSystem Define the particle system to render
  86514. */
  86515. dispatchParticles(particleSystem: IParticleSystem): void;
  86516. /**
  86517. * Add a submesh to the manager in order to render it this frame
  86518. * @param subMesh The submesh to dispatch
  86519. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86520. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86521. */
  86522. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86523. /**
  86524. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86525. * This allowed control for front to back rendering or reversly depending of the special needs.
  86526. *
  86527. * @param renderingGroupId The rendering group id corresponding to its index
  86528. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86529. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86530. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86531. */
  86532. 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;
  86533. /**
  86534. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86535. *
  86536. * @param renderingGroupId The rendering group id corresponding to its index
  86537. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86538. * @param depth Automatically clears depth between groups if true and autoClear is true.
  86539. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  86540. */
  86541. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  86542. /**
  86543. * Gets the current auto clear configuration for one rendering group of the rendering
  86544. * manager.
  86545. * @param index the rendering group index to get the information for
  86546. * @returns The auto clear setup for the requested rendering group
  86547. */
  86548. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  86549. }
  86550. }
  86551. declare module BABYLON {
  86552. /**
  86553. * This Helps creating a texture that will be created from a camera in your scene.
  86554. * It is basically a dynamic texture that could be used to create special effects for instance.
  86555. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  86556. */
  86557. export class RenderTargetTexture extends Texture {
  86558. isCube: boolean;
  86559. /**
  86560. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  86561. */
  86562. static readonly REFRESHRATE_RENDER_ONCE: number;
  86563. /**
  86564. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  86565. */
  86566. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  86567. /**
  86568. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  86569. * the central point of your effect and can save a lot of performances.
  86570. */
  86571. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  86572. /**
  86573. * Use this predicate to dynamically define the list of mesh you want to render.
  86574. * If set, the renderList property will be overwritten.
  86575. */
  86576. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  86577. private _renderList;
  86578. /**
  86579. * Use this list to define the list of mesh you want to render.
  86580. */
  86581. renderList: Nullable<Array<AbstractMesh>>;
  86582. private _hookArray;
  86583. /**
  86584. * Define if particles should be rendered in your texture.
  86585. */
  86586. renderParticles: boolean;
  86587. /**
  86588. * Define if sprites should be rendered in your texture.
  86589. */
  86590. renderSprites: boolean;
  86591. /**
  86592. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  86593. */
  86594. coordinatesMode: number;
  86595. /**
  86596. * Define the camera used to render the texture.
  86597. */
  86598. activeCamera: Nullable<Camera>;
  86599. /**
  86600. * Override the render function of the texture with your own one.
  86601. */
  86602. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  86603. /**
  86604. * Define if camera post processes should be use while rendering the texture.
  86605. */
  86606. useCameraPostProcesses: boolean;
  86607. /**
  86608. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  86609. */
  86610. ignoreCameraViewport: boolean;
  86611. private _postProcessManager;
  86612. private _postProcesses;
  86613. private _resizeObserver;
  86614. /**
  86615. * An event triggered when the texture is unbind.
  86616. */
  86617. onBeforeBindObservable: Observable<RenderTargetTexture>;
  86618. /**
  86619. * An event triggered when the texture is unbind.
  86620. */
  86621. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  86622. private _onAfterUnbindObserver;
  86623. /**
  86624. * Set a after unbind callback in the texture.
  86625. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  86626. */
  86627. onAfterUnbind: () => void;
  86628. /**
  86629. * An event triggered before rendering the texture
  86630. */
  86631. onBeforeRenderObservable: Observable<number>;
  86632. private _onBeforeRenderObserver;
  86633. /**
  86634. * Set a before render callback in the texture.
  86635. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  86636. */
  86637. onBeforeRender: (faceIndex: number) => void;
  86638. /**
  86639. * An event triggered after rendering the texture
  86640. */
  86641. onAfterRenderObservable: Observable<number>;
  86642. private _onAfterRenderObserver;
  86643. /**
  86644. * Set a after render callback in the texture.
  86645. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  86646. */
  86647. onAfterRender: (faceIndex: number) => void;
  86648. /**
  86649. * An event triggered after the texture clear
  86650. */
  86651. onClearObservable: Observable<Engine>;
  86652. private _onClearObserver;
  86653. /**
  86654. * Set a clear callback in the texture.
  86655. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  86656. */
  86657. onClear: (Engine: Engine) => void;
  86658. /**
  86659. * An event triggered when the texture is resized.
  86660. */
  86661. onResizeObservable: Observable<RenderTargetTexture>;
  86662. /**
  86663. * Define the clear color of the Render Target if it should be different from the scene.
  86664. */
  86665. clearColor: Color4;
  86666. protected _size: number | {
  86667. width: number;
  86668. height: number;
  86669. };
  86670. protected _initialSizeParameter: number | {
  86671. width: number;
  86672. height: number;
  86673. } | {
  86674. ratio: number;
  86675. };
  86676. protected _sizeRatio: Nullable<number>;
  86677. /** @hidden */
  86678. _generateMipMaps: boolean;
  86679. protected _renderingManager: RenderingManager;
  86680. /** @hidden */
  86681. _waitingRenderList: string[];
  86682. protected _doNotChangeAspectRatio: boolean;
  86683. protected _currentRefreshId: number;
  86684. protected _refreshRate: number;
  86685. protected _textureMatrix: Matrix;
  86686. protected _samples: number;
  86687. protected _renderTargetOptions: RenderTargetCreationOptions;
  86688. /**
  86689. * Gets render target creation options that were used.
  86690. */
  86691. readonly renderTargetOptions: RenderTargetCreationOptions;
  86692. protected _engine: Engine;
  86693. protected _onRatioRescale(): void;
  86694. /**
  86695. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  86696. * It must define where the camera used to render the texture is set
  86697. */
  86698. boundingBoxPosition: Vector3;
  86699. private _boundingBoxSize;
  86700. /**
  86701. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  86702. * When defined, the cubemap will switch to local mode
  86703. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86704. * @example https://www.babylonjs-playground.com/#RNASML
  86705. */
  86706. boundingBoxSize: Vector3;
  86707. /**
  86708. * In case the RTT has been created with a depth texture, get the associated
  86709. * depth texture.
  86710. * Otherwise, return null.
  86711. */
  86712. depthStencilTexture: Nullable<InternalTexture>;
  86713. /**
  86714. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  86715. * or used a shadow, depth texture...
  86716. * @param name The friendly name of the texture
  86717. * @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)
  86718. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  86719. * @param generateMipMaps True if mip maps need to be generated after render.
  86720. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  86721. * @param type The type of the buffer in the RTT (int, half float, float...)
  86722. * @param isCube True if a cube texture needs to be created
  86723. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  86724. * @param generateDepthBuffer True to generate a depth buffer
  86725. * @param generateStencilBuffer True to generate a stencil buffer
  86726. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  86727. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  86728. * @param delayAllocation if the texture allocation should be delayed (default: false)
  86729. */
  86730. constructor(name: string, size: number | {
  86731. width: number;
  86732. height: number;
  86733. } | {
  86734. ratio: number;
  86735. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  86736. /**
  86737. * Creates a depth stencil texture.
  86738. * This is only available in WebGL 2 or with the depth texture extension available.
  86739. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  86740. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  86741. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  86742. */
  86743. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  86744. private _processSizeParameter;
  86745. /**
  86746. * Define the number of samples to use in case of MSAA.
  86747. * It defaults to one meaning no MSAA has been enabled.
  86748. */
  86749. samples: number;
  86750. /**
  86751. * Resets the refresh counter of the texture and start bak from scratch.
  86752. * Could be useful to regenerate the texture if it is setup to render only once.
  86753. */
  86754. resetRefreshCounter(): void;
  86755. /**
  86756. * Define the refresh rate of the texture or the rendering frequency.
  86757. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86758. */
  86759. refreshRate: number;
  86760. /**
  86761. * Adds a post process to the render target rendering passes.
  86762. * @param postProcess define the post process to add
  86763. */
  86764. addPostProcess(postProcess: PostProcess): void;
  86765. /**
  86766. * Clear all the post processes attached to the render target
  86767. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  86768. */
  86769. clearPostProcesses(dispose?: boolean): void;
  86770. /**
  86771. * Remove one of the post process from the list of attached post processes to the texture
  86772. * @param postProcess define the post process to remove from the list
  86773. */
  86774. removePostProcess(postProcess: PostProcess): void;
  86775. /** @hidden */
  86776. _shouldRender(): boolean;
  86777. /**
  86778. * Gets the actual render size of the texture.
  86779. * @returns the width of the render size
  86780. */
  86781. getRenderSize(): number;
  86782. /**
  86783. * Gets the actual render width of the texture.
  86784. * @returns the width of the render size
  86785. */
  86786. getRenderWidth(): number;
  86787. /**
  86788. * Gets the actual render height of the texture.
  86789. * @returns the height of the render size
  86790. */
  86791. getRenderHeight(): number;
  86792. /**
  86793. * Get if the texture can be rescaled or not.
  86794. */
  86795. readonly canRescale: boolean;
  86796. /**
  86797. * Resize the texture using a ratio.
  86798. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  86799. */
  86800. scale(ratio: number): void;
  86801. /**
  86802. * Get the texture reflection matrix used to rotate/transform the reflection.
  86803. * @returns the reflection matrix
  86804. */
  86805. getReflectionTextureMatrix(): Matrix;
  86806. /**
  86807. * Resize the texture to a new desired size.
  86808. * Be carrefull as it will recreate all the data in the new texture.
  86809. * @param size Define the new size. It can be:
  86810. * - a number for squared texture,
  86811. * - an object containing { width: number, height: number }
  86812. * - or an object containing a ratio { ratio: number }
  86813. */
  86814. resize(size: number | {
  86815. width: number;
  86816. height: number;
  86817. } | {
  86818. ratio: number;
  86819. }): void;
  86820. /**
  86821. * Renders all the objects from the render list into the texture.
  86822. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  86823. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  86824. */
  86825. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  86826. private _bestReflectionRenderTargetDimension;
  86827. /**
  86828. * @hidden
  86829. * @param faceIndex face index to bind to if this is a cubetexture
  86830. */
  86831. _bindFrameBuffer(faceIndex?: number): void;
  86832. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  86833. private renderToTarget;
  86834. /**
  86835. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86836. * This allowed control for front to back rendering or reversly depending of the special needs.
  86837. *
  86838. * @param renderingGroupId The rendering group id corresponding to its index
  86839. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86840. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86841. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86842. */
  86843. 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;
  86844. /**
  86845. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86846. *
  86847. * @param renderingGroupId The rendering group id corresponding to its index
  86848. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86849. */
  86850. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  86851. /**
  86852. * Clones the texture.
  86853. * @returns the cloned texture
  86854. */
  86855. clone(): RenderTargetTexture;
  86856. /**
  86857. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86858. * @returns The JSON representation of the texture
  86859. */
  86860. serialize(): any;
  86861. /**
  86862. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  86863. */
  86864. disposeFramebufferObjects(): void;
  86865. /**
  86866. * Dispose the texture and release its associated resources.
  86867. */
  86868. dispose(): void;
  86869. /** @hidden */
  86870. _rebuild(): void;
  86871. /**
  86872. * Clear the info related to rendering groups preventing retention point in material dispose.
  86873. */
  86874. freeRenderingGroups(): void;
  86875. /**
  86876. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  86877. * @returns the view count
  86878. */
  86879. getViewCount(): number;
  86880. }
  86881. }
  86882. declare module BABYLON {
  86883. /**
  86884. * Base class for the main features of a material in Babylon.js
  86885. */
  86886. export class Material implements IAnimatable {
  86887. /**
  86888. * Returns the triangle fill mode
  86889. */
  86890. static readonly TriangleFillMode: number;
  86891. /**
  86892. * Returns the wireframe mode
  86893. */
  86894. static readonly WireFrameFillMode: number;
  86895. /**
  86896. * Returns the point fill mode
  86897. */
  86898. static readonly PointFillMode: number;
  86899. /**
  86900. * Returns the point list draw mode
  86901. */
  86902. static readonly PointListDrawMode: number;
  86903. /**
  86904. * Returns the line list draw mode
  86905. */
  86906. static readonly LineListDrawMode: number;
  86907. /**
  86908. * Returns the line loop draw mode
  86909. */
  86910. static readonly LineLoopDrawMode: number;
  86911. /**
  86912. * Returns the line strip draw mode
  86913. */
  86914. static readonly LineStripDrawMode: number;
  86915. /**
  86916. * Returns the triangle strip draw mode
  86917. */
  86918. static readonly TriangleStripDrawMode: number;
  86919. /**
  86920. * Returns the triangle fan draw mode
  86921. */
  86922. static readonly TriangleFanDrawMode: number;
  86923. /**
  86924. * Stores the clock-wise side orientation
  86925. */
  86926. static readonly ClockWiseSideOrientation: number;
  86927. /**
  86928. * Stores the counter clock-wise side orientation
  86929. */
  86930. static readonly CounterClockWiseSideOrientation: number;
  86931. /**
  86932. * The dirty texture flag value
  86933. */
  86934. static readonly TextureDirtyFlag: number;
  86935. /**
  86936. * The dirty light flag value
  86937. */
  86938. static readonly LightDirtyFlag: number;
  86939. /**
  86940. * The dirty fresnel flag value
  86941. */
  86942. static readonly FresnelDirtyFlag: number;
  86943. /**
  86944. * The dirty attribute flag value
  86945. */
  86946. static readonly AttributesDirtyFlag: number;
  86947. /**
  86948. * The dirty misc flag value
  86949. */
  86950. static readonly MiscDirtyFlag: number;
  86951. /**
  86952. * The all dirty flag value
  86953. */
  86954. static readonly AllDirtyFlag: number;
  86955. /**
  86956. * The ID of the material
  86957. */
  86958. id: string;
  86959. /**
  86960. * Gets or sets the unique id of the material
  86961. */
  86962. uniqueId: number;
  86963. /**
  86964. * The name of the material
  86965. */
  86966. name: string;
  86967. /**
  86968. * Gets or sets user defined metadata
  86969. */
  86970. metadata: any;
  86971. /**
  86972. * For internal use only. Please do not use.
  86973. */
  86974. reservedDataStore: any;
  86975. /**
  86976. * Specifies if the ready state should be checked on each call
  86977. */
  86978. checkReadyOnEveryCall: boolean;
  86979. /**
  86980. * Specifies if the ready state should be checked once
  86981. */
  86982. checkReadyOnlyOnce: boolean;
  86983. /**
  86984. * The state of the material
  86985. */
  86986. state: string;
  86987. /**
  86988. * The alpha value of the material
  86989. */
  86990. protected _alpha: number;
  86991. /**
  86992. * List of inspectable custom properties (used by the Inspector)
  86993. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86994. */
  86995. inspectableCustomProperties: IInspectable[];
  86996. /**
  86997. * Sets the alpha value of the material
  86998. */
  86999. /**
  87000. * Gets the alpha value of the material
  87001. */
  87002. alpha: number;
  87003. /**
  87004. * Specifies if back face culling is enabled
  87005. */
  87006. protected _backFaceCulling: boolean;
  87007. /**
  87008. * Sets the back-face culling state
  87009. */
  87010. /**
  87011. * Gets the back-face culling state
  87012. */
  87013. backFaceCulling: boolean;
  87014. /**
  87015. * Stores the value for side orientation
  87016. */
  87017. sideOrientation: number;
  87018. /**
  87019. * Callback triggered when the material is compiled
  87020. */
  87021. onCompiled: Nullable<(effect: Effect) => void>;
  87022. /**
  87023. * Callback triggered when an error occurs
  87024. */
  87025. onError: Nullable<(effect: Effect, errors: string) => void>;
  87026. /**
  87027. * Callback triggered to get the render target textures
  87028. */
  87029. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  87030. /**
  87031. * Gets a boolean indicating that current material needs to register RTT
  87032. */
  87033. readonly hasRenderTargetTextures: boolean;
  87034. /**
  87035. * Specifies if the material should be serialized
  87036. */
  87037. doNotSerialize: boolean;
  87038. /**
  87039. * @hidden
  87040. */
  87041. _storeEffectOnSubMeshes: boolean;
  87042. /**
  87043. * Stores the animations for the material
  87044. */
  87045. animations: Nullable<Array<Animation>>;
  87046. /**
  87047. * An event triggered when the material is disposed
  87048. */
  87049. onDisposeObservable: Observable<Material>;
  87050. /**
  87051. * An observer which watches for dispose events
  87052. */
  87053. private _onDisposeObserver;
  87054. private _onUnBindObservable;
  87055. /**
  87056. * Called during a dispose event
  87057. */
  87058. onDispose: () => void;
  87059. private _onBindObservable;
  87060. /**
  87061. * An event triggered when the material is bound
  87062. */
  87063. readonly onBindObservable: Observable<AbstractMesh>;
  87064. /**
  87065. * An observer which watches for bind events
  87066. */
  87067. private _onBindObserver;
  87068. /**
  87069. * Called during a bind event
  87070. */
  87071. onBind: (Mesh: AbstractMesh) => void;
  87072. /**
  87073. * An event triggered when the material is unbound
  87074. */
  87075. readonly onUnBindObservable: Observable<Material>;
  87076. /**
  87077. * Stores the value of the alpha mode
  87078. */
  87079. private _alphaMode;
  87080. /**
  87081. * Sets the value of the alpha mode.
  87082. *
  87083. * | Value | Type | Description |
  87084. * | --- | --- | --- |
  87085. * | 0 | ALPHA_DISABLE | |
  87086. * | 1 | ALPHA_ADD | |
  87087. * | 2 | ALPHA_COMBINE | |
  87088. * | 3 | ALPHA_SUBTRACT | |
  87089. * | 4 | ALPHA_MULTIPLY | |
  87090. * | 5 | ALPHA_MAXIMIZED | |
  87091. * | 6 | ALPHA_ONEONE | |
  87092. * | 7 | ALPHA_PREMULTIPLIED | |
  87093. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  87094. * | 9 | ALPHA_INTERPOLATE | |
  87095. * | 10 | ALPHA_SCREENMODE | |
  87096. *
  87097. */
  87098. /**
  87099. * Gets the value of the alpha mode
  87100. */
  87101. alphaMode: number;
  87102. /**
  87103. * Stores the state of the need depth pre-pass value
  87104. */
  87105. private _needDepthPrePass;
  87106. /**
  87107. * Sets the need depth pre-pass value
  87108. */
  87109. /**
  87110. * Gets the depth pre-pass value
  87111. */
  87112. needDepthPrePass: boolean;
  87113. /**
  87114. * Specifies if depth writing should be disabled
  87115. */
  87116. disableDepthWrite: boolean;
  87117. /**
  87118. * Specifies if depth writing should be forced
  87119. */
  87120. forceDepthWrite: boolean;
  87121. /**
  87122. * Specifies if there should be a separate pass for culling
  87123. */
  87124. separateCullingPass: boolean;
  87125. /**
  87126. * Stores the state specifing if fog should be enabled
  87127. */
  87128. private _fogEnabled;
  87129. /**
  87130. * Sets the state for enabling fog
  87131. */
  87132. /**
  87133. * Gets the value of the fog enabled state
  87134. */
  87135. fogEnabled: boolean;
  87136. /**
  87137. * Stores the size of points
  87138. */
  87139. pointSize: number;
  87140. /**
  87141. * Stores the z offset value
  87142. */
  87143. zOffset: number;
  87144. /**
  87145. * Gets a value specifying if wireframe mode is enabled
  87146. */
  87147. /**
  87148. * Sets the state of wireframe mode
  87149. */
  87150. wireframe: boolean;
  87151. /**
  87152. * Gets the value specifying if point clouds are enabled
  87153. */
  87154. /**
  87155. * Sets the state of point cloud mode
  87156. */
  87157. pointsCloud: boolean;
  87158. /**
  87159. * Gets the material fill mode
  87160. */
  87161. /**
  87162. * Sets the material fill mode
  87163. */
  87164. fillMode: number;
  87165. /**
  87166. * @hidden
  87167. * Stores the effects for the material
  87168. */
  87169. _effect: Nullable<Effect>;
  87170. /**
  87171. * @hidden
  87172. * Specifies if the material was previously ready
  87173. */
  87174. _wasPreviouslyReady: boolean;
  87175. /**
  87176. * Specifies if uniform buffers should be used
  87177. */
  87178. private _useUBO;
  87179. /**
  87180. * Stores a reference to the scene
  87181. */
  87182. private _scene;
  87183. /**
  87184. * Stores the fill mode state
  87185. */
  87186. private _fillMode;
  87187. /**
  87188. * Specifies if the depth write state should be cached
  87189. */
  87190. private _cachedDepthWriteState;
  87191. /**
  87192. * Stores the uniform buffer
  87193. */
  87194. protected _uniformBuffer: UniformBuffer;
  87195. /** @hidden */
  87196. _indexInSceneMaterialArray: number;
  87197. /** @hidden */
  87198. meshMap: Nullable<{
  87199. [id: string]: AbstractMesh | undefined;
  87200. }>;
  87201. /**
  87202. * Creates a material instance
  87203. * @param name defines the name of the material
  87204. * @param scene defines the scene to reference
  87205. * @param doNotAdd specifies if the material should be added to the scene
  87206. */
  87207. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87208. /**
  87209. * Returns a string representation of the current material
  87210. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87211. * @returns a string with material information
  87212. */
  87213. toString(fullDetails?: boolean): string;
  87214. /**
  87215. * Gets the class name of the material
  87216. * @returns a string with the class name of the material
  87217. */
  87218. getClassName(): string;
  87219. /**
  87220. * Specifies if updates for the material been locked
  87221. */
  87222. readonly isFrozen: boolean;
  87223. /**
  87224. * Locks updates for the material
  87225. */
  87226. freeze(): void;
  87227. /**
  87228. * Unlocks updates for the material
  87229. */
  87230. unfreeze(): void;
  87231. /**
  87232. * Specifies if the material is ready to be used
  87233. * @param mesh defines the mesh to check
  87234. * @param useInstances specifies if instances should be used
  87235. * @returns a boolean indicating if the material is ready to be used
  87236. */
  87237. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87238. /**
  87239. * Specifies that the submesh is ready to be used
  87240. * @param mesh defines the mesh to check
  87241. * @param subMesh defines which submesh to check
  87242. * @param useInstances specifies that instances should be used
  87243. * @returns a boolean indicating that the submesh is ready or not
  87244. */
  87245. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87246. /**
  87247. * Returns the material effect
  87248. * @returns the effect associated with the material
  87249. */
  87250. getEffect(): Nullable<Effect>;
  87251. /**
  87252. * Returns the current scene
  87253. * @returns a Scene
  87254. */
  87255. getScene(): Scene;
  87256. /**
  87257. * Specifies if the material will require alpha blending
  87258. * @returns a boolean specifying if alpha blending is needed
  87259. */
  87260. needAlphaBlending(): boolean;
  87261. /**
  87262. * Specifies if the mesh will require alpha blending
  87263. * @param mesh defines the mesh to check
  87264. * @returns a boolean specifying if alpha blending is needed for the mesh
  87265. */
  87266. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87267. /**
  87268. * Specifies if this material should be rendered in alpha test mode
  87269. * @returns a boolean specifying if an alpha test is needed.
  87270. */
  87271. needAlphaTesting(): boolean;
  87272. /**
  87273. * Gets the texture used for the alpha test
  87274. * @returns the texture to use for alpha testing
  87275. */
  87276. getAlphaTestTexture(): Nullable<BaseTexture>;
  87277. /**
  87278. * Marks the material to indicate that it needs to be re-calculated
  87279. */
  87280. markDirty(): void;
  87281. /** @hidden */
  87282. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  87283. /**
  87284. * Binds the material to the mesh
  87285. * @param world defines the world transformation matrix
  87286. * @param mesh defines the mesh to bind the material to
  87287. */
  87288. bind(world: Matrix, mesh?: Mesh): void;
  87289. /**
  87290. * Binds the submesh to the material
  87291. * @param world defines the world transformation matrix
  87292. * @param mesh defines the mesh containing the submesh
  87293. * @param subMesh defines the submesh to bind the material to
  87294. */
  87295. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  87296. /**
  87297. * Binds the world matrix to the material
  87298. * @param world defines the world transformation matrix
  87299. */
  87300. bindOnlyWorldMatrix(world: Matrix): void;
  87301. /**
  87302. * Binds the scene's uniform buffer to the effect.
  87303. * @param effect defines the effect to bind to the scene uniform buffer
  87304. * @param sceneUbo defines the uniform buffer storing scene data
  87305. */
  87306. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  87307. /**
  87308. * Binds the view matrix to the effect
  87309. * @param effect defines the effect to bind the view matrix to
  87310. */
  87311. bindView(effect: Effect): void;
  87312. /**
  87313. * Binds the view projection matrix to the effect
  87314. * @param effect defines the effect to bind the view projection matrix to
  87315. */
  87316. bindViewProjection(effect: Effect): void;
  87317. /**
  87318. * Specifies if material alpha testing should be turned on for the mesh
  87319. * @param mesh defines the mesh to check
  87320. */
  87321. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  87322. /**
  87323. * Processes to execute after binding the material to a mesh
  87324. * @param mesh defines the rendered mesh
  87325. */
  87326. protected _afterBind(mesh?: Mesh): void;
  87327. /**
  87328. * Unbinds the material from the mesh
  87329. */
  87330. unbind(): void;
  87331. /**
  87332. * Gets the active textures from the material
  87333. * @returns an array of textures
  87334. */
  87335. getActiveTextures(): BaseTexture[];
  87336. /**
  87337. * Specifies if the material uses a texture
  87338. * @param texture defines the texture to check against the material
  87339. * @returns a boolean specifying if the material uses the texture
  87340. */
  87341. hasTexture(texture: BaseTexture): boolean;
  87342. /**
  87343. * Makes a duplicate of the material, and gives it a new name
  87344. * @param name defines the new name for the duplicated material
  87345. * @returns the cloned material
  87346. */
  87347. clone(name: string): Nullable<Material>;
  87348. /**
  87349. * Gets the meshes bound to the material
  87350. * @returns an array of meshes bound to the material
  87351. */
  87352. getBindedMeshes(): AbstractMesh[];
  87353. /**
  87354. * Force shader compilation
  87355. * @param mesh defines the mesh associated with this material
  87356. * @param onCompiled defines a function to execute once the material is compiled
  87357. * @param options defines the options to configure the compilation
  87358. * @param onError defines a function to execute if the material fails compiling
  87359. */
  87360. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  87361. clipPlane: boolean;
  87362. }>, onError?: (reason: string) => void): void;
  87363. /**
  87364. * Force shader compilation
  87365. * @param mesh defines the mesh that will use this material
  87366. * @param options defines additional options for compiling the shaders
  87367. * @returns a promise that resolves when the compilation completes
  87368. */
  87369. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  87370. clipPlane: boolean;
  87371. }>): Promise<void>;
  87372. private static readonly _AllDirtyCallBack;
  87373. private static readonly _ImageProcessingDirtyCallBack;
  87374. private static readonly _TextureDirtyCallBack;
  87375. private static readonly _FresnelDirtyCallBack;
  87376. private static readonly _MiscDirtyCallBack;
  87377. private static readonly _LightsDirtyCallBack;
  87378. private static readonly _AttributeDirtyCallBack;
  87379. private static _FresnelAndMiscDirtyCallBack;
  87380. private static _TextureAndMiscDirtyCallBack;
  87381. private static readonly _DirtyCallbackArray;
  87382. private static readonly _RunDirtyCallBacks;
  87383. /**
  87384. * Marks a define in the material to indicate that it needs to be re-computed
  87385. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  87386. */
  87387. markAsDirty(flag: number): void;
  87388. /**
  87389. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  87390. * @param func defines a function which checks material defines against the submeshes
  87391. */
  87392. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  87393. /**
  87394. * Indicates that we need to re-calculated for all submeshes
  87395. */
  87396. protected _markAllSubMeshesAsAllDirty(): void;
  87397. /**
  87398. * Indicates that image processing needs to be re-calculated for all submeshes
  87399. */
  87400. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  87401. /**
  87402. * Indicates that textures need to be re-calculated for all submeshes
  87403. */
  87404. protected _markAllSubMeshesAsTexturesDirty(): void;
  87405. /**
  87406. * Indicates that fresnel needs to be re-calculated for all submeshes
  87407. */
  87408. protected _markAllSubMeshesAsFresnelDirty(): void;
  87409. /**
  87410. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  87411. */
  87412. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  87413. /**
  87414. * Indicates that lights need to be re-calculated for all submeshes
  87415. */
  87416. protected _markAllSubMeshesAsLightsDirty(): void;
  87417. /**
  87418. * Indicates that attributes need to be re-calculated for all submeshes
  87419. */
  87420. protected _markAllSubMeshesAsAttributesDirty(): void;
  87421. /**
  87422. * Indicates that misc needs to be re-calculated for all submeshes
  87423. */
  87424. protected _markAllSubMeshesAsMiscDirty(): void;
  87425. /**
  87426. * Indicates that textures and misc need to be re-calculated for all submeshes
  87427. */
  87428. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  87429. /**
  87430. * Disposes the material
  87431. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87432. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87433. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87434. */
  87435. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87436. /** @hidden */
  87437. private releaseVertexArrayObject;
  87438. /**
  87439. * Serializes this material
  87440. * @returns the serialized material object
  87441. */
  87442. serialize(): any;
  87443. /**
  87444. * Creates a material from parsed material data
  87445. * @param parsedMaterial defines parsed material data
  87446. * @param scene defines the hosting scene
  87447. * @param rootUrl defines the root URL to use to load textures
  87448. * @returns a new material
  87449. */
  87450. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  87451. }
  87452. }
  87453. declare module BABYLON {
  87454. /**
  87455. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87456. * separate meshes. This can be use to improve performances.
  87457. * @see http://doc.babylonjs.com/how_to/multi_materials
  87458. */
  87459. export class MultiMaterial extends Material {
  87460. private _subMaterials;
  87461. /**
  87462. * Gets or Sets the list of Materials used within the multi material.
  87463. * They need to be ordered according to the submeshes order in the associated mesh
  87464. */
  87465. subMaterials: Nullable<Material>[];
  87466. /**
  87467. * Function used to align with Node.getChildren()
  87468. * @returns the list of Materials used within the multi material
  87469. */
  87470. getChildren(): Nullable<Material>[];
  87471. /**
  87472. * Instantiates a new Multi Material
  87473. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87474. * separate meshes. This can be use to improve performances.
  87475. * @see http://doc.babylonjs.com/how_to/multi_materials
  87476. * @param name Define the name in the scene
  87477. * @param scene Define the scene the material belongs to
  87478. */
  87479. constructor(name: string, scene: Scene);
  87480. private _hookArray;
  87481. /**
  87482. * Get one of the submaterial by its index in the submaterials array
  87483. * @param index The index to look the sub material at
  87484. * @returns The Material if the index has been defined
  87485. */
  87486. getSubMaterial(index: number): Nullable<Material>;
  87487. /**
  87488. * Get the list of active textures for the whole sub materials list.
  87489. * @returns All the textures that will be used during the rendering
  87490. */
  87491. getActiveTextures(): BaseTexture[];
  87492. /**
  87493. * Gets the current class name of the material e.g. "MultiMaterial"
  87494. * Mainly use in serialization.
  87495. * @returns the class name
  87496. */
  87497. getClassName(): string;
  87498. /**
  87499. * Checks if the material is ready to render the requested sub mesh
  87500. * @param mesh Define the mesh the submesh belongs to
  87501. * @param subMesh Define the sub mesh to look readyness for
  87502. * @param useInstances Define whether or not the material is used with instances
  87503. * @returns true if ready, otherwise false
  87504. */
  87505. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87506. /**
  87507. * Clones the current material and its related sub materials
  87508. * @param name Define the name of the newly cloned material
  87509. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  87510. * @returns the cloned material
  87511. */
  87512. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  87513. /**
  87514. * Serializes the materials into a JSON representation.
  87515. * @returns the JSON representation
  87516. */
  87517. serialize(): any;
  87518. /**
  87519. * Dispose the material and release its associated resources
  87520. * @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)
  87521. * @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)
  87522. * @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)
  87523. */
  87524. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  87525. /**
  87526. * Creates a MultiMaterial from parsed MultiMaterial data.
  87527. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  87528. * @param scene defines the hosting scene
  87529. * @returns a new MultiMaterial
  87530. */
  87531. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  87532. }
  87533. }
  87534. declare module BABYLON {
  87535. /**
  87536. * Base class for submeshes
  87537. */
  87538. export class BaseSubMesh {
  87539. /** @hidden */
  87540. _materialDefines: Nullable<MaterialDefines>;
  87541. /** @hidden */
  87542. _materialEffect: Nullable<Effect>;
  87543. /**
  87544. * Gets associated effect
  87545. */
  87546. readonly effect: Nullable<Effect>;
  87547. /**
  87548. * Sets associated effect (effect used to render this submesh)
  87549. * @param effect defines the effect to associate with
  87550. * @param defines defines the set of defines used to compile this effect
  87551. */
  87552. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  87553. }
  87554. /**
  87555. * Defines a subdivision inside a mesh
  87556. */
  87557. export class SubMesh extends BaseSubMesh implements ICullable {
  87558. /** the material index to use */
  87559. materialIndex: number;
  87560. /** vertex index start */
  87561. verticesStart: number;
  87562. /** vertices count */
  87563. verticesCount: number;
  87564. /** index start */
  87565. indexStart: number;
  87566. /** indices count */
  87567. indexCount: number;
  87568. /** @hidden */
  87569. _linesIndexCount: number;
  87570. private _mesh;
  87571. private _renderingMesh;
  87572. private _boundingInfo;
  87573. private _linesIndexBuffer;
  87574. /** @hidden */
  87575. _lastColliderWorldVertices: Nullable<Vector3[]>;
  87576. /** @hidden */
  87577. _trianglePlanes: Plane[];
  87578. /** @hidden */
  87579. _lastColliderTransformMatrix: Nullable<Matrix>;
  87580. /** @hidden */
  87581. _renderId: number;
  87582. /** @hidden */
  87583. _alphaIndex: number;
  87584. /** @hidden */
  87585. _distanceToCamera: number;
  87586. /** @hidden */
  87587. _id: number;
  87588. private _currentMaterial;
  87589. /**
  87590. * Add a new submesh to a mesh
  87591. * @param materialIndex defines the material index to use
  87592. * @param verticesStart defines vertex index start
  87593. * @param verticesCount defines vertices count
  87594. * @param indexStart defines index start
  87595. * @param indexCount defines indices count
  87596. * @param mesh defines the parent mesh
  87597. * @param renderingMesh defines an optional rendering mesh
  87598. * @param createBoundingBox defines if bounding box should be created for this submesh
  87599. * @returns the new submesh
  87600. */
  87601. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  87602. /**
  87603. * Creates a new submesh
  87604. * @param materialIndex defines the material index to use
  87605. * @param verticesStart defines vertex index start
  87606. * @param verticesCount defines vertices count
  87607. * @param indexStart defines index start
  87608. * @param indexCount defines indices count
  87609. * @param mesh defines the parent mesh
  87610. * @param renderingMesh defines an optional rendering mesh
  87611. * @param createBoundingBox defines if bounding box should be created for this submesh
  87612. */
  87613. constructor(
  87614. /** the material index to use */
  87615. materialIndex: number,
  87616. /** vertex index start */
  87617. verticesStart: number,
  87618. /** vertices count */
  87619. verticesCount: number,
  87620. /** index start */
  87621. indexStart: number,
  87622. /** indices count */
  87623. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  87624. /**
  87625. * Returns true if this submesh covers the entire parent mesh
  87626. * @ignorenaming
  87627. */
  87628. readonly IsGlobal: boolean;
  87629. /**
  87630. * Returns the submesh BoudingInfo object
  87631. * @returns current bounding info (or mesh's one if the submesh is global)
  87632. */
  87633. getBoundingInfo(): BoundingInfo;
  87634. /**
  87635. * Sets the submesh BoundingInfo
  87636. * @param boundingInfo defines the new bounding info to use
  87637. * @returns the SubMesh
  87638. */
  87639. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  87640. /**
  87641. * Returns the mesh of the current submesh
  87642. * @return the parent mesh
  87643. */
  87644. getMesh(): AbstractMesh;
  87645. /**
  87646. * Returns the rendering mesh of the submesh
  87647. * @returns the rendering mesh (could be different from parent mesh)
  87648. */
  87649. getRenderingMesh(): Mesh;
  87650. /**
  87651. * Returns the submesh material
  87652. * @returns null or the current material
  87653. */
  87654. getMaterial(): Nullable<Material>;
  87655. /**
  87656. * Sets a new updated BoundingInfo object to the submesh
  87657. * @param data defines an optional position array to use to determine the bounding info
  87658. * @returns the SubMesh
  87659. */
  87660. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  87661. /** @hidden */
  87662. _checkCollision(collider: Collider): boolean;
  87663. /**
  87664. * Updates the submesh BoundingInfo
  87665. * @param world defines the world matrix to use to update the bounding info
  87666. * @returns the submesh
  87667. */
  87668. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  87669. /**
  87670. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  87671. * @param frustumPlanes defines the frustum planes
  87672. * @returns true if the submesh is intersecting with the frustum
  87673. */
  87674. isInFrustum(frustumPlanes: Plane[]): boolean;
  87675. /**
  87676. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  87677. * @param frustumPlanes defines the frustum planes
  87678. * @returns true if the submesh is inside the frustum
  87679. */
  87680. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87681. /**
  87682. * Renders the submesh
  87683. * @param enableAlphaMode defines if alpha needs to be used
  87684. * @returns the submesh
  87685. */
  87686. render(enableAlphaMode: boolean): SubMesh;
  87687. /**
  87688. * @hidden
  87689. */
  87690. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  87691. /**
  87692. * Checks if the submesh intersects with a ray
  87693. * @param ray defines the ray to test
  87694. * @returns true is the passed ray intersects the submesh bounding box
  87695. */
  87696. canIntersects(ray: Ray): boolean;
  87697. /**
  87698. * Intersects current submesh with a ray
  87699. * @param ray defines the ray to test
  87700. * @param positions defines mesh's positions array
  87701. * @param indices defines mesh's indices array
  87702. * @param fastCheck defines if only bounding info should be used
  87703. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87704. * @returns intersection info or null if no intersection
  87705. */
  87706. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  87707. /** @hidden */
  87708. private _intersectLines;
  87709. /** @hidden */
  87710. private _intersectUnIndexedLines;
  87711. /** @hidden */
  87712. private _intersectTriangles;
  87713. /** @hidden */
  87714. private _intersectUnIndexedTriangles;
  87715. /** @hidden */
  87716. _rebuild(): void;
  87717. /**
  87718. * Creates a new submesh from the passed mesh
  87719. * @param newMesh defines the new hosting mesh
  87720. * @param newRenderingMesh defines an optional rendering mesh
  87721. * @returns the new submesh
  87722. */
  87723. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  87724. /**
  87725. * Release associated resources
  87726. */
  87727. dispose(): void;
  87728. /**
  87729. * Gets the class name
  87730. * @returns the string "SubMesh".
  87731. */
  87732. getClassName(): string;
  87733. /**
  87734. * Creates a new submesh from indices data
  87735. * @param materialIndex the index of the main mesh material
  87736. * @param startIndex the index where to start the copy in the mesh indices array
  87737. * @param indexCount the number of indices to copy then from the startIndex
  87738. * @param mesh the main mesh to create the submesh from
  87739. * @param renderingMesh the optional rendering mesh
  87740. * @returns a new submesh
  87741. */
  87742. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  87743. }
  87744. }
  87745. declare module BABYLON {
  87746. /**
  87747. * Class used to represent data loading progression
  87748. */
  87749. export class SceneLoaderFlags {
  87750. private static _ForceFullSceneLoadingForIncremental;
  87751. private static _ShowLoadingScreen;
  87752. private static _CleanBoneMatrixWeights;
  87753. private static _loggingLevel;
  87754. /**
  87755. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  87756. */
  87757. static ForceFullSceneLoadingForIncremental: boolean;
  87758. /**
  87759. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  87760. */
  87761. static ShowLoadingScreen: boolean;
  87762. /**
  87763. * Defines the current logging level (while loading the scene)
  87764. * @ignorenaming
  87765. */
  87766. static loggingLevel: number;
  87767. /**
  87768. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  87769. */
  87770. static CleanBoneMatrixWeights: boolean;
  87771. }
  87772. }
  87773. declare module BABYLON {
  87774. /**
  87775. * Class used to store geometry data (vertex buffers + index buffer)
  87776. */
  87777. export class Geometry implements IGetSetVerticesData {
  87778. /**
  87779. * Gets or sets the ID of the geometry
  87780. */
  87781. id: string;
  87782. /**
  87783. * Gets or sets the unique ID of the geometry
  87784. */
  87785. uniqueId: number;
  87786. /**
  87787. * Gets the delay loading state of the geometry (none by default which means not delayed)
  87788. */
  87789. delayLoadState: number;
  87790. /**
  87791. * Gets the file containing the data to load when running in delay load state
  87792. */
  87793. delayLoadingFile: Nullable<string>;
  87794. /**
  87795. * Callback called when the geometry is updated
  87796. */
  87797. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  87798. private _scene;
  87799. private _engine;
  87800. private _meshes;
  87801. private _totalVertices;
  87802. /** @hidden */
  87803. _indices: IndicesArray;
  87804. /** @hidden */
  87805. _vertexBuffers: {
  87806. [key: string]: VertexBuffer;
  87807. };
  87808. private _isDisposed;
  87809. private _extend;
  87810. private _boundingBias;
  87811. /** @hidden */
  87812. _delayInfo: Array<string>;
  87813. private _indexBuffer;
  87814. private _indexBufferIsUpdatable;
  87815. /** @hidden */
  87816. _boundingInfo: Nullable<BoundingInfo>;
  87817. /** @hidden */
  87818. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  87819. /** @hidden */
  87820. _softwareSkinningFrameId: number;
  87821. private _vertexArrayObjects;
  87822. private _updatable;
  87823. /** @hidden */
  87824. _positions: Nullable<Vector3[]>;
  87825. /**
  87826. * 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
  87827. */
  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. boundingBias: Vector2;
  87832. /**
  87833. * Static function used to attach a new empty geometry to a mesh
  87834. * @param mesh defines the mesh to attach the geometry to
  87835. * @returns the new Geometry
  87836. */
  87837. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  87838. /**
  87839. * Creates a new geometry
  87840. * @param id defines the unique ID
  87841. * @param scene defines the hosting scene
  87842. * @param vertexData defines the VertexData used to get geometry data
  87843. * @param updatable defines if geometry must be updatable (false by default)
  87844. * @param mesh defines the mesh that will be associated with the geometry
  87845. */
  87846. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  87847. /**
  87848. * Gets the current extend of the geometry
  87849. */
  87850. readonly extend: {
  87851. minimum: Vector3;
  87852. maximum: Vector3;
  87853. };
  87854. /**
  87855. * Gets the hosting scene
  87856. * @returns the hosting Scene
  87857. */
  87858. getScene(): Scene;
  87859. /**
  87860. * Gets the hosting engine
  87861. * @returns the hosting Engine
  87862. */
  87863. getEngine(): Engine;
  87864. /**
  87865. * Defines if the geometry is ready to use
  87866. * @returns true if the geometry is ready to be used
  87867. */
  87868. isReady(): boolean;
  87869. /**
  87870. * Gets a value indicating that the geometry should not be serialized
  87871. */
  87872. readonly doNotSerialize: boolean;
  87873. /** @hidden */
  87874. _rebuild(): void;
  87875. /**
  87876. * Affects all geometry data in one call
  87877. * @param vertexData defines the geometry data
  87878. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  87879. */
  87880. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  87881. /**
  87882. * Set specific vertex data
  87883. * @param kind defines the data kind (Position, normal, etc...)
  87884. * @param data defines the vertex data to use
  87885. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87886. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87887. */
  87888. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  87889. /**
  87890. * Removes a specific vertex data
  87891. * @param kind defines the data kind (Position, normal, etc...)
  87892. */
  87893. removeVerticesData(kind: string): void;
  87894. /**
  87895. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  87896. * @param buffer defines the vertex buffer to use
  87897. * @param totalVertices defines the total number of vertices for position kind (could be null)
  87898. */
  87899. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  87900. /**
  87901. * Update a specific vertex buffer
  87902. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  87903. * It will do nothing if the buffer is not updatable
  87904. * @param kind defines the data kind (Position, normal, etc...)
  87905. * @param data defines the data to use
  87906. * @param offset defines the offset in the target buffer where to store the data
  87907. * @param useBytes set to true if the offset is in bytes
  87908. */
  87909. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  87910. /**
  87911. * Update a specific vertex buffer
  87912. * This function will create a new buffer if the current one is not updatable
  87913. * @param kind defines the data kind (Position, normal, etc...)
  87914. * @param data defines the data to use
  87915. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  87916. */
  87917. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  87918. private _updateBoundingInfo;
  87919. /** @hidden */
  87920. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  87921. /**
  87922. * Gets total number of vertices
  87923. * @returns the total number of vertices
  87924. */
  87925. getTotalVertices(): number;
  87926. /**
  87927. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87928. * @param kind defines the data kind (Position, normal, etc...)
  87929. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87930. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87931. * @returns a float array containing vertex data
  87932. */
  87933. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87934. /**
  87935. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  87936. * @param kind defines the data kind (Position, normal, etc...)
  87937. * @returns true if the vertex buffer with the specified kind is updatable
  87938. */
  87939. isVertexBufferUpdatable(kind: string): boolean;
  87940. /**
  87941. * Gets a specific vertex buffer
  87942. * @param kind defines the data kind (Position, normal, etc...)
  87943. * @returns a VertexBuffer
  87944. */
  87945. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87946. /**
  87947. * Returns all vertex buffers
  87948. * @return an object holding all vertex buffers indexed by kind
  87949. */
  87950. getVertexBuffers(): Nullable<{
  87951. [key: string]: VertexBuffer;
  87952. }>;
  87953. /**
  87954. * Gets a boolean indicating if specific vertex buffer is present
  87955. * @param kind defines the data kind (Position, normal, etc...)
  87956. * @returns true if data is present
  87957. */
  87958. isVerticesDataPresent(kind: string): boolean;
  87959. /**
  87960. * Gets a list of all attached data kinds (Position, normal, etc...)
  87961. * @returns a list of string containing all kinds
  87962. */
  87963. getVerticesDataKinds(): string[];
  87964. /**
  87965. * Update index buffer
  87966. * @param indices defines the indices to store in the index buffer
  87967. * @param offset defines the offset in the target buffer where to store the data
  87968. * @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)
  87969. */
  87970. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  87971. /**
  87972. * Creates a new index buffer
  87973. * @param indices defines the indices to store in the index buffer
  87974. * @param totalVertices defines the total number of vertices (could be null)
  87975. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87976. */
  87977. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  87978. /**
  87979. * Return the total number of indices
  87980. * @returns the total number of indices
  87981. */
  87982. getTotalIndices(): number;
  87983. /**
  87984. * Gets the index buffer array
  87985. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87986. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87987. * @returns the index buffer array
  87988. */
  87989. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87990. /**
  87991. * Gets the index buffer
  87992. * @return the index buffer
  87993. */
  87994. getIndexBuffer(): Nullable<DataBuffer>;
  87995. /** @hidden */
  87996. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  87997. /**
  87998. * Release the associated resources for a specific mesh
  87999. * @param mesh defines the source mesh
  88000. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  88001. */
  88002. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  88003. /**
  88004. * Apply current geometry to a given mesh
  88005. * @param mesh defines the mesh to apply geometry to
  88006. */
  88007. applyToMesh(mesh: Mesh): void;
  88008. private _updateExtend;
  88009. private _applyToMesh;
  88010. private notifyUpdate;
  88011. /**
  88012. * Load the geometry if it was flagged as delay loaded
  88013. * @param scene defines the hosting scene
  88014. * @param onLoaded defines a callback called when the geometry is loaded
  88015. */
  88016. load(scene: Scene, onLoaded?: () => void): void;
  88017. private _queueLoad;
  88018. /**
  88019. * Invert the geometry to move from a right handed system to a left handed one.
  88020. */
  88021. toLeftHanded(): void;
  88022. /** @hidden */
  88023. _resetPointsArrayCache(): void;
  88024. /** @hidden */
  88025. _generatePointsArray(): boolean;
  88026. /**
  88027. * Gets a value indicating if the geometry is disposed
  88028. * @returns true if the geometry was disposed
  88029. */
  88030. isDisposed(): boolean;
  88031. private _disposeVertexArrayObjects;
  88032. /**
  88033. * Free all associated resources
  88034. */
  88035. dispose(): void;
  88036. /**
  88037. * Clone the current geometry into a new geometry
  88038. * @param id defines the unique ID of the new geometry
  88039. * @returns a new geometry object
  88040. */
  88041. copy(id: string): Geometry;
  88042. /**
  88043. * Serialize the current geometry info (and not the vertices data) into a JSON object
  88044. * @return a JSON representation of the current geometry data (without the vertices data)
  88045. */
  88046. serialize(): any;
  88047. private toNumberArray;
  88048. /**
  88049. * Serialize all vertices data into a JSON oject
  88050. * @returns a JSON representation of the current geometry data
  88051. */
  88052. serializeVerticeData(): any;
  88053. /**
  88054. * Extracts a clone of a mesh geometry
  88055. * @param mesh defines the source mesh
  88056. * @param id defines the unique ID of the new geometry object
  88057. * @returns the new geometry object
  88058. */
  88059. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88060. /**
  88061. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88062. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88063. * Be aware Math.random() could cause collisions, but:
  88064. * "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"
  88065. * @returns a string containing a new GUID
  88066. */
  88067. static RandomId(): string;
  88068. /** @hidden */
  88069. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88070. private static _CleanMatricesWeights;
  88071. /**
  88072. * Create a new geometry from persisted data (Using .babylon file format)
  88073. * @param parsedVertexData defines the persisted data
  88074. * @param scene defines the hosting scene
  88075. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88076. * @returns the new geometry object
  88077. */
  88078. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88079. }
  88080. }
  88081. declare module BABYLON {
  88082. /**
  88083. * Define an interface for all classes that will get and set the data on vertices
  88084. */
  88085. export interface IGetSetVerticesData {
  88086. /**
  88087. * Gets a boolean indicating if specific vertex data is present
  88088. * @param kind defines the vertex data kind to use
  88089. * @returns true is data kind is present
  88090. */
  88091. isVerticesDataPresent(kind: string): boolean;
  88092. /**
  88093. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88094. * @param kind defines the data kind (Position, normal, etc...)
  88095. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88096. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88097. * @returns a float array containing vertex data
  88098. */
  88099. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88100. /**
  88101. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88102. * @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.
  88103. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88104. * @returns the indices array or an empty array if the mesh has no geometry
  88105. */
  88106. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88107. /**
  88108. * Set specific vertex data
  88109. * @param kind defines the data kind (Position, normal, etc...)
  88110. * @param data defines the vertex data to use
  88111. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88112. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88113. */
  88114. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88115. /**
  88116. * Update a specific associated vertex buffer
  88117. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88118. * - VertexBuffer.PositionKind
  88119. * - VertexBuffer.UVKind
  88120. * - VertexBuffer.UV2Kind
  88121. * - VertexBuffer.UV3Kind
  88122. * - VertexBuffer.UV4Kind
  88123. * - VertexBuffer.UV5Kind
  88124. * - VertexBuffer.UV6Kind
  88125. * - VertexBuffer.ColorKind
  88126. * - VertexBuffer.MatricesIndicesKind
  88127. * - VertexBuffer.MatricesIndicesExtraKind
  88128. * - VertexBuffer.MatricesWeightsKind
  88129. * - VertexBuffer.MatricesWeightsExtraKind
  88130. * @param data defines the data source
  88131. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88132. * @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)
  88133. */
  88134. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88135. /**
  88136. * Creates a new index buffer
  88137. * @param indices defines the indices to store in the index buffer
  88138. * @param totalVertices defines the total number of vertices (could be null)
  88139. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88140. */
  88141. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88142. }
  88143. /**
  88144. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88145. */
  88146. export class VertexData {
  88147. /**
  88148. * Mesh side orientation : usually the external or front surface
  88149. */
  88150. static readonly FRONTSIDE: number;
  88151. /**
  88152. * Mesh side orientation : usually the internal or back surface
  88153. */
  88154. static readonly BACKSIDE: number;
  88155. /**
  88156. * Mesh side orientation : both internal and external or front and back surfaces
  88157. */
  88158. static readonly DOUBLESIDE: number;
  88159. /**
  88160. * Mesh side orientation : by default, `FRONTSIDE`
  88161. */
  88162. static readonly DEFAULTSIDE: number;
  88163. /**
  88164. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88165. */
  88166. positions: Nullable<FloatArray>;
  88167. /**
  88168. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88169. */
  88170. normals: Nullable<FloatArray>;
  88171. /**
  88172. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88173. */
  88174. tangents: Nullable<FloatArray>;
  88175. /**
  88176. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88177. */
  88178. uvs: Nullable<FloatArray>;
  88179. /**
  88180. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88181. */
  88182. uvs2: Nullable<FloatArray>;
  88183. /**
  88184. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88185. */
  88186. uvs3: Nullable<FloatArray>;
  88187. /**
  88188. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88189. */
  88190. uvs4: Nullable<FloatArray>;
  88191. /**
  88192. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88193. */
  88194. uvs5: Nullable<FloatArray>;
  88195. /**
  88196. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88197. */
  88198. uvs6: Nullable<FloatArray>;
  88199. /**
  88200. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88201. */
  88202. colors: Nullable<FloatArray>;
  88203. /**
  88204. * 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).
  88205. */
  88206. matricesIndices: Nullable<FloatArray>;
  88207. /**
  88208. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88209. */
  88210. matricesWeights: Nullable<FloatArray>;
  88211. /**
  88212. * An array extending the number of possible indices
  88213. */
  88214. matricesIndicesExtra: Nullable<FloatArray>;
  88215. /**
  88216. * An array extending the number of possible weights when the number of indices is extended
  88217. */
  88218. matricesWeightsExtra: Nullable<FloatArray>;
  88219. /**
  88220. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88221. */
  88222. indices: Nullable<IndicesArray>;
  88223. /**
  88224. * Uses the passed data array to set the set the values for the specified kind of data
  88225. * @param data a linear array of floating numbers
  88226. * @param kind the type of data that is being set, eg positions, colors etc
  88227. */
  88228. set(data: FloatArray, kind: string): void;
  88229. /**
  88230. * Associates the vertexData to the passed Mesh.
  88231. * Sets it as updatable or not (default `false`)
  88232. * @param mesh the mesh the vertexData is applied to
  88233. * @param updatable when used and having the value true allows new data to update the vertexData
  88234. * @returns the VertexData
  88235. */
  88236. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88237. /**
  88238. * Associates the vertexData to the passed Geometry.
  88239. * Sets it as updatable or not (default `false`)
  88240. * @param geometry the geometry the vertexData is applied to
  88241. * @param updatable when used and having the value true allows new data to update the vertexData
  88242. * @returns VertexData
  88243. */
  88244. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88245. /**
  88246. * Updates the associated mesh
  88247. * @param mesh the mesh to be updated
  88248. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88249. * @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
  88250. * @returns VertexData
  88251. */
  88252. updateMesh(mesh: Mesh): VertexData;
  88253. /**
  88254. * Updates the associated geometry
  88255. * @param geometry the geometry to be updated
  88256. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88257. * @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
  88258. * @returns VertexData.
  88259. */
  88260. updateGeometry(geometry: Geometry): VertexData;
  88261. private _applyTo;
  88262. private _update;
  88263. /**
  88264. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88265. * @param matrix the transforming matrix
  88266. * @returns the VertexData
  88267. */
  88268. transform(matrix: Matrix): VertexData;
  88269. /**
  88270. * Merges the passed VertexData into the current one
  88271. * @param other the VertexData to be merged into the current one
  88272. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88273. * @returns the modified VertexData
  88274. */
  88275. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88276. private _mergeElement;
  88277. private _validate;
  88278. /**
  88279. * Serializes the VertexData
  88280. * @returns a serialized object
  88281. */
  88282. serialize(): any;
  88283. /**
  88284. * Extracts the vertexData from a mesh
  88285. * @param mesh the mesh from which to extract the VertexData
  88286. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88287. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88288. * @returns the object VertexData associated to the passed mesh
  88289. */
  88290. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88291. /**
  88292. * Extracts the vertexData from the geometry
  88293. * @param geometry the geometry from which to extract the VertexData
  88294. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  88295. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88296. * @returns the object VertexData associated to the passed mesh
  88297. */
  88298. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88299. private static _ExtractFrom;
  88300. /**
  88301. * Creates the VertexData for a Ribbon
  88302. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  88303. * * pathArray array of paths, each of which an array of successive Vector3
  88304. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  88305. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  88306. * * 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
  88307. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88308. * * 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)
  88309. * * 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)
  88310. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  88311. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  88312. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  88313. * @returns the VertexData of the ribbon
  88314. */
  88315. static CreateRibbon(options: {
  88316. pathArray: Vector3[][];
  88317. closeArray?: boolean;
  88318. closePath?: boolean;
  88319. offset?: number;
  88320. sideOrientation?: number;
  88321. frontUVs?: Vector4;
  88322. backUVs?: Vector4;
  88323. invertUV?: boolean;
  88324. uvs?: Vector2[];
  88325. colors?: Color4[];
  88326. }): VertexData;
  88327. /**
  88328. * Creates the VertexData for a box
  88329. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88330. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88331. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88332. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88333. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88334. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88335. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88336. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88337. * * 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)
  88338. * * 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)
  88339. * @returns the VertexData of the box
  88340. */
  88341. static CreateBox(options: {
  88342. size?: number;
  88343. width?: number;
  88344. height?: number;
  88345. depth?: number;
  88346. faceUV?: Vector4[];
  88347. faceColors?: Color4[];
  88348. sideOrientation?: number;
  88349. frontUVs?: Vector4;
  88350. backUVs?: Vector4;
  88351. }): VertexData;
  88352. /**
  88353. * Creates the VertexData for a tiled box
  88354. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88355. * * faceTiles sets the pattern, tile size and number of tiles for a face
  88356. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88357. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88358. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88359. * @returns the VertexData of the box
  88360. */
  88361. static CreateTiledBox(options: {
  88362. pattern?: number;
  88363. width?: number;
  88364. height?: number;
  88365. depth?: number;
  88366. tileSize?: number;
  88367. tileWidth?: number;
  88368. tileHeight?: number;
  88369. alignHorizontal?: number;
  88370. alignVertical?: number;
  88371. faceUV?: Vector4[];
  88372. faceColors?: Color4[];
  88373. sideOrientation?: number;
  88374. }): VertexData;
  88375. /**
  88376. * Creates the VertexData for a tiled plane
  88377. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88378. * * pattern a limited pattern arrangement depending on the number
  88379. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  88380. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  88381. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  88382. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88383. * * 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)
  88384. * * 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)
  88385. * @returns the VertexData of the tiled plane
  88386. */
  88387. static CreateTiledPlane(options: {
  88388. pattern?: number;
  88389. tileSize?: number;
  88390. tileWidth?: number;
  88391. tileHeight?: number;
  88392. size?: number;
  88393. width?: number;
  88394. height?: number;
  88395. alignHorizontal?: number;
  88396. alignVertical?: number;
  88397. sideOrientation?: number;
  88398. frontUVs?: Vector4;
  88399. backUVs?: Vector4;
  88400. }): VertexData;
  88401. /**
  88402. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88403. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88404. * * segments sets the number of horizontal strips optional, default 32
  88405. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88406. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88407. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88408. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88409. * * 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
  88410. * * 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
  88411. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88412. * * 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)
  88413. * * 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)
  88414. * @returns the VertexData of the ellipsoid
  88415. */
  88416. static CreateSphere(options: {
  88417. segments?: number;
  88418. diameter?: number;
  88419. diameterX?: number;
  88420. diameterY?: number;
  88421. diameterZ?: number;
  88422. arc?: number;
  88423. slice?: number;
  88424. sideOrientation?: number;
  88425. frontUVs?: Vector4;
  88426. backUVs?: Vector4;
  88427. }): VertexData;
  88428. /**
  88429. * Creates the VertexData for a cylinder, cone or prism
  88430. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88431. * * height sets the height (y direction) of the cylinder, optional, default 2
  88432. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88433. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88434. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88435. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88436. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88437. * * 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
  88438. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88439. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88440. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88441. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88442. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88443. * * 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)
  88444. * * 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)
  88445. * @returns the VertexData of the cylinder, cone or prism
  88446. */
  88447. static CreateCylinder(options: {
  88448. height?: number;
  88449. diameterTop?: number;
  88450. diameterBottom?: number;
  88451. diameter?: number;
  88452. tessellation?: number;
  88453. subdivisions?: number;
  88454. arc?: number;
  88455. faceColors?: Color4[];
  88456. faceUV?: Vector4[];
  88457. hasRings?: boolean;
  88458. enclose?: boolean;
  88459. sideOrientation?: number;
  88460. frontUVs?: Vector4;
  88461. backUVs?: Vector4;
  88462. }): VertexData;
  88463. /**
  88464. * Creates the VertexData for a torus
  88465. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88466. * * diameter the diameter of the torus, optional default 1
  88467. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88468. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88469. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88470. * * 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)
  88471. * * 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)
  88472. * @returns the VertexData of the torus
  88473. */
  88474. static CreateTorus(options: {
  88475. diameter?: number;
  88476. thickness?: number;
  88477. tessellation?: number;
  88478. sideOrientation?: number;
  88479. frontUVs?: Vector4;
  88480. backUVs?: Vector4;
  88481. }): VertexData;
  88482. /**
  88483. * Creates the VertexData of the LineSystem
  88484. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88485. * - lines an array of lines, each line being an array of successive Vector3
  88486. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88487. * @returns the VertexData of the LineSystem
  88488. */
  88489. static CreateLineSystem(options: {
  88490. lines: Vector3[][];
  88491. colors?: Nullable<Color4[][]>;
  88492. }): VertexData;
  88493. /**
  88494. * Create the VertexData for a DashedLines
  88495. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88496. * - points an array successive Vector3
  88497. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88498. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88499. * - dashNb the intended total number of dashes, optional, default 200
  88500. * @returns the VertexData for the DashedLines
  88501. */
  88502. static CreateDashedLines(options: {
  88503. points: Vector3[];
  88504. dashSize?: number;
  88505. gapSize?: number;
  88506. dashNb?: number;
  88507. }): VertexData;
  88508. /**
  88509. * Creates the VertexData for a Ground
  88510. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88511. * - width the width (x direction) of the ground, optional, default 1
  88512. * - height the height (z direction) of the ground, optional, default 1
  88513. * - subdivisions the number of subdivisions per side, optional, default 1
  88514. * @returns the VertexData of the Ground
  88515. */
  88516. static CreateGround(options: {
  88517. width?: number;
  88518. height?: number;
  88519. subdivisions?: number;
  88520. subdivisionsX?: number;
  88521. subdivisionsY?: number;
  88522. }): VertexData;
  88523. /**
  88524. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88525. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88526. * * xmin the ground minimum X coordinate, optional, default -1
  88527. * * zmin the ground minimum Z coordinate, optional, default -1
  88528. * * xmax the ground maximum X coordinate, optional, default 1
  88529. * * zmax the ground maximum Z coordinate, optional, default 1
  88530. * * 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}
  88531. * * 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}
  88532. * @returns the VertexData of the TiledGround
  88533. */
  88534. static CreateTiledGround(options: {
  88535. xmin: number;
  88536. zmin: number;
  88537. xmax: number;
  88538. zmax: number;
  88539. subdivisions?: {
  88540. w: number;
  88541. h: number;
  88542. };
  88543. precision?: {
  88544. w: number;
  88545. h: number;
  88546. };
  88547. }): VertexData;
  88548. /**
  88549. * Creates the VertexData of the Ground designed from a heightmap
  88550. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  88551. * * width the width (x direction) of the ground
  88552. * * height the height (z direction) of the ground
  88553. * * subdivisions the number of subdivisions per side
  88554. * * minHeight the minimum altitude on the ground, optional, default 0
  88555. * * maxHeight the maximum altitude on the ground, optional default 1
  88556. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  88557. * * buffer the array holding the image color data
  88558. * * bufferWidth the width of image
  88559. * * bufferHeight the height of image
  88560. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  88561. * @returns the VertexData of the Ground designed from a heightmap
  88562. */
  88563. static CreateGroundFromHeightMap(options: {
  88564. width: number;
  88565. height: number;
  88566. subdivisions: number;
  88567. minHeight: number;
  88568. maxHeight: number;
  88569. colorFilter: Color3;
  88570. buffer: Uint8Array;
  88571. bufferWidth: number;
  88572. bufferHeight: number;
  88573. alphaFilter: number;
  88574. }): VertexData;
  88575. /**
  88576. * Creates the VertexData for a Plane
  88577. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  88578. * * size sets the width and height of the plane to the value of size, optional default 1
  88579. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  88580. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  88581. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88582. * * 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)
  88583. * * 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)
  88584. * @returns the VertexData of the box
  88585. */
  88586. static CreatePlane(options: {
  88587. size?: number;
  88588. width?: number;
  88589. height?: number;
  88590. sideOrientation?: number;
  88591. frontUVs?: Vector4;
  88592. backUVs?: Vector4;
  88593. }): VertexData;
  88594. /**
  88595. * Creates the VertexData of the Disc or regular Polygon
  88596. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  88597. * * radius the radius of the disc, optional default 0.5
  88598. * * tessellation the number of polygon sides, optional, default 64
  88599. * * 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
  88600. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88601. * * 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)
  88602. * * 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)
  88603. * @returns the VertexData of the box
  88604. */
  88605. static CreateDisc(options: {
  88606. radius?: number;
  88607. tessellation?: number;
  88608. arc?: number;
  88609. sideOrientation?: number;
  88610. frontUVs?: Vector4;
  88611. backUVs?: Vector4;
  88612. }): VertexData;
  88613. /**
  88614. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  88615. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  88616. * @param polygon a mesh built from polygonTriangulation.build()
  88617. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88618. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88619. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88620. * @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)
  88621. * @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)
  88622. * @returns the VertexData of the Polygon
  88623. */
  88624. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  88625. /**
  88626. * Creates the VertexData of the IcoSphere
  88627. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  88628. * * radius the radius of the IcoSphere, optional default 1
  88629. * * radiusX allows stretching in the x direction, optional, default radius
  88630. * * radiusY allows stretching in the y direction, optional, default radius
  88631. * * radiusZ allows stretching in the z direction, optional, default radius
  88632. * * flat when true creates a flat shaded mesh, optional, default true
  88633. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88634. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88635. * * 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)
  88636. * * 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)
  88637. * @returns the VertexData of the IcoSphere
  88638. */
  88639. static CreateIcoSphere(options: {
  88640. radius?: number;
  88641. radiusX?: number;
  88642. radiusY?: number;
  88643. radiusZ?: number;
  88644. flat?: boolean;
  88645. subdivisions?: number;
  88646. sideOrientation?: number;
  88647. frontUVs?: Vector4;
  88648. backUVs?: Vector4;
  88649. }): VertexData;
  88650. /**
  88651. * Creates the VertexData for a Polyhedron
  88652. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  88653. * * type provided types are:
  88654. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  88655. * * 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)
  88656. * * size the size of the IcoSphere, optional default 1
  88657. * * sizeX allows stretching in the x direction, optional, default size
  88658. * * sizeY allows stretching in the y direction, optional, default size
  88659. * * sizeZ allows stretching in the z direction, optional, default size
  88660. * * 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
  88661. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88662. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88663. * * flat when true creates a flat shaded mesh, optional, default true
  88664. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88665. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88666. * * 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)
  88667. * * 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)
  88668. * @returns the VertexData of the Polyhedron
  88669. */
  88670. static CreatePolyhedron(options: {
  88671. type?: number;
  88672. size?: number;
  88673. sizeX?: number;
  88674. sizeY?: number;
  88675. sizeZ?: number;
  88676. custom?: any;
  88677. faceUV?: Vector4[];
  88678. faceColors?: Color4[];
  88679. flat?: boolean;
  88680. sideOrientation?: number;
  88681. frontUVs?: Vector4;
  88682. backUVs?: Vector4;
  88683. }): VertexData;
  88684. /**
  88685. * Creates the VertexData for a TorusKnot
  88686. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  88687. * * radius the radius of the torus knot, optional, default 2
  88688. * * tube the thickness of the tube, optional, default 0.5
  88689. * * radialSegments the number of sides on each tube segments, optional, default 32
  88690. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  88691. * * p the number of windings around the z axis, optional, default 2
  88692. * * q the number of windings around the x axis, optional, default 3
  88693. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88694. * * 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)
  88695. * * 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)
  88696. * @returns the VertexData of the Torus Knot
  88697. */
  88698. static CreateTorusKnot(options: {
  88699. radius?: number;
  88700. tube?: number;
  88701. radialSegments?: number;
  88702. tubularSegments?: number;
  88703. p?: number;
  88704. q?: number;
  88705. sideOrientation?: number;
  88706. frontUVs?: Vector4;
  88707. backUVs?: Vector4;
  88708. }): VertexData;
  88709. /**
  88710. * Compute normals for given positions and indices
  88711. * @param positions an array of vertex positions, [...., x, y, z, ......]
  88712. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  88713. * @param normals an array of vertex normals, [...., x, y, z, ......]
  88714. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  88715. * * facetNormals : optional array of facet normals (vector3)
  88716. * * facetPositions : optional array of facet positions (vector3)
  88717. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  88718. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  88719. * * bInfo : optional bounding info, required for facetPartitioning computation
  88720. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  88721. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  88722. * * useRightHandedSystem: optional boolean to for right handed system computation
  88723. * * depthSort : optional boolean to enable the facet depth sort computation
  88724. * * distanceTo : optional Vector3 to compute the facet depth from this location
  88725. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  88726. */
  88727. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  88728. facetNormals?: any;
  88729. facetPositions?: any;
  88730. facetPartitioning?: any;
  88731. ratio?: number;
  88732. bInfo?: any;
  88733. bbSize?: Vector3;
  88734. subDiv?: any;
  88735. useRightHandedSystem?: boolean;
  88736. depthSort?: boolean;
  88737. distanceTo?: Vector3;
  88738. depthSortedFacets?: any;
  88739. }): void;
  88740. /** @hidden */
  88741. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  88742. /**
  88743. * Applies VertexData created from the imported parameters to the geometry
  88744. * @param parsedVertexData the parsed data from an imported file
  88745. * @param geometry the geometry to apply the VertexData to
  88746. */
  88747. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  88748. }
  88749. }
  88750. declare module BABYLON {
  88751. /**
  88752. * Defines a target to use with MorphTargetManager
  88753. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88754. */
  88755. export class MorphTarget implements IAnimatable {
  88756. /** defines the name of the target */
  88757. name: string;
  88758. /**
  88759. * Gets or sets the list of animations
  88760. */
  88761. animations: Animation[];
  88762. private _scene;
  88763. private _positions;
  88764. private _normals;
  88765. private _tangents;
  88766. private _uvs;
  88767. private _influence;
  88768. /**
  88769. * Observable raised when the influence changes
  88770. */
  88771. onInfluenceChanged: Observable<boolean>;
  88772. /** @hidden */
  88773. _onDataLayoutChanged: Observable<void>;
  88774. /**
  88775. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  88776. */
  88777. influence: number;
  88778. /**
  88779. * Gets or sets the id of the morph Target
  88780. */
  88781. id: string;
  88782. private _animationPropertiesOverride;
  88783. /**
  88784. * Gets or sets the animation properties override
  88785. */
  88786. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88787. /**
  88788. * Creates a new MorphTarget
  88789. * @param name defines the name of the target
  88790. * @param influence defines the influence to use
  88791. * @param scene defines the scene the morphtarget belongs to
  88792. */
  88793. constructor(
  88794. /** defines the name of the target */
  88795. name: string, influence?: number, scene?: Nullable<Scene>);
  88796. /**
  88797. * Gets a boolean defining if the target contains position data
  88798. */
  88799. readonly hasPositions: boolean;
  88800. /**
  88801. * Gets a boolean defining if the target contains normal data
  88802. */
  88803. readonly hasNormals: boolean;
  88804. /**
  88805. * Gets a boolean defining if the target contains tangent data
  88806. */
  88807. readonly hasTangents: boolean;
  88808. /**
  88809. * Gets a boolean defining if the target contains texture coordinates data
  88810. */
  88811. readonly hasUVs: boolean;
  88812. /**
  88813. * Affects position data to this target
  88814. * @param data defines the position data to use
  88815. */
  88816. setPositions(data: Nullable<FloatArray>): void;
  88817. /**
  88818. * Gets the position data stored in this target
  88819. * @returns a FloatArray containing the position data (or null if not present)
  88820. */
  88821. getPositions(): Nullable<FloatArray>;
  88822. /**
  88823. * Affects normal data to this target
  88824. * @param data defines the normal data to use
  88825. */
  88826. setNormals(data: Nullable<FloatArray>): void;
  88827. /**
  88828. * Gets the normal data stored in this target
  88829. * @returns a FloatArray containing the normal data (or null if not present)
  88830. */
  88831. getNormals(): Nullable<FloatArray>;
  88832. /**
  88833. * Affects tangent data to this target
  88834. * @param data defines the tangent data to use
  88835. */
  88836. setTangents(data: Nullable<FloatArray>): void;
  88837. /**
  88838. * Gets the tangent data stored in this target
  88839. * @returns a FloatArray containing the tangent data (or null if not present)
  88840. */
  88841. getTangents(): Nullable<FloatArray>;
  88842. /**
  88843. * Affects texture coordinates data to this target
  88844. * @param data defines the texture coordinates data to use
  88845. */
  88846. setUVs(data: Nullable<FloatArray>): void;
  88847. /**
  88848. * Gets the texture coordinates data stored in this target
  88849. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  88850. */
  88851. getUVs(): Nullable<FloatArray>;
  88852. /**
  88853. * Serializes the current target into a Serialization object
  88854. * @returns the serialized object
  88855. */
  88856. serialize(): any;
  88857. /**
  88858. * Returns the string "MorphTarget"
  88859. * @returns "MorphTarget"
  88860. */
  88861. getClassName(): string;
  88862. /**
  88863. * Creates a new target from serialized data
  88864. * @param serializationObject defines the serialized data to use
  88865. * @returns a new MorphTarget
  88866. */
  88867. static Parse(serializationObject: any): MorphTarget;
  88868. /**
  88869. * Creates a MorphTarget from mesh data
  88870. * @param mesh defines the source mesh
  88871. * @param name defines the name to use for the new target
  88872. * @param influence defines the influence to attach to the target
  88873. * @returns a new MorphTarget
  88874. */
  88875. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  88876. }
  88877. }
  88878. declare module BABYLON {
  88879. /**
  88880. * This class is used to deform meshes using morphing between different targets
  88881. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88882. */
  88883. export class MorphTargetManager {
  88884. private _targets;
  88885. private _targetInfluenceChangedObservers;
  88886. private _targetDataLayoutChangedObservers;
  88887. private _activeTargets;
  88888. private _scene;
  88889. private _influences;
  88890. private _supportsNormals;
  88891. private _supportsTangents;
  88892. private _supportsUVs;
  88893. private _vertexCount;
  88894. private _uniqueId;
  88895. private _tempInfluences;
  88896. /**
  88897. * Gets or sets a boolean indicating if normals must be morphed
  88898. */
  88899. enableNormalMorphing: boolean;
  88900. /**
  88901. * Gets or sets a boolean indicating if tangents must be morphed
  88902. */
  88903. enableTangentMorphing: boolean;
  88904. /**
  88905. * Gets or sets a boolean indicating if UV must be morphed
  88906. */
  88907. enableUVMorphing: boolean;
  88908. /**
  88909. * Creates a new MorphTargetManager
  88910. * @param scene defines the current scene
  88911. */
  88912. constructor(scene?: Nullable<Scene>);
  88913. /**
  88914. * Gets the unique ID of this manager
  88915. */
  88916. readonly uniqueId: number;
  88917. /**
  88918. * Gets the number of vertices handled by this manager
  88919. */
  88920. readonly vertexCount: number;
  88921. /**
  88922. * Gets a boolean indicating if this manager supports morphing of normals
  88923. */
  88924. readonly supportsNormals: boolean;
  88925. /**
  88926. * Gets a boolean indicating if this manager supports morphing of tangents
  88927. */
  88928. readonly supportsTangents: boolean;
  88929. /**
  88930. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  88931. */
  88932. readonly supportsUVs: boolean;
  88933. /**
  88934. * Gets the number of targets stored in this manager
  88935. */
  88936. readonly numTargets: number;
  88937. /**
  88938. * Gets the number of influencers (ie. the number of targets with influences > 0)
  88939. */
  88940. readonly numInfluencers: number;
  88941. /**
  88942. * Gets the list of influences (one per target)
  88943. */
  88944. readonly influences: Float32Array;
  88945. /**
  88946. * Gets the active target at specified index. An active target is a target with an influence > 0
  88947. * @param index defines the index to check
  88948. * @returns the requested target
  88949. */
  88950. getActiveTarget(index: number): MorphTarget;
  88951. /**
  88952. * Gets the target at specified index
  88953. * @param index defines the index to check
  88954. * @returns the requested target
  88955. */
  88956. getTarget(index: number): MorphTarget;
  88957. /**
  88958. * Add a new target to this manager
  88959. * @param target defines the target to add
  88960. */
  88961. addTarget(target: MorphTarget): void;
  88962. /**
  88963. * Removes a target from the manager
  88964. * @param target defines the target to remove
  88965. */
  88966. removeTarget(target: MorphTarget): void;
  88967. /**
  88968. * Serializes the current manager into a Serialization object
  88969. * @returns the serialized object
  88970. */
  88971. serialize(): any;
  88972. private _syncActiveTargets;
  88973. /**
  88974. * Syncrhonize the targets with all the meshes using this morph target manager
  88975. */
  88976. synchronize(): void;
  88977. /**
  88978. * Creates a new MorphTargetManager from serialized data
  88979. * @param serializationObject defines the serialized data
  88980. * @param scene defines the hosting scene
  88981. * @returns the new MorphTargetManager
  88982. */
  88983. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  88984. }
  88985. }
  88986. declare module BABYLON {
  88987. /**
  88988. * Class used to represent a specific level of detail of a mesh
  88989. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88990. */
  88991. export class MeshLODLevel {
  88992. /** Defines the distance where this level should start being displayed */
  88993. distance: number;
  88994. /** Defines the mesh to use to render this level */
  88995. mesh: Nullable<Mesh>;
  88996. /**
  88997. * Creates a new LOD level
  88998. * @param distance defines the distance where this level should star being displayed
  88999. * @param mesh defines the mesh to use to render this level
  89000. */
  89001. constructor(
  89002. /** Defines the distance where this level should start being displayed */
  89003. distance: number,
  89004. /** Defines the mesh to use to render this level */
  89005. mesh: Nullable<Mesh>);
  89006. }
  89007. }
  89008. declare module BABYLON {
  89009. /**
  89010. * Mesh representing the gorund
  89011. */
  89012. export class GroundMesh extends Mesh {
  89013. /** If octree should be generated */
  89014. generateOctree: boolean;
  89015. private _heightQuads;
  89016. /** @hidden */
  89017. _subdivisionsX: number;
  89018. /** @hidden */
  89019. _subdivisionsY: number;
  89020. /** @hidden */
  89021. _width: number;
  89022. /** @hidden */
  89023. _height: number;
  89024. /** @hidden */
  89025. _minX: number;
  89026. /** @hidden */
  89027. _maxX: number;
  89028. /** @hidden */
  89029. _minZ: number;
  89030. /** @hidden */
  89031. _maxZ: number;
  89032. constructor(name: string, scene: Scene);
  89033. /**
  89034. * "GroundMesh"
  89035. * @returns "GroundMesh"
  89036. */
  89037. getClassName(): string;
  89038. /**
  89039. * The minimum of x and y subdivisions
  89040. */
  89041. readonly subdivisions: number;
  89042. /**
  89043. * X subdivisions
  89044. */
  89045. readonly subdivisionsX: number;
  89046. /**
  89047. * Y subdivisions
  89048. */
  89049. readonly subdivisionsY: number;
  89050. /**
  89051. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  89052. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89053. * @param chunksCount the number of subdivisions for x and y
  89054. * @param octreeBlocksSize (Default: 32)
  89055. */
  89056. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89057. /**
  89058. * Returns a height (y) value in the Worl system :
  89059. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89060. * @param x x coordinate
  89061. * @param z z coordinate
  89062. * @returns the ground y position if (x, z) are outside the ground surface.
  89063. */
  89064. getHeightAtCoordinates(x: number, z: number): number;
  89065. /**
  89066. * Returns a normalized vector (Vector3) orthogonal to the ground
  89067. * at the ground coordinates (x, z) expressed in the World system.
  89068. * @param x x coordinate
  89069. * @param z z coordinate
  89070. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89071. */
  89072. getNormalAtCoordinates(x: number, z: number): Vector3;
  89073. /**
  89074. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89075. * at the ground coordinates (x, z) expressed in the World system.
  89076. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89077. * @param x x coordinate
  89078. * @param z z coordinate
  89079. * @param ref vector to store the result
  89080. * @returns the GroundMesh.
  89081. */
  89082. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89083. /**
  89084. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89085. * if the ground has been updated.
  89086. * This can be used in the render loop.
  89087. * @returns the GroundMesh.
  89088. */
  89089. updateCoordinateHeights(): GroundMesh;
  89090. private _getFacetAt;
  89091. private _initHeightQuads;
  89092. private _computeHeightQuads;
  89093. /**
  89094. * Serializes this ground mesh
  89095. * @param serializationObject object to write serialization to
  89096. */
  89097. serialize(serializationObject: any): void;
  89098. /**
  89099. * Parses a serialized ground mesh
  89100. * @param parsedMesh the serialized mesh
  89101. * @param scene the scene to create the ground mesh in
  89102. * @returns the created ground mesh
  89103. */
  89104. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89105. }
  89106. }
  89107. declare module BABYLON {
  89108. /**
  89109. * Interface for Physics-Joint data
  89110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89111. */
  89112. export interface PhysicsJointData {
  89113. /**
  89114. * The main pivot of the joint
  89115. */
  89116. mainPivot?: Vector3;
  89117. /**
  89118. * The connected pivot of the joint
  89119. */
  89120. connectedPivot?: Vector3;
  89121. /**
  89122. * The main axis of the joint
  89123. */
  89124. mainAxis?: Vector3;
  89125. /**
  89126. * The connected axis of the joint
  89127. */
  89128. connectedAxis?: Vector3;
  89129. /**
  89130. * The collision of the joint
  89131. */
  89132. collision?: boolean;
  89133. /**
  89134. * Native Oimo/Cannon/Energy data
  89135. */
  89136. nativeParams?: any;
  89137. }
  89138. /**
  89139. * This is a holder class for the physics joint created by the physics plugin
  89140. * It holds a set of functions to control the underlying joint
  89141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89142. */
  89143. export class PhysicsJoint {
  89144. /**
  89145. * The type of the physics joint
  89146. */
  89147. type: number;
  89148. /**
  89149. * The data for the physics joint
  89150. */
  89151. jointData: PhysicsJointData;
  89152. private _physicsJoint;
  89153. protected _physicsPlugin: IPhysicsEnginePlugin;
  89154. /**
  89155. * Initializes the physics joint
  89156. * @param type The type of the physics joint
  89157. * @param jointData The data for the physics joint
  89158. */
  89159. constructor(
  89160. /**
  89161. * The type of the physics joint
  89162. */
  89163. type: number,
  89164. /**
  89165. * The data for the physics joint
  89166. */
  89167. jointData: PhysicsJointData);
  89168. /**
  89169. * Gets the physics joint
  89170. */
  89171. /**
  89172. * Sets the physics joint
  89173. */
  89174. physicsJoint: any;
  89175. /**
  89176. * Sets the physics plugin
  89177. */
  89178. physicsPlugin: IPhysicsEnginePlugin;
  89179. /**
  89180. * Execute a function that is physics-plugin specific.
  89181. * @param {Function} func the function that will be executed.
  89182. * It accepts two parameters: the physics world and the physics joint
  89183. */
  89184. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89185. /**
  89186. * Distance-Joint type
  89187. */
  89188. static DistanceJoint: number;
  89189. /**
  89190. * Hinge-Joint type
  89191. */
  89192. static HingeJoint: number;
  89193. /**
  89194. * Ball-and-Socket joint type
  89195. */
  89196. static BallAndSocketJoint: number;
  89197. /**
  89198. * Wheel-Joint type
  89199. */
  89200. static WheelJoint: number;
  89201. /**
  89202. * Slider-Joint type
  89203. */
  89204. static SliderJoint: number;
  89205. /**
  89206. * Prismatic-Joint type
  89207. */
  89208. static PrismaticJoint: number;
  89209. /**
  89210. * Universal-Joint type
  89211. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89212. */
  89213. static UniversalJoint: number;
  89214. /**
  89215. * Hinge-Joint 2 type
  89216. */
  89217. static Hinge2Joint: number;
  89218. /**
  89219. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89220. */
  89221. static PointToPointJoint: number;
  89222. /**
  89223. * Spring-Joint type
  89224. */
  89225. static SpringJoint: number;
  89226. /**
  89227. * Lock-Joint type
  89228. */
  89229. static LockJoint: number;
  89230. }
  89231. /**
  89232. * A class representing a physics distance joint
  89233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89234. */
  89235. export class DistanceJoint extends PhysicsJoint {
  89236. /**
  89237. *
  89238. * @param jointData The data for the Distance-Joint
  89239. */
  89240. constructor(jointData: DistanceJointData);
  89241. /**
  89242. * Update the predefined distance.
  89243. * @param maxDistance The maximum preferred distance
  89244. * @param minDistance The minimum preferred distance
  89245. */
  89246. updateDistance(maxDistance: number, minDistance?: number): void;
  89247. }
  89248. /**
  89249. * Represents a Motor-Enabled Joint
  89250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89251. */
  89252. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89253. /**
  89254. * Initializes the Motor-Enabled Joint
  89255. * @param type The type of the joint
  89256. * @param jointData The physica joint data for the joint
  89257. */
  89258. constructor(type: number, jointData: PhysicsJointData);
  89259. /**
  89260. * Set the motor values.
  89261. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89262. * @param force the force to apply
  89263. * @param maxForce max force for this motor.
  89264. */
  89265. setMotor(force?: number, maxForce?: number): void;
  89266. /**
  89267. * Set the motor's limits.
  89268. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89269. * @param upperLimit The upper limit of the motor
  89270. * @param lowerLimit The lower limit of the motor
  89271. */
  89272. setLimit(upperLimit: number, lowerLimit?: number): void;
  89273. }
  89274. /**
  89275. * This class represents a single physics Hinge-Joint
  89276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89277. */
  89278. export class HingeJoint extends MotorEnabledJoint {
  89279. /**
  89280. * Initializes the Hinge-Joint
  89281. * @param jointData The joint data for the Hinge-Joint
  89282. */
  89283. constructor(jointData: PhysicsJointData);
  89284. /**
  89285. * Set the motor values.
  89286. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89287. * @param {number} force the force to apply
  89288. * @param {number} maxForce max force for this motor.
  89289. */
  89290. setMotor(force?: number, maxForce?: number): void;
  89291. /**
  89292. * Set the motor's limits.
  89293. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89294. * @param upperLimit The upper limit of the motor
  89295. * @param lowerLimit The lower limit of the motor
  89296. */
  89297. setLimit(upperLimit: number, lowerLimit?: number): void;
  89298. }
  89299. /**
  89300. * This class represents a dual hinge physics joint (same as wheel joint)
  89301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89302. */
  89303. export class Hinge2Joint extends MotorEnabledJoint {
  89304. /**
  89305. * Initializes the Hinge2-Joint
  89306. * @param jointData The joint data for the Hinge2-Joint
  89307. */
  89308. constructor(jointData: PhysicsJointData);
  89309. /**
  89310. * Set the motor values.
  89311. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89312. * @param {number} targetSpeed the speed the motor is to reach
  89313. * @param {number} maxForce max force for this motor.
  89314. * @param {motorIndex} the motor's index, 0 or 1.
  89315. */
  89316. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  89317. /**
  89318. * Set the motor limits.
  89319. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89320. * @param {number} upperLimit the upper limit
  89321. * @param {number} lowerLimit lower limit
  89322. * @param {motorIndex} the motor's index, 0 or 1.
  89323. */
  89324. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89325. }
  89326. /**
  89327. * Interface for a motor enabled joint
  89328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89329. */
  89330. export interface IMotorEnabledJoint {
  89331. /**
  89332. * Physics joint
  89333. */
  89334. physicsJoint: any;
  89335. /**
  89336. * Sets the motor of the motor-enabled joint
  89337. * @param force The force of the motor
  89338. * @param maxForce The maximum force of the motor
  89339. * @param motorIndex The index of the motor
  89340. */
  89341. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  89342. /**
  89343. * Sets the limit of the motor
  89344. * @param upperLimit The upper limit of the motor
  89345. * @param lowerLimit The lower limit of the motor
  89346. * @param motorIndex The index of the motor
  89347. */
  89348. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89349. }
  89350. /**
  89351. * Joint data for a Distance-Joint
  89352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89353. */
  89354. export interface DistanceJointData extends PhysicsJointData {
  89355. /**
  89356. * Max distance the 2 joint objects can be apart
  89357. */
  89358. maxDistance: number;
  89359. }
  89360. /**
  89361. * Joint data from a spring joint
  89362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89363. */
  89364. export interface SpringJointData extends PhysicsJointData {
  89365. /**
  89366. * Length of the spring
  89367. */
  89368. length: number;
  89369. /**
  89370. * Stiffness of the spring
  89371. */
  89372. stiffness: number;
  89373. /**
  89374. * Damping of the spring
  89375. */
  89376. damping: number;
  89377. /** this callback will be called when applying the force to the impostors. */
  89378. forceApplicationCallback: () => void;
  89379. }
  89380. }
  89381. declare module BABYLON {
  89382. /**
  89383. * Holds the data for the raycast result
  89384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89385. */
  89386. export class PhysicsRaycastResult {
  89387. private _hasHit;
  89388. private _hitDistance;
  89389. private _hitNormalWorld;
  89390. private _hitPointWorld;
  89391. private _rayFromWorld;
  89392. private _rayToWorld;
  89393. /**
  89394. * Gets if there was a hit
  89395. */
  89396. readonly hasHit: boolean;
  89397. /**
  89398. * Gets the distance from the hit
  89399. */
  89400. readonly hitDistance: number;
  89401. /**
  89402. * Gets the hit normal/direction in the world
  89403. */
  89404. readonly hitNormalWorld: Vector3;
  89405. /**
  89406. * Gets the hit point in the world
  89407. */
  89408. readonly hitPointWorld: Vector3;
  89409. /**
  89410. * Gets the ray "start point" of the ray in the world
  89411. */
  89412. readonly rayFromWorld: Vector3;
  89413. /**
  89414. * Gets the ray "end point" of the ray in the world
  89415. */
  89416. readonly rayToWorld: Vector3;
  89417. /**
  89418. * Sets the hit data (normal & point in world space)
  89419. * @param hitNormalWorld defines the normal in world space
  89420. * @param hitPointWorld defines the point in world space
  89421. */
  89422. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  89423. /**
  89424. * Sets the distance from the start point to the hit point
  89425. * @param distance
  89426. */
  89427. setHitDistance(distance: number): void;
  89428. /**
  89429. * Calculates the distance manually
  89430. */
  89431. calculateHitDistance(): void;
  89432. /**
  89433. * Resets all the values to default
  89434. * @param from The from point on world space
  89435. * @param to The to point on world space
  89436. */
  89437. reset(from?: Vector3, to?: Vector3): void;
  89438. }
  89439. /**
  89440. * Interface for the size containing width and height
  89441. */
  89442. interface IXYZ {
  89443. /**
  89444. * X
  89445. */
  89446. x: number;
  89447. /**
  89448. * Y
  89449. */
  89450. y: number;
  89451. /**
  89452. * Z
  89453. */
  89454. z: number;
  89455. }
  89456. }
  89457. declare module BABYLON {
  89458. /**
  89459. * Interface used to describe a physics joint
  89460. */
  89461. export interface PhysicsImpostorJoint {
  89462. /** Defines the main impostor to which the joint is linked */
  89463. mainImpostor: PhysicsImpostor;
  89464. /** Defines the impostor that is connected to the main impostor using this joint */
  89465. connectedImpostor: PhysicsImpostor;
  89466. /** Defines the joint itself */
  89467. joint: PhysicsJoint;
  89468. }
  89469. /** @hidden */
  89470. export interface IPhysicsEnginePlugin {
  89471. world: any;
  89472. name: string;
  89473. setGravity(gravity: Vector3): void;
  89474. setTimeStep(timeStep: number): void;
  89475. getTimeStep(): number;
  89476. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  89477. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89478. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89479. generatePhysicsBody(impostor: PhysicsImpostor): void;
  89480. removePhysicsBody(impostor: PhysicsImpostor): void;
  89481. generateJoint(joint: PhysicsImpostorJoint): void;
  89482. removeJoint(joint: PhysicsImpostorJoint): void;
  89483. isSupported(): boolean;
  89484. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  89485. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  89486. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89487. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89488. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89489. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89490. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  89491. getBodyMass(impostor: PhysicsImpostor): number;
  89492. getBodyFriction(impostor: PhysicsImpostor): number;
  89493. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  89494. getBodyRestitution(impostor: PhysicsImpostor): number;
  89495. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  89496. getBodyPressure?(impostor: PhysicsImpostor): number;
  89497. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  89498. getBodyStiffness?(impostor: PhysicsImpostor): number;
  89499. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  89500. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  89501. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  89502. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  89503. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  89504. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89505. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89506. sleepBody(impostor: PhysicsImpostor): void;
  89507. wakeUpBody(impostor: PhysicsImpostor): void;
  89508. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89509. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  89510. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  89511. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89512. getRadius(impostor: PhysicsImpostor): number;
  89513. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  89514. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  89515. dispose(): void;
  89516. }
  89517. /**
  89518. * Interface used to define a physics engine
  89519. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  89520. */
  89521. export interface IPhysicsEngine {
  89522. /**
  89523. * Gets the gravity vector used by the simulation
  89524. */
  89525. gravity: Vector3;
  89526. /**
  89527. * Sets the gravity vector used by the simulation
  89528. * @param gravity defines the gravity vector to use
  89529. */
  89530. setGravity(gravity: Vector3): void;
  89531. /**
  89532. * Set the time step of the physics engine.
  89533. * Default is 1/60.
  89534. * To slow it down, enter 1/600 for example.
  89535. * To speed it up, 1/30
  89536. * @param newTimeStep the new timestep to apply to this world.
  89537. */
  89538. setTimeStep(newTimeStep: number): void;
  89539. /**
  89540. * Get the time step of the physics engine.
  89541. * @returns the current time step
  89542. */
  89543. getTimeStep(): number;
  89544. /**
  89545. * Release all resources
  89546. */
  89547. dispose(): void;
  89548. /**
  89549. * Gets the name of the current physics plugin
  89550. * @returns the name of the plugin
  89551. */
  89552. getPhysicsPluginName(): string;
  89553. /**
  89554. * Adding a new impostor for the impostor tracking.
  89555. * This will be done by the impostor itself.
  89556. * @param impostor the impostor to add
  89557. */
  89558. addImpostor(impostor: PhysicsImpostor): void;
  89559. /**
  89560. * Remove an impostor from the engine.
  89561. * This impostor and its mesh will not longer be updated by the physics engine.
  89562. * @param impostor the impostor to remove
  89563. */
  89564. removeImpostor(impostor: PhysicsImpostor): void;
  89565. /**
  89566. * Add a joint to the physics engine
  89567. * @param mainImpostor defines the main impostor to which the joint is added.
  89568. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  89569. * @param joint defines the joint that will connect both impostors.
  89570. */
  89571. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89572. /**
  89573. * Removes a joint from the simulation
  89574. * @param mainImpostor defines the impostor used with the joint
  89575. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  89576. * @param joint defines the joint to remove
  89577. */
  89578. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89579. /**
  89580. * Gets the current plugin used to run the simulation
  89581. * @returns current plugin
  89582. */
  89583. getPhysicsPlugin(): IPhysicsEnginePlugin;
  89584. /**
  89585. * Gets the list of physic impostors
  89586. * @returns an array of PhysicsImpostor
  89587. */
  89588. getImpostors(): Array<PhysicsImpostor>;
  89589. /**
  89590. * Gets the impostor for a physics enabled object
  89591. * @param object defines the object impersonated by the impostor
  89592. * @returns the PhysicsImpostor or null if not found
  89593. */
  89594. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89595. /**
  89596. * Gets the impostor for a physics body object
  89597. * @param body defines physics body used by the impostor
  89598. * @returns the PhysicsImpostor or null if not found
  89599. */
  89600. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  89601. /**
  89602. * Does a raycast in the physics world
  89603. * @param from when should the ray start?
  89604. * @param to when should the ray end?
  89605. * @returns PhysicsRaycastResult
  89606. */
  89607. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89608. /**
  89609. * Called by the scene. No need to call it.
  89610. * @param delta defines the timespam between frames
  89611. */
  89612. _step(delta: number): void;
  89613. }
  89614. }
  89615. declare module BABYLON {
  89616. /**
  89617. * The interface for the physics imposter parameters
  89618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89619. */
  89620. export interface PhysicsImpostorParameters {
  89621. /**
  89622. * The mass of the physics imposter
  89623. */
  89624. mass: number;
  89625. /**
  89626. * The friction of the physics imposter
  89627. */
  89628. friction?: number;
  89629. /**
  89630. * The coefficient of restitution of the physics imposter
  89631. */
  89632. restitution?: number;
  89633. /**
  89634. * The native options of the physics imposter
  89635. */
  89636. nativeOptions?: any;
  89637. /**
  89638. * Specifies if the parent should be ignored
  89639. */
  89640. ignoreParent?: boolean;
  89641. /**
  89642. * Specifies if bi-directional transformations should be disabled
  89643. */
  89644. disableBidirectionalTransformation?: boolean;
  89645. /**
  89646. * The pressure inside the physics imposter, soft object only
  89647. */
  89648. pressure?: number;
  89649. /**
  89650. * The stiffness the physics imposter, soft object only
  89651. */
  89652. stiffness?: number;
  89653. /**
  89654. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  89655. */
  89656. velocityIterations?: number;
  89657. /**
  89658. * The number of iterations used in maintaining consistent vertex positions, soft object only
  89659. */
  89660. positionIterations?: number;
  89661. /**
  89662. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  89663. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  89664. * Add to fix multiple points
  89665. */
  89666. fixedPoints?: number;
  89667. /**
  89668. * The collision margin around a soft object
  89669. */
  89670. margin?: number;
  89671. /**
  89672. * The collision margin around a soft object
  89673. */
  89674. damping?: number;
  89675. /**
  89676. * The path for a rope based on an extrusion
  89677. */
  89678. path?: any;
  89679. /**
  89680. * The shape of an extrusion used for a rope based on an extrusion
  89681. */
  89682. shape?: any;
  89683. }
  89684. /**
  89685. * Interface for a physics-enabled object
  89686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89687. */
  89688. export interface IPhysicsEnabledObject {
  89689. /**
  89690. * The position of the physics-enabled object
  89691. */
  89692. position: Vector3;
  89693. /**
  89694. * The rotation of the physics-enabled object
  89695. */
  89696. rotationQuaternion: Nullable<Quaternion>;
  89697. /**
  89698. * The scale of the physics-enabled object
  89699. */
  89700. scaling: Vector3;
  89701. /**
  89702. * The rotation of the physics-enabled object
  89703. */
  89704. rotation?: Vector3;
  89705. /**
  89706. * The parent of the physics-enabled object
  89707. */
  89708. parent?: any;
  89709. /**
  89710. * The bounding info of the physics-enabled object
  89711. * @returns The bounding info of the physics-enabled object
  89712. */
  89713. getBoundingInfo(): BoundingInfo;
  89714. /**
  89715. * Computes the world matrix
  89716. * @param force Specifies if the world matrix should be computed by force
  89717. * @returns A world matrix
  89718. */
  89719. computeWorldMatrix(force: boolean): Matrix;
  89720. /**
  89721. * Gets the world matrix
  89722. * @returns A world matrix
  89723. */
  89724. getWorldMatrix?(): Matrix;
  89725. /**
  89726. * Gets the child meshes
  89727. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  89728. * @returns An array of abstract meshes
  89729. */
  89730. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  89731. /**
  89732. * Gets the vertex data
  89733. * @param kind The type of vertex data
  89734. * @returns A nullable array of numbers, or a float32 array
  89735. */
  89736. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  89737. /**
  89738. * Gets the indices from the mesh
  89739. * @returns A nullable array of index arrays
  89740. */
  89741. getIndices?(): Nullable<IndicesArray>;
  89742. /**
  89743. * Gets the scene from the mesh
  89744. * @returns the indices array or null
  89745. */
  89746. getScene?(): Scene;
  89747. /**
  89748. * Gets the absolute position from the mesh
  89749. * @returns the absolute position
  89750. */
  89751. getAbsolutePosition(): Vector3;
  89752. /**
  89753. * Gets the absolute pivot point from the mesh
  89754. * @returns the absolute pivot point
  89755. */
  89756. getAbsolutePivotPoint(): Vector3;
  89757. /**
  89758. * Rotates the mesh
  89759. * @param axis The axis of rotation
  89760. * @param amount The amount of rotation
  89761. * @param space The space of the rotation
  89762. * @returns The rotation transform node
  89763. */
  89764. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89765. /**
  89766. * Translates the mesh
  89767. * @param axis The axis of translation
  89768. * @param distance The distance of translation
  89769. * @param space The space of the translation
  89770. * @returns The transform node
  89771. */
  89772. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89773. /**
  89774. * Sets the absolute position of the mesh
  89775. * @param absolutePosition The absolute position of the mesh
  89776. * @returns The transform node
  89777. */
  89778. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89779. /**
  89780. * Gets the class name of the mesh
  89781. * @returns The class name
  89782. */
  89783. getClassName(): string;
  89784. }
  89785. /**
  89786. * Represents a physics imposter
  89787. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89788. */
  89789. export class PhysicsImpostor {
  89790. /**
  89791. * The physics-enabled object used as the physics imposter
  89792. */
  89793. object: IPhysicsEnabledObject;
  89794. /**
  89795. * The type of the physics imposter
  89796. */
  89797. type: number;
  89798. private _options;
  89799. private _scene?;
  89800. /**
  89801. * The default object size of the imposter
  89802. */
  89803. static DEFAULT_OBJECT_SIZE: Vector3;
  89804. /**
  89805. * The identity quaternion of the imposter
  89806. */
  89807. static IDENTITY_QUATERNION: Quaternion;
  89808. /** @hidden */
  89809. _pluginData: any;
  89810. private _physicsEngine;
  89811. private _physicsBody;
  89812. private _bodyUpdateRequired;
  89813. private _onBeforePhysicsStepCallbacks;
  89814. private _onAfterPhysicsStepCallbacks;
  89815. /** @hidden */
  89816. _onPhysicsCollideCallbacks: Array<{
  89817. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  89818. otherImpostors: Array<PhysicsImpostor>;
  89819. }>;
  89820. private _deltaPosition;
  89821. private _deltaRotation;
  89822. private _deltaRotationConjugated;
  89823. /** @hidden */
  89824. _isFromLine: boolean;
  89825. private _parent;
  89826. private _isDisposed;
  89827. private static _tmpVecs;
  89828. private static _tmpQuat;
  89829. /**
  89830. * Specifies if the physics imposter is disposed
  89831. */
  89832. readonly isDisposed: boolean;
  89833. /**
  89834. * Gets the mass of the physics imposter
  89835. */
  89836. mass: number;
  89837. /**
  89838. * Gets the coefficient of friction
  89839. */
  89840. /**
  89841. * Sets the coefficient of friction
  89842. */
  89843. friction: number;
  89844. /**
  89845. * Gets the coefficient of restitution
  89846. */
  89847. /**
  89848. * Sets the coefficient of restitution
  89849. */
  89850. restitution: number;
  89851. /**
  89852. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  89853. */
  89854. /**
  89855. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  89856. */
  89857. pressure: number;
  89858. /**
  89859. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89860. */
  89861. /**
  89862. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89863. */
  89864. stiffness: number;
  89865. /**
  89866. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89867. */
  89868. /**
  89869. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89870. */
  89871. velocityIterations: number;
  89872. /**
  89873. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89874. */
  89875. /**
  89876. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89877. */
  89878. positionIterations: number;
  89879. /**
  89880. * The unique id of the physics imposter
  89881. * set by the physics engine when adding this impostor to the array
  89882. */
  89883. uniqueId: number;
  89884. /**
  89885. * @hidden
  89886. */
  89887. soft: boolean;
  89888. /**
  89889. * @hidden
  89890. */
  89891. segments: number;
  89892. private _joints;
  89893. /**
  89894. * Initializes the physics imposter
  89895. * @param object The physics-enabled object used as the physics imposter
  89896. * @param type The type of the physics imposter
  89897. * @param _options The options for the physics imposter
  89898. * @param _scene The Babylon scene
  89899. */
  89900. constructor(
  89901. /**
  89902. * The physics-enabled object used as the physics imposter
  89903. */
  89904. object: IPhysicsEnabledObject,
  89905. /**
  89906. * The type of the physics imposter
  89907. */
  89908. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  89909. /**
  89910. * This function will completly initialize this impostor.
  89911. * It will create a new body - but only if this mesh has no parent.
  89912. * If it has, this impostor will not be used other than to define the impostor
  89913. * of the child mesh.
  89914. * @hidden
  89915. */
  89916. _init(): void;
  89917. private _getPhysicsParent;
  89918. /**
  89919. * Should a new body be generated.
  89920. * @returns boolean specifying if body initialization is required
  89921. */
  89922. isBodyInitRequired(): boolean;
  89923. /**
  89924. * Sets the updated scaling
  89925. * @param updated Specifies if the scaling is updated
  89926. */
  89927. setScalingUpdated(): void;
  89928. /**
  89929. * Force a regeneration of this or the parent's impostor's body.
  89930. * Use under cautious - This will remove all joints already implemented.
  89931. */
  89932. forceUpdate(): void;
  89933. /**
  89934. * Gets the body that holds this impostor. Either its own, or its parent.
  89935. */
  89936. /**
  89937. * Set the physics body. Used mainly by the physics engine/plugin
  89938. */
  89939. physicsBody: any;
  89940. /**
  89941. * Get the parent of the physics imposter
  89942. * @returns Physics imposter or null
  89943. */
  89944. /**
  89945. * Sets the parent of the physics imposter
  89946. */
  89947. parent: Nullable<PhysicsImpostor>;
  89948. /**
  89949. * Resets the update flags
  89950. */
  89951. resetUpdateFlags(): void;
  89952. /**
  89953. * Gets the object extend size
  89954. * @returns the object extend size
  89955. */
  89956. getObjectExtendSize(): Vector3;
  89957. /**
  89958. * Gets the object center
  89959. * @returns The object center
  89960. */
  89961. getObjectCenter(): Vector3;
  89962. /**
  89963. * Get a specific parametes from the options parameter
  89964. * @param paramName The object parameter name
  89965. * @returns The object parameter
  89966. */
  89967. getParam(paramName: string): any;
  89968. /**
  89969. * Sets a specific parameter in the options given to the physics plugin
  89970. * @param paramName The parameter name
  89971. * @param value The value of the parameter
  89972. */
  89973. setParam(paramName: string, value: number): void;
  89974. /**
  89975. * Specifically change the body's mass option. Won't recreate the physics body object
  89976. * @param mass The mass of the physics imposter
  89977. */
  89978. setMass(mass: number): void;
  89979. /**
  89980. * Gets the linear velocity
  89981. * @returns linear velocity or null
  89982. */
  89983. getLinearVelocity(): Nullable<Vector3>;
  89984. /**
  89985. * Sets the linear velocity
  89986. * @param velocity linear velocity or null
  89987. */
  89988. setLinearVelocity(velocity: Nullable<Vector3>): void;
  89989. /**
  89990. * Gets the angular velocity
  89991. * @returns angular velocity or null
  89992. */
  89993. getAngularVelocity(): Nullable<Vector3>;
  89994. /**
  89995. * Sets the angular velocity
  89996. * @param velocity The velocity or null
  89997. */
  89998. setAngularVelocity(velocity: Nullable<Vector3>): void;
  89999. /**
  90000. * Execute a function with the physics plugin native code
  90001. * Provide a function the will have two variables - the world object and the physics body object
  90002. * @param func The function to execute with the physics plugin native code
  90003. */
  90004. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  90005. /**
  90006. * Register a function that will be executed before the physics world is stepping forward
  90007. * @param func The function to execute before the physics world is stepped forward
  90008. */
  90009. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90010. /**
  90011. * Unregister a function that will be executed before the physics world is stepping forward
  90012. * @param func The function to execute before the physics world is stepped forward
  90013. */
  90014. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90015. /**
  90016. * Register a function that will be executed after the physics step
  90017. * @param func The function to execute after physics step
  90018. */
  90019. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90020. /**
  90021. * Unregisters a function that will be executed after the physics step
  90022. * @param func The function to execute after physics step
  90023. */
  90024. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90025. /**
  90026. * register a function that will be executed when this impostor collides against a different body
  90027. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  90028. * @param func Callback that is executed on collision
  90029. */
  90030. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  90031. /**
  90032. * Unregisters the physics imposter on contact
  90033. * @param collideAgainst The physics object to collide against
  90034. * @param func Callback to execute on collision
  90035. */
  90036. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  90037. private _tmpQuat;
  90038. private _tmpQuat2;
  90039. /**
  90040. * Get the parent rotation
  90041. * @returns The parent rotation
  90042. */
  90043. getParentsRotation(): Quaternion;
  90044. /**
  90045. * this function is executed by the physics engine.
  90046. */
  90047. beforeStep: () => void;
  90048. /**
  90049. * this function is executed by the physics engine
  90050. */
  90051. afterStep: () => void;
  90052. /**
  90053. * Legacy collision detection event support
  90054. */
  90055. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90056. /**
  90057. * event and body object due to cannon's event-based architecture.
  90058. */
  90059. onCollide: (e: {
  90060. body: any;
  90061. }) => void;
  90062. /**
  90063. * Apply a force
  90064. * @param force The force to apply
  90065. * @param contactPoint The contact point for the force
  90066. * @returns The physics imposter
  90067. */
  90068. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90069. /**
  90070. * Apply an impulse
  90071. * @param force The impulse force
  90072. * @param contactPoint The contact point for the impulse force
  90073. * @returns The physics imposter
  90074. */
  90075. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90076. /**
  90077. * A help function to create a joint
  90078. * @param otherImpostor A physics imposter used to create a joint
  90079. * @param jointType The type of joint
  90080. * @param jointData The data for the joint
  90081. * @returns The physics imposter
  90082. */
  90083. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90084. /**
  90085. * Add a joint to this impostor with a different impostor
  90086. * @param otherImpostor A physics imposter used to add a joint
  90087. * @param joint The joint to add
  90088. * @returns The physics imposter
  90089. */
  90090. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90091. /**
  90092. * Add an anchor to a cloth impostor
  90093. * @param otherImpostor rigid impostor to anchor to
  90094. * @param width ratio across width from 0 to 1
  90095. * @param height ratio up height from 0 to 1
  90096. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90097. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90098. * @returns impostor the soft imposter
  90099. */
  90100. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90101. /**
  90102. * Add a hook to a rope impostor
  90103. * @param otherImpostor rigid impostor to anchor to
  90104. * @param length ratio across rope from 0 to 1
  90105. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90106. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90107. * @returns impostor the rope imposter
  90108. */
  90109. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90110. /**
  90111. * Will keep this body still, in a sleep mode.
  90112. * @returns the physics imposter
  90113. */
  90114. sleep(): PhysicsImpostor;
  90115. /**
  90116. * Wake the body up.
  90117. * @returns The physics imposter
  90118. */
  90119. wakeUp(): PhysicsImpostor;
  90120. /**
  90121. * Clones the physics imposter
  90122. * @param newObject The physics imposter clones to this physics-enabled object
  90123. * @returns A nullable physics imposter
  90124. */
  90125. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90126. /**
  90127. * Disposes the physics imposter
  90128. */
  90129. dispose(): void;
  90130. /**
  90131. * Sets the delta position
  90132. * @param position The delta position amount
  90133. */
  90134. setDeltaPosition(position: Vector3): void;
  90135. /**
  90136. * Sets the delta rotation
  90137. * @param rotation The delta rotation amount
  90138. */
  90139. setDeltaRotation(rotation: Quaternion): void;
  90140. /**
  90141. * Gets the box size of the physics imposter and stores the result in the input parameter
  90142. * @param result Stores the box size
  90143. * @returns The physics imposter
  90144. */
  90145. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90146. /**
  90147. * Gets the radius of the physics imposter
  90148. * @returns Radius of the physics imposter
  90149. */
  90150. getRadius(): number;
  90151. /**
  90152. * Sync a bone with this impostor
  90153. * @param bone The bone to sync to the impostor.
  90154. * @param boneMesh The mesh that the bone is influencing.
  90155. * @param jointPivot The pivot of the joint / bone in local space.
  90156. * @param distToJoint Optional distance from the impostor to the joint.
  90157. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90158. */
  90159. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90160. /**
  90161. * Sync impostor to a bone
  90162. * @param bone The bone that the impostor will be synced to.
  90163. * @param boneMesh The mesh that the bone is influencing.
  90164. * @param jointPivot The pivot of the joint / bone in local space.
  90165. * @param distToJoint Optional distance from the impostor to the joint.
  90166. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90167. * @param boneAxis Optional vector3 axis the bone is aligned with
  90168. */
  90169. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90170. /**
  90171. * No-Imposter type
  90172. */
  90173. static NoImpostor: number;
  90174. /**
  90175. * Sphere-Imposter type
  90176. */
  90177. static SphereImpostor: number;
  90178. /**
  90179. * Box-Imposter type
  90180. */
  90181. static BoxImpostor: number;
  90182. /**
  90183. * Plane-Imposter type
  90184. */
  90185. static PlaneImpostor: number;
  90186. /**
  90187. * Mesh-imposter type
  90188. */
  90189. static MeshImpostor: number;
  90190. /**
  90191. * Capsule-Impostor type (Ammo.js plugin only)
  90192. */
  90193. static CapsuleImpostor: number;
  90194. /**
  90195. * Cylinder-Imposter type
  90196. */
  90197. static CylinderImpostor: number;
  90198. /**
  90199. * Particle-Imposter type
  90200. */
  90201. static ParticleImpostor: number;
  90202. /**
  90203. * Heightmap-Imposter type
  90204. */
  90205. static HeightmapImpostor: number;
  90206. /**
  90207. * ConvexHull-Impostor type (Ammo.js plugin only)
  90208. */
  90209. static ConvexHullImpostor: number;
  90210. /**
  90211. * Rope-Imposter type
  90212. */
  90213. static RopeImpostor: number;
  90214. /**
  90215. * Cloth-Imposter type
  90216. */
  90217. static ClothImpostor: number;
  90218. /**
  90219. * Softbody-Imposter type
  90220. */
  90221. static SoftbodyImpostor: number;
  90222. }
  90223. }
  90224. declare module BABYLON {
  90225. /**
  90226. * @hidden
  90227. **/
  90228. export class _CreationDataStorage {
  90229. closePath?: boolean;
  90230. closeArray?: boolean;
  90231. idx: number[];
  90232. dashSize: number;
  90233. gapSize: number;
  90234. path3D: Path3D;
  90235. pathArray: Vector3[][];
  90236. arc: number;
  90237. radius: number;
  90238. cap: number;
  90239. tessellation: number;
  90240. }
  90241. /**
  90242. * @hidden
  90243. **/
  90244. class _InstanceDataStorage {
  90245. visibleInstances: any;
  90246. batchCache: _InstancesBatch;
  90247. instancesBufferSize: number;
  90248. instancesBuffer: Nullable<Buffer>;
  90249. instancesData: Float32Array;
  90250. overridenInstanceCount: number;
  90251. isFrozen: boolean;
  90252. previousBatch: Nullable<_InstancesBatch>;
  90253. hardwareInstancedRendering: boolean;
  90254. sideOrientation: number;
  90255. }
  90256. /**
  90257. * @hidden
  90258. **/
  90259. export class _InstancesBatch {
  90260. mustReturn: boolean;
  90261. visibleInstances: Nullable<InstancedMesh[]>[];
  90262. renderSelf: boolean[];
  90263. hardwareInstancedRendering: boolean[];
  90264. }
  90265. /**
  90266. * Class used to represent renderable models
  90267. */
  90268. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90269. /**
  90270. * Mesh side orientation : usually the external or front surface
  90271. */
  90272. static readonly FRONTSIDE: number;
  90273. /**
  90274. * Mesh side orientation : usually the internal or back surface
  90275. */
  90276. static readonly BACKSIDE: number;
  90277. /**
  90278. * Mesh side orientation : both internal and external or front and back surfaces
  90279. */
  90280. static readonly DOUBLESIDE: number;
  90281. /**
  90282. * Mesh side orientation : by default, `FRONTSIDE`
  90283. */
  90284. static readonly DEFAULTSIDE: number;
  90285. /**
  90286. * Mesh cap setting : no cap
  90287. */
  90288. static readonly NO_CAP: number;
  90289. /**
  90290. * Mesh cap setting : one cap at the beginning of the mesh
  90291. */
  90292. static readonly CAP_START: number;
  90293. /**
  90294. * Mesh cap setting : one cap at the end of the mesh
  90295. */
  90296. static readonly CAP_END: number;
  90297. /**
  90298. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90299. */
  90300. static readonly CAP_ALL: number;
  90301. /**
  90302. * Mesh pattern setting : no flip or rotate
  90303. */
  90304. static readonly NO_FLIP: number;
  90305. /**
  90306. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  90307. */
  90308. static readonly FLIP_TILE: number;
  90309. /**
  90310. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  90311. */
  90312. static readonly ROTATE_TILE: number;
  90313. /**
  90314. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  90315. */
  90316. static readonly FLIP_ROW: number;
  90317. /**
  90318. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  90319. */
  90320. static readonly ROTATE_ROW: number;
  90321. /**
  90322. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  90323. */
  90324. static readonly FLIP_N_ROTATE_TILE: number;
  90325. /**
  90326. * Mesh pattern setting : rotate pattern and rotate
  90327. */
  90328. static readonly FLIP_N_ROTATE_ROW: number;
  90329. /**
  90330. * Mesh tile positioning : part tiles same on left/right or top/bottom
  90331. */
  90332. static readonly CENTER: number;
  90333. /**
  90334. * Mesh tile positioning : part tiles on left
  90335. */
  90336. static readonly LEFT: number;
  90337. /**
  90338. * Mesh tile positioning : part tiles on right
  90339. */
  90340. static readonly RIGHT: number;
  90341. /**
  90342. * Mesh tile positioning : part tiles on top
  90343. */
  90344. static readonly TOP: number;
  90345. /**
  90346. * Mesh tile positioning : part tiles on bottom
  90347. */
  90348. static readonly BOTTOM: number;
  90349. /**
  90350. * Gets the default side orientation.
  90351. * @param orientation the orientation to value to attempt to get
  90352. * @returns the default orientation
  90353. * @hidden
  90354. */
  90355. static _GetDefaultSideOrientation(orientation?: number): number;
  90356. private _internalMeshDataInfo;
  90357. /**
  90358. * An event triggered before rendering the mesh
  90359. */
  90360. readonly onBeforeRenderObservable: Observable<Mesh>;
  90361. /**
  90362. * An event triggered before binding the mesh
  90363. */
  90364. readonly onBeforeBindObservable: Observable<Mesh>;
  90365. /**
  90366. * An event triggered after rendering the mesh
  90367. */
  90368. readonly onAfterRenderObservable: Observable<Mesh>;
  90369. /**
  90370. * An event triggered before drawing the mesh
  90371. */
  90372. readonly onBeforeDrawObservable: Observable<Mesh>;
  90373. private _onBeforeDrawObserver;
  90374. /**
  90375. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  90376. */
  90377. onBeforeDraw: () => void;
  90378. readonly hasInstances: boolean;
  90379. /**
  90380. * Gets the delay loading state of the mesh (when delay loading is turned on)
  90381. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  90382. */
  90383. delayLoadState: number;
  90384. /**
  90385. * Gets the list of instances created from this mesh
  90386. * it is not supposed to be modified manually.
  90387. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  90388. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90389. */
  90390. instances: InstancedMesh[];
  90391. /**
  90392. * Gets the file containing delay loading data for this mesh
  90393. */
  90394. delayLoadingFile: string;
  90395. /** @hidden */
  90396. _binaryInfo: any;
  90397. /**
  90398. * User defined function used to change how LOD level selection is done
  90399. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90400. */
  90401. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  90402. /**
  90403. * Gets or sets the morph target manager
  90404. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90405. */
  90406. morphTargetManager: Nullable<MorphTargetManager>;
  90407. /** @hidden */
  90408. _creationDataStorage: Nullable<_CreationDataStorage>;
  90409. /** @hidden */
  90410. _geometry: Nullable<Geometry>;
  90411. /** @hidden */
  90412. _delayInfo: Array<string>;
  90413. /** @hidden */
  90414. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  90415. /** @hidden */
  90416. _instanceDataStorage: _InstanceDataStorage;
  90417. private _effectiveMaterial;
  90418. /** @hidden */
  90419. _shouldGenerateFlatShading: boolean;
  90420. /** @hidden */
  90421. _originalBuilderSideOrientation: number;
  90422. /**
  90423. * Use this property to change the original side orientation defined at construction time
  90424. */
  90425. overrideMaterialSideOrientation: Nullable<number>;
  90426. /**
  90427. * Gets the source mesh (the one used to clone this one from)
  90428. */
  90429. readonly source: Nullable<Mesh>;
  90430. /**
  90431. * Gets or sets a boolean indicating that this mesh does not use index buffer
  90432. */
  90433. isUnIndexed: boolean;
  90434. /**
  90435. * @constructor
  90436. * @param name The value used by scene.getMeshByName() to do a lookup.
  90437. * @param scene The scene to add this mesh to.
  90438. * @param parent The parent of this mesh, if it has one
  90439. * @param source An optional Mesh from which geometry is shared, cloned.
  90440. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90441. * When false, achieved by calling a clone(), also passing False.
  90442. * This will make creation of children, recursive.
  90443. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  90444. */
  90445. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  90446. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  90447. /**
  90448. * Gets the class name
  90449. * @returns the string "Mesh".
  90450. */
  90451. getClassName(): string;
  90452. /** @hidden */
  90453. readonly _isMesh: boolean;
  90454. /**
  90455. * Returns a description of this mesh
  90456. * @param fullDetails define if full details about this mesh must be used
  90457. * @returns a descriptive string representing this mesh
  90458. */
  90459. toString(fullDetails?: boolean): string;
  90460. /** @hidden */
  90461. _unBindEffect(): void;
  90462. /**
  90463. * Gets a boolean indicating if this mesh has LOD
  90464. */
  90465. readonly hasLODLevels: boolean;
  90466. /**
  90467. * Gets the list of MeshLODLevel associated with the current mesh
  90468. * @returns an array of MeshLODLevel
  90469. */
  90470. getLODLevels(): MeshLODLevel[];
  90471. private _sortLODLevels;
  90472. /**
  90473. * Add a mesh as LOD level triggered at the given distance.
  90474. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90475. * @param distance The distance from the center of the object to show this level
  90476. * @param mesh The mesh to be added as LOD level (can be null)
  90477. * @return This mesh (for chaining)
  90478. */
  90479. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  90480. /**
  90481. * Returns the LOD level mesh at the passed distance or null if not found.
  90482. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90483. * @param distance The distance from the center of the object to show this level
  90484. * @returns a Mesh or `null`
  90485. */
  90486. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  90487. /**
  90488. * Remove a mesh from the LOD array
  90489. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90490. * @param mesh defines the mesh to be removed
  90491. * @return This mesh (for chaining)
  90492. */
  90493. removeLODLevel(mesh: Mesh): Mesh;
  90494. /**
  90495. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  90496. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90497. * @param camera defines the camera to use to compute distance
  90498. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  90499. * @return This mesh (for chaining)
  90500. */
  90501. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  90502. /**
  90503. * Gets the mesh internal Geometry object
  90504. */
  90505. readonly geometry: Nullable<Geometry>;
  90506. /**
  90507. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  90508. * @returns the total number of vertices
  90509. */
  90510. getTotalVertices(): number;
  90511. /**
  90512. * Returns the content of an associated vertex buffer
  90513. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90514. * - VertexBuffer.PositionKind
  90515. * - VertexBuffer.UVKind
  90516. * - VertexBuffer.UV2Kind
  90517. * - VertexBuffer.UV3Kind
  90518. * - VertexBuffer.UV4Kind
  90519. * - VertexBuffer.UV5Kind
  90520. * - VertexBuffer.UV6Kind
  90521. * - VertexBuffer.ColorKind
  90522. * - VertexBuffer.MatricesIndicesKind
  90523. * - VertexBuffer.MatricesIndicesExtraKind
  90524. * - VertexBuffer.MatricesWeightsKind
  90525. * - VertexBuffer.MatricesWeightsExtraKind
  90526. * @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
  90527. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  90528. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  90529. */
  90530. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90531. /**
  90532. * Returns the mesh VertexBuffer object from the requested `kind`
  90533. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90534. * - VertexBuffer.PositionKind
  90535. * - VertexBuffer.NormalKind
  90536. * - VertexBuffer.UVKind
  90537. * - VertexBuffer.UV2Kind
  90538. * - VertexBuffer.UV3Kind
  90539. * - VertexBuffer.UV4Kind
  90540. * - VertexBuffer.UV5Kind
  90541. * - VertexBuffer.UV6Kind
  90542. * - VertexBuffer.ColorKind
  90543. * - VertexBuffer.MatricesIndicesKind
  90544. * - VertexBuffer.MatricesIndicesExtraKind
  90545. * - VertexBuffer.MatricesWeightsKind
  90546. * - VertexBuffer.MatricesWeightsExtraKind
  90547. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  90548. */
  90549. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90550. /**
  90551. * Tests if a specific vertex buffer is associated with this mesh
  90552. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90553. * - VertexBuffer.PositionKind
  90554. * - VertexBuffer.NormalKind
  90555. * - VertexBuffer.UVKind
  90556. * - VertexBuffer.UV2Kind
  90557. * - VertexBuffer.UV3Kind
  90558. * - VertexBuffer.UV4Kind
  90559. * - VertexBuffer.UV5Kind
  90560. * - VertexBuffer.UV6Kind
  90561. * - VertexBuffer.ColorKind
  90562. * - VertexBuffer.MatricesIndicesKind
  90563. * - VertexBuffer.MatricesIndicesExtraKind
  90564. * - VertexBuffer.MatricesWeightsKind
  90565. * - VertexBuffer.MatricesWeightsExtraKind
  90566. * @returns a boolean
  90567. */
  90568. isVerticesDataPresent(kind: string): boolean;
  90569. /**
  90570. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  90571. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90572. * - VertexBuffer.PositionKind
  90573. * - VertexBuffer.UVKind
  90574. * - VertexBuffer.UV2Kind
  90575. * - VertexBuffer.UV3Kind
  90576. * - VertexBuffer.UV4Kind
  90577. * - VertexBuffer.UV5Kind
  90578. * - VertexBuffer.UV6Kind
  90579. * - VertexBuffer.ColorKind
  90580. * - VertexBuffer.MatricesIndicesKind
  90581. * - VertexBuffer.MatricesIndicesExtraKind
  90582. * - VertexBuffer.MatricesWeightsKind
  90583. * - VertexBuffer.MatricesWeightsExtraKind
  90584. * @returns a boolean
  90585. */
  90586. isVertexBufferUpdatable(kind: string): boolean;
  90587. /**
  90588. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  90589. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90590. * - VertexBuffer.PositionKind
  90591. * - VertexBuffer.NormalKind
  90592. * - VertexBuffer.UVKind
  90593. * - VertexBuffer.UV2Kind
  90594. * - VertexBuffer.UV3Kind
  90595. * - VertexBuffer.UV4Kind
  90596. * - VertexBuffer.UV5Kind
  90597. * - VertexBuffer.UV6Kind
  90598. * - VertexBuffer.ColorKind
  90599. * - VertexBuffer.MatricesIndicesKind
  90600. * - VertexBuffer.MatricesIndicesExtraKind
  90601. * - VertexBuffer.MatricesWeightsKind
  90602. * - VertexBuffer.MatricesWeightsExtraKind
  90603. * @returns an array of strings
  90604. */
  90605. getVerticesDataKinds(): string[];
  90606. /**
  90607. * Returns a positive integer : the total number of indices in this mesh geometry.
  90608. * @returns the numner of indices or zero if the mesh has no geometry.
  90609. */
  90610. getTotalIndices(): number;
  90611. /**
  90612. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90613. * @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.
  90614. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90615. * @returns the indices array or an empty array if the mesh has no geometry
  90616. */
  90617. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90618. readonly isBlocked: boolean;
  90619. /**
  90620. * Determine if the current mesh is ready to be rendered
  90621. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90622. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  90623. * @returns true if all associated assets are ready (material, textures, shaders)
  90624. */
  90625. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  90626. /**
  90627. * 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.
  90628. */
  90629. readonly areNormalsFrozen: boolean;
  90630. /**
  90631. * 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.
  90632. * @returns the current mesh
  90633. */
  90634. freezeNormals(): Mesh;
  90635. /**
  90636. * 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
  90637. * @returns the current mesh
  90638. */
  90639. unfreezeNormals(): Mesh;
  90640. /**
  90641. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  90642. */
  90643. overridenInstanceCount: number;
  90644. /** @hidden */
  90645. _preActivate(): Mesh;
  90646. /** @hidden */
  90647. _preActivateForIntermediateRendering(renderId: number): Mesh;
  90648. /** @hidden */
  90649. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  90650. /**
  90651. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90652. * This means the mesh underlying bounding box and sphere are recomputed.
  90653. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90654. * @returns the current mesh
  90655. */
  90656. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  90657. /** @hidden */
  90658. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  90659. /**
  90660. * This function will subdivide the mesh into multiple submeshes
  90661. * @param count defines the expected number of submeshes
  90662. */
  90663. subdivide(count: number): void;
  90664. /**
  90665. * Copy a FloatArray into a specific associated vertex buffer
  90666. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90667. * - VertexBuffer.PositionKind
  90668. * - VertexBuffer.UVKind
  90669. * - VertexBuffer.UV2Kind
  90670. * - VertexBuffer.UV3Kind
  90671. * - VertexBuffer.UV4Kind
  90672. * - VertexBuffer.UV5Kind
  90673. * - VertexBuffer.UV6Kind
  90674. * - VertexBuffer.ColorKind
  90675. * - VertexBuffer.MatricesIndicesKind
  90676. * - VertexBuffer.MatricesIndicesExtraKind
  90677. * - VertexBuffer.MatricesWeightsKind
  90678. * - VertexBuffer.MatricesWeightsExtraKind
  90679. * @param data defines the data source
  90680. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90681. * @param stride defines the data stride size (can be null)
  90682. * @returns the current mesh
  90683. */
  90684. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90685. /**
  90686. * Flags an associated vertex buffer as updatable
  90687. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  90688. * - VertexBuffer.PositionKind
  90689. * - VertexBuffer.UVKind
  90690. * - VertexBuffer.UV2Kind
  90691. * - VertexBuffer.UV3Kind
  90692. * - VertexBuffer.UV4Kind
  90693. * - VertexBuffer.UV5Kind
  90694. * - VertexBuffer.UV6Kind
  90695. * - VertexBuffer.ColorKind
  90696. * - VertexBuffer.MatricesIndicesKind
  90697. * - VertexBuffer.MatricesIndicesExtraKind
  90698. * - VertexBuffer.MatricesWeightsKind
  90699. * - VertexBuffer.MatricesWeightsExtraKind
  90700. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90701. */
  90702. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  90703. /**
  90704. * Sets the mesh global Vertex Buffer
  90705. * @param buffer defines the buffer to use
  90706. * @returns the current mesh
  90707. */
  90708. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  90709. /**
  90710. * Update a specific associated vertex buffer
  90711. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90712. * - VertexBuffer.PositionKind
  90713. * - VertexBuffer.UVKind
  90714. * - VertexBuffer.UV2Kind
  90715. * - VertexBuffer.UV3Kind
  90716. * - VertexBuffer.UV4Kind
  90717. * - VertexBuffer.UV5Kind
  90718. * - VertexBuffer.UV6Kind
  90719. * - VertexBuffer.ColorKind
  90720. * - VertexBuffer.MatricesIndicesKind
  90721. * - VertexBuffer.MatricesIndicesExtraKind
  90722. * - VertexBuffer.MatricesWeightsKind
  90723. * - VertexBuffer.MatricesWeightsExtraKind
  90724. * @param data defines the data source
  90725. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90726. * @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)
  90727. * @returns the current mesh
  90728. */
  90729. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90730. /**
  90731. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  90732. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  90733. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  90734. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  90735. * @returns the current mesh
  90736. */
  90737. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  90738. /**
  90739. * Creates a un-shared specific occurence of the geometry for the mesh.
  90740. * @returns the current mesh
  90741. */
  90742. makeGeometryUnique(): Mesh;
  90743. /**
  90744. * Set the index buffer of this mesh
  90745. * @param indices defines the source data
  90746. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  90747. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  90748. * @returns the current mesh
  90749. */
  90750. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  90751. /**
  90752. * Update the current index buffer
  90753. * @param indices defines the source data
  90754. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90755. * @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)
  90756. * @returns the current mesh
  90757. */
  90758. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90759. /**
  90760. * Invert the geometry to move from a right handed system to a left handed one.
  90761. * @returns the current mesh
  90762. */
  90763. toLeftHanded(): Mesh;
  90764. /** @hidden */
  90765. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90766. /** @hidden */
  90767. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90768. /**
  90769. * Registers for this mesh a javascript function called just before the rendering process
  90770. * @param func defines the function to call before rendering this mesh
  90771. * @returns the current mesh
  90772. */
  90773. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90774. /**
  90775. * Disposes a previously registered javascript function called before the rendering
  90776. * @param func defines the function to remove
  90777. * @returns the current mesh
  90778. */
  90779. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90780. /**
  90781. * Registers for this mesh a javascript function called just after the rendering is complete
  90782. * @param func defines the function to call after rendering this mesh
  90783. * @returns the current mesh
  90784. */
  90785. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90786. /**
  90787. * Disposes a previously registered javascript function called after the rendering.
  90788. * @param func defines the function to remove
  90789. * @returns the current mesh
  90790. */
  90791. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90792. /** @hidden */
  90793. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  90794. /** @hidden */
  90795. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  90796. /** @hidden */
  90797. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  90798. /** @hidden */
  90799. _rebuild(): void;
  90800. /** @hidden */
  90801. _freeze(): void;
  90802. /** @hidden */
  90803. _unFreeze(): void;
  90804. /**
  90805. * 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
  90806. * @param subMesh defines the subMesh to render
  90807. * @param enableAlphaMode defines if alpha mode can be changed
  90808. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  90809. * @returns the current mesh
  90810. */
  90811. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  90812. private _onBeforeDraw;
  90813. /**
  90814. * Renormalize the mesh and patch it up if there are no weights
  90815. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  90816. * However in the case of zero weights then we set just a single influence to 1.
  90817. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  90818. */
  90819. cleanMatrixWeights(): void;
  90820. private normalizeSkinFourWeights;
  90821. private normalizeSkinWeightsAndExtra;
  90822. /**
  90823. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  90824. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  90825. * the user know there was an issue with importing the mesh
  90826. * @returns a validation object with skinned, valid and report string
  90827. */
  90828. validateSkinning(): {
  90829. skinned: boolean;
  90830. valid: boolean;
  90831. report: string;
  90832. };
  90833. /** @hidden */
  90834. _checkDelayState(): Mesh;
  90835. private _queueLoad;
  90836. /**
  90837. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90838. * A mesh is in the frustum if its bounding box intersects the frustum
  90839. * @param frustumPlanes defines the frustum to test
  90840. * @returns true if the mesh is in the frustum planes
  90841. */
  90842. isInFrustum(frustumPlanes: Plane[]): boolean;
  90843. /**
  90844. * Sets the mesh material by the material or multiMaterial `id` property
  90845. * @param id is a string identifying the material or the multiMaterial
  90846. * @returns the current mesh
  90847. */
  90848. setMaterialByID(id: string): Mesh;
  90849. /**
  90850. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  90851. * @returns an array of IAnimatable
  90852. */
  90853. getAnimatables(): IAnimatable[];
  90854. /**
  90855. * Modifies the mesh geometry according to the passed transformation matrix.
  90856. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  90857. * The mesh normals are modified using the same transformation.
  90858. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90859. * @param transform defines the transform matrix to use
  90860. * @see http://doc.babylonjs.com/resources/baking_transformations
  90861. * @returns the current mesh
  90862. */
  90863. bakeTransformIntoVertices(transform: Matrix): Mesh;
  90864. /**
  90865. * Modifies the mesh geometry according to its own current World Matrix.
  90866. * The mesh World Matrix is then reset.
  90867. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  90868. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90869. * @see http://doc.babylonjs.com/resources/baking_transformations
  90870. * @returns the current mesh
  90871. */
  90872. bakeCurrentTransformIntoVertices(): Mesh;
  90873. /** @hidden */
  90874. readonly _positions: Nullable<Vector3[]>;
  90875. /** @hidden */
  90876. _resetPointsArrayCache(): Mesh;
  90877. /** @hidden */
  90878. _generatePointsArray(): boolean;
  90879. /**
  90880. * Returns a new Mesh object generated from the current mesh properties.
  90881. * This method must not get confused with createInstance()
  90882. * @param name is a string, the name given to the new mesh
  90883. * @param newParent can be any Node object (default `null`)
  90884. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  90885. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  90886. * @returns a new mesh
  90887. */
  90888. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  90889. /**
  90890. * Releases resources associated with this mesh.
  90891. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90892. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90893. */
  90894. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90895. /**
  90896. * Modifies the mesh geometry according to a displacement map.
  90897. * 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.
  90898. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90899. * @param url is a string, the URL from the image file is to be downloaded.
  90900. * @param minHeight is the lower limit of the displacement.
  90901. * @param maxHeight is the upper limit of the displacement.
  90902. * @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.
  90903. * @param uvOffset is an optional vector2 used to offset UV.
  90904. * @param uvScale is an optional vector2 used to scale UV.
  90905. * @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.
  90906. * @returns the Mesh.
  90907. */
  90908. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90909. /**
  90910. * Modifies the mesh geometry according to a displacementMap buffer.
  90911. * 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.
  90912. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90913. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  90914. * @param heightMapWidth is the width of the buffer image.
  90915. * @param heightMapHeight is the height of the buffer image.
  90916. * @param minHeight is the lower limit of the displacement.
  90917. * @param maxHeight is the upper limit of the displacement.
  90918. * @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.
  90919. * @param uvOffset is an optional vector2 used to offset UV.
  90920. * @param uvScale is an optional vector2 used to scale UV.
  90921. * @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.
  90922. * @returns the Mesh.
  90923. */
  90924. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90925. /**
  90926. * Modify the mesh to get a flat shading rendering.
  90927. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  90928. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  90929. * @returns current mesh
  90930. */
  90931. convertToFlatShadedMesh(): Mesh;
  90932. /**
  90933. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  90934. * In other words, more vertices, no more indices and a single bigger VBO.
  90935. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  90936. * @returns current mesh
  90937. */
  90938. convertToUnIndexedMesh(): Mesh;
  90939. /**
  90940. * Inverses facet orientations.
  90941. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90942. * @param flipNormals will also inverts the normals
  90943. * @returns current mesh
  90944. */
  90945. flipFaces(flipNormals?: boolean): Mesh;
  90946. /**
  90947. * Increase the number of facets and hence vertices in a mesh
  90948. * Vertex normals are interpolated from existing vertex normals
  90949. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90950. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  90951. */
  90952. increaseVertices(numberPerEdge: number): void;
  90953. /**
  90954. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  90955. * This will undo any application of covertToFlatShadedMesh
  90956. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90957. */
  90958. forceSharedVertices(): void;
  90959. /** @hidden */
  90960. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  90961. /** @hidden */
  90962. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  90963. /**
  90964. * Creates a new InstancedMesh object from the mesh model.
  90965. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90966. * @param name defines the name of the new instance
  90967. * @returns a new InstancedMesh
  90968. */
  90969. createInstance(name: string): InstancedMesh;
  90970. /**
  90971. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  90972. * After this call, all the mesh instances have the same submeshes than the current mesh.
  90973. * @returns the current mesh
  90974. */
  90975. synchronizeInstances(): Mesh;
  90976. /**
  90977. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  90978. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  90979. * This should be used together with the simplification to avoid disappearing triangles.
  90980. * @param successCallback an optional success callback to be called after the optimization finished.
  90981. * @returns the current mesh
  90982. */
  90983. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  90984. /**
  90985. * Serialize current mesh
  90986. * @param serializationObject defines the object which will receive the serialization data
  90987. */
  90988. serialize(serializationObject: any): void;
  90989. /** @hidden */
  90990. _syncGeometryWithMorphTargetManager(): void;
  90991. /** @hidden */
  90992. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  90993. /**
  90994. * Returns a new Mesh object parsed from the source provided.
  90995. * @param parsedMesh is the source
  90996. * @param scene defines the hosting scene
  90997. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  90998. * @returns a new Mesh
  90999. */
  91000. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  91001. /**
  91002. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  91003. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91004. * @param name defines the name of the mesh to create
  91005. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  91006. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  91007. * @param closePath creates a seam between the first and the last points of each path of the path array
  91008. * @param offset is taken in account only if the `pathArray` is containing a single path
  91009. * @param scene defines the hosting scene
  91010. * @param updatable defines if the mesh must be flagged as updatable
  91011. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91012. * @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)
  91013. * @returns a new Mesh
  91014. */
  91015. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91016. /**
  91017. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  91018. * @param name defines the name of the mesh to create
  91019. * @param radius sets the radius size (float) of the polygon (default 0.5)
  91020. * @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
  91021. * @param scene defines the hosting scene
  91022. * @param updatable defines if the mesh must be flagged as updatable
  91023. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91024. * @returns a new Mesh
  91025. */
  91026. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91027. /**
  91028. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  91029. * @param name defines the name of the mesh to create
  91030. * @param size sets the size (float) of each box side (default 1)
  91031. * @param scene defines the hosting scene
  91032. * @param updatable defines if the mesh must be flagged as updatable
  91033. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91034. * @returns a new Mesh
  91035. */
  91036. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91037. /**
  91038. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  91039. * @param name defines the name of the mesh to create
  91040. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91041. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91042. * @param scene defines the hosting scene
  91043. * @param updatable defines if the mesh must be flagged as updatable
  91044. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91045. * @returns a new Mesh
  91046. */
  91047. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91048. /**
  91049. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  91050. * @param name defines the name of the mesh to create
  91051. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91052. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91053. * @param scene defines the hosting scene
  91054. * @returns a new Mesh
  91055. */
  91056. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91057. /**
  91058. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91059. * @param name defines the name of the mesh to create
  91060. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91061. * @param diameterTop set the top cap diameter (floats, default 1)
  91062. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91063. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91064. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91065. * @param scene defines the hosting scene
  91066. * @param updatable defines if the mesh must be flagged as updatable
  91067. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91068. * @returns a new Mesh
  91069. */
  91070. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91071. /**
  91072. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91073. * @param name defines the name of the mesh to create
  91074. * @param diameter sets the diameter size (float) of the torus (default 1)
  91075. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91076. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91077. * @param scene defines the hosting scene
  91078. * @param updatable defines if the mesh must be flagged as updatable
  91079. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91080. * @returns a new Mesh
  91081. */
  91082. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91083. /**
  91084. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91085. * @param name defines the name of the mesh to create
  91086. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91087. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91088. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91089. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91090. * @param p the number of windings on X axis (positive integers, default 2)
  91091. * @param q the number of windings on Y axis (positive integers, default 3)
  91092. * @param scene defines the hosting scene
  91093. * @param updatable defines if the mesh must be flagged as updatable
  91094. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91095. * @returns a new Mesh
  91096. */
  91097. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91098. /**
  91099. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  91100. * @param name defines the name of the mesh to create
  91101. * @param points is an array successive Vector3
  91102. * @param scene defines the hosting scene
  91103. * @param updatable defines if the mesh must be flagged as updatable
  91104. * @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).
  91105. * @returns a new Mesh
  91106. */
  91107. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91108. /**
  91109. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  91110. * @param name defines the name of the mesh to create
  91111. * @param points is an array successive Vector3
  91112. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91113. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91114. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91115. * @param scene defines the hosting scene
  91116. * @param updatable defines if the mesh must be flagged as updatable
  91117. * @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)
  91118. * @returns a new Mesh
  91119. */
  91120. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91121. /**
  91122. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91123. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91124. * 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.
  91125. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91126. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91127. * Remember you can only change the shape positions, not their number when updating a polygon.
  91128. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91129. * @param name defines the name of the mesh to create
  91130. * @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
  91131. * @param scene defines the hosting scene
  91132. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91133. * @param updatable defines if the mesh must be flagged as updatable
  91134. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91135. * @param earcutInjection can be used to inject your own earcut reference
  91136. * @returns a new Mesh
  91137. */
  91138. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91139. /**
  91140. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91141. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91142. * @param name defines the name of the mesh to create
  91143. * @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
  91144. * @param depth defines the height of extrusion
  91145. * @param scene defines the hosting scene
  91146. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91147. * @param updatable defines if the mesh must be flagged as updatable
  91148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91149. * @param earcutInjection can be used to inject your own earcut reference
  91150. * @returns a new Mesh
  91151. */
  91152. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91153. /**
  91154. * Creates an extruded shape mesh.
  91155. * 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
  91156. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91157. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91158. * @param name defines the name of the mesh to create
  91159. * @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
  91160. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91161. * @param scale is the value to scale the shape
  91162. * @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
  91163. * @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
  91164. * @param scene defines the hosting scene
  91165. * @param updatable defines if the mesh must be flagged as updatable
  91166. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91167. * @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)
  91168. * @returns a new Mesh
  91169. */
  91170. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91171. /**
  91172. * Creates an custom extruded shape mesh.
  91173. * The custom extrusion is a parametric shape.
  91174. * It has no predefined shape. Its final shape will depend on the input parameters.
  91175. * Please consider using the same method from the MeshBuilder class instead
  91176. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91177. * @param name defines the name of the mesh to create
  91178. * @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
  91179. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91180. * @param scaleFunction is a custom Javascript function called on each path point
  91181. * @param rotationFunction is a custom Javascript function called on each path point
  91182. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91183. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91184. * @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
  91185. * @param scene defines the hosting scene
  91186. * @param updatable defines if the mesh must be flagged as updatable
  91187. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91188. * @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)
  91189. * @returns a new Mesh
  91190. */
  91191. 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;
  91192. /**
  91193. * Creates lathe mesh.
  91194. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91195. * Please consider using the same method from the MeshBuilder class instead
  91196. * @param name defines the name of the mesh to create
  91197. * @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
  91198. * @param radius is the radius value of the lathe
  91199. * @param tessellation is the side number of the lathe.
  91200. * @param scene defines the hosting scene
  91201. * @param updatable defines if the mesh must be flagged as updatable
  91202. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91203. * @returns a new Mesh
  91204. */
  91205. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91206. /**
  91207. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91208. * @param name defines the name of the mesh to create
  91209. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91210. * @param scene defines the hosting scene
  91211. * @param updatable defines if the mesh must be flagged as updatable
  91212. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91213. * @returns a new Mesh
  91214. */
  91215. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91216. /**
  91217. * Creates a ground mesh.
  91218. * Please consider using the same method from the MeshBuilder class instead
  91219. * @param name defines the name of the mesh to create
  91220. * @param width set the width of the ground
  91221. * @param height set the height of the ground
  91222. * @param subdivisions sets the number of subdivisions per side
  91223. * @param scene defines the hosting scene
  91224. * @param updatable defines if the mesh must be flagged as updatable
  91225. * @returns a new Mesh
  91226. */
  91227. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91228. /**
  91229. * Creates a tiled ground mesh.
  91230. * Please consider using the same method from the MeshBuilder class instead
  91231. * @param name defines the name of the mesh to create
  91232. * @param xmin set the ground minimum X coordinate
  91233. * @param zmin set the ground minimum Y coordinate
  91234. * @param xmax set the ground maximum X coordinate
  91235. * @param zmax set the ground maximum Z coordinate
  91236. * @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
  91237. * @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
  91238. * @param scene defines the hosting scene
  91239. * @param updatable defines if the mesh must be flagged as updatable
  91240. * @returns a new Mesh
  91241. */
  91242. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91243. w: number;
  91244. h: number;
  91245. }, precision: {
  91246. w: number;
  91247. h: number;
  91248. }, scene: Scene, updatable?: boolean): Mesh;
  91249. /**
  91250. * Creates a ground mesh from a height map.
  91251. * Please consider using the same method from the MeshBuilder class instead
  91252. * @see http://doc.babylonjs.com/babylon101/height_map
  91253. * @param name defines the name of the mesh to create
  91254. * @param url sets the URL of the height map image resource
  91255. * @param width set the ground width size
  91256. * @param height set the ground height size
  91257. * @param subdivisions sets the number of subdivision per side
  91258. * @param minHeight is the minimum altitude on the ground
  91259. * @param maxHeight is the maximum altitude on the ground
  91260. * @param scene defines the hosting scene
  91261. * @param updatable defines if the mesh must be flagged as updatable
  91262. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  91263. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91264. * @returns a new Mesh
  91265. */
  91266. 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;
  91267. /**
  91268. * Creates a tube mesh.
  91269. * The tube is a parametric shape.
  91270. * It has no predefined shape. Its final shape will depend on the input parameters.
  91271. * Please consider using the same method from the MeshBuilder class instead
  91272. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91273. * @param name defines the name of the mesh to create
  91274. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  91275. * @param radius sets the tube radius size
  91276. * @param tessellation is the number of sides on the tubular surface
  91277. * @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
  91278. * @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
  91279. * @param scene defines the hosting scene
  91280. * @param updatable defines if the mesh must be flagged as updatable
  91281. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91282. * @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)
  91283. * @returns a new Mesh
  91284. */
  91285. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  91286. (i: number, distance: number): number;
  91287. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91288. /**
  91289. * Creates a polyhedron mesh.
  91290. * Please consider using the same method from the MeshBuilder class instead.
  91291. * * 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
  91292. * * The parameter `size` (positive float, default 1) sets the polygon size
  91293. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  91294. * * 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`
  91295. * * 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
  91296. * * 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)`)
  91297. * * 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
  91298. * * 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
  91299. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91300. * * 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
  91301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91302. * @param name defines the name of the mesh to create
  91303. * @param options defines the options used to create the mesh
  91304. * @param scene defines the hosting scene
  91305. * @returns a new Mesh
  91306. */
  91307. static CreatePolyhedron(name: string, options: {
  91308. type?: number;
  91309. size?: number;
  91310. sizeX?: number;
  91311. sizeY?: number;
  91312. sizeZ?: number;
  91313. custom?: any;
  91314. faceUV?: Vector4[];
  91315. faceColors?: Color4[];
  91316. updatable?: boolean;
  91317. sideOrientation?: number;
  91318. }, scene: Scene): Mesh;
  91319. /**
  91320. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91321. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91322. * * 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`)
  91323. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91324. * * 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
  91325. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91326. * * 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
  91327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91328. * @param name defines the name of the mesh
  91329. * @param options defines the options used to create the mesh
  91330. * @param scene defines the hosting scene
  91331. * @returns a new Mesh
  91332. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91333. */
  91334. static CreateIcoSphere(name: string, options: {
  91335. radius?: number;
  91336. flat?: boolean;
  91337. subdivisions?: number;
  91338. sideOrientation?: number;
  91339. updatable?: boolean;
  91340. }, scene: Scene): Mesh;
  91341. /**
  91342. * Creates a decal mesh.
  91343. * Please consider using the same method from the MeshBuilder class instead.
  91344. * A decal is a mesh usually applied as a model onto the surface of another mesh
  91345. * @param name defines the name of the mesh
  91346. * @param sourceMesh defines the mesh receiving the decal
  91347. * @param position sets the position of the decal in world coordinates
  91348. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  91349. * @param size sets the decal scaling
  91350. * @param angle sets the angle to rotate the decal
  91351. * @returns a new Mesh
  91352. */
  91353. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  91354. /**
  91355. * Prepare internal position array for software CPU skinning
  91356. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  91357. */
  91358. setPositionsForCPUSkinning(): Float32Array;
  91359. /**
  91360. * Prepare internal normal array for software CPU skinning
  91361. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  91362. */
  91363. setNormalsForCPUSkinning(): Float32Array;
  91364. /**
  91365. * Updates the vertex buffer by applying transformation from the bones
  91366. * @param skeleton defines the skeleton to apply to current mesh
  91367. * @returns the current mesh
  91368. */
  91369. applySkeleton(skeleton: Skeleton): Mesh;
  91370. /**
  91371. * 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
  91372. * @param meshes defines the list of meshes to scan
  91373. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  91374. */
  91375. static MinMax(meshes: AbstractMesh[]): {
  91376. min: Vector3;
  91377. max: Vector3;
  91378. };
  91379. /**
  91380. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  91381. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  91382. * @returns a vector3
  91383. */
  91384. static Center(meshesOrMinMaxVector: {
  91385. min: Vector3;
  91386. max: Vector3;
  91387. } | AbstractMesh[]): Vector3;
  91388. /**
  91389. * Merge the array of meshes into a single mesh for performance reasons.
  91390. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  91391. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  91392. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  91393. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  91394. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  91395. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  91396. * @returns a new mesh
  91397. */
  91398. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  91399. /** @hidden */
  91400. addInstance(instance: InstancedMesh): void;
  91401. /** @hidden */
  91402. removeInstance(instance: InstancedMesh): void;
  91403. }
  91404. }
  91405. declare module BABYLON {
  91406. /**
  91407. * This is the base class of all the camera used in the application.
  91408. * @see http://doc.babylonjs.com/features/cameras
  91409. */
  91410. export class Camera extends Node {
  91411. /** @hidden */
  91412. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  91413. /**
  91414. * This is the default projection mode used by the cameras.
  91415. * It helps recreating a feeling of perspective and better appreciate depth.
  91416. * This is the best way to simulate real life cameras.
  91417. */
  91418. static readonly PERSPECTIVE_CAMERA: number;
  91419. /**
  91420. * This helps creating camera with an orthographic mode.
  91421. * 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.
  91422. */
  91423. static readonly ORTHOGRAPHIC_CAMERA: number;
  91424. /**
  91425. * This is the default FOV mode for perspective cameras.
  91426. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  91427. */
  91428. static readonly FOVMODE_VERTICAL_FIXED: number;
  91429. /**
  91430. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  91431. */
  91432. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  91433. /**
  91434. * This specifies ther is no need for a camera rig.
  91435. * Basically only one eye is rendered corresponding to the camera.
  91436. */
  91437. static readonly RIG_MODE_NONE: number;
  91438. /**
  91439. * Simulates a camera Rig with one blue eye and one red eye.
  91440. * This can be use with 3d blue and red glasses.
  91441. */
  91442. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  91443. /**
  91444. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  91445. */
  91446. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  91447. /**
  91448. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  91449. */
  91450. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  91451. /**
  91452. * Defines that both eyes of the camera will be rendered over under each other.
  91453. */
  91454. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  91455. /**
  91456. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  91457. */
  91458. static readonly RIG_MODE_VR: number;
  91459. /**
  91460. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  91461. */
  91462. static readonly RIG_MODE_WEBVR: number;
  91463. /**
  91464. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  91465. */
  91466. static readonly RIG_MODE_CUSTOM: number;
  91467. /**
  91468. * Defines if by default attaching controls should prevent the default javascript event to continue.
  91469. */
  91470. static ForceAttachControlToAlwaysPreventDefault: boolean;
  91471. /**
  91472. * Define the input manager associated with the camera.
  91473. */
  91474. inputs: CameraInputsManager<Camera>;
  91475. /** @hidden */
  91476. _position: Vector3;
  91477. /**
  91478. * Define the current local position of the camera in the scene
  91479. */
  91480. position: Vector3;
  91481. /**
  91482. * The vector the camera should consider as up.
  91483. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  91484. */
  91485. upVector: Vector3;
  91486. /**
  91487. * Define the current limit on the left side for an orthographic camera
  91488. * In scene unit
  91489. */
  91490. orthoLeft: Nullable<number>;
  91491. /**
  91492. * Define the current limit on the right side for an orthographic camera
  91493. * In scene unit
  91494. */
  91495. orthoRight: Nullable<number>;
  91496. /**
  91497. * Define the current limit on the bottom side for an orthographic camera
  91498. * In scene unit
  91499. */
  91500. orthoBottom: Nullable<number>;
  91501. /**
  91502. * Define the current limit on the top side for an orthographic camera
  91503. * In scene unit
  91504. */
  91505. orthoTop: Nullable<number>;
  91506. /**
  91507. * Field Of View is set in Radians. (default is 0.8)
  91508. */
  91509. fov: number;
  91510. /**
  91511. * Define the minimum distance the camera can see from.
  91512. * This is important to note that the depth buffer are not infinite and the closer it starts
  91513. * the more your scene might encounter depth fighting issue.
  91514. */
  91515. minZ: number;
  91516. /**
  91517. * Define the maximum distance the camera can see to.
  91518. * This is important to note that the depth buffer are not infinite and the further it end
  91519. * the more your scene might encounter depth fighting issue.
  91520. */
  91521. maxZ: number;
  91522. /**
  91523. * Define the default inertia of the camera.
  91524. * This helps giving a smooth feeling to the camera movement.
  91525. */
  91526. inertia: number;
  91527. /**
  91528. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  91529. */
  91530. mode: number;
  91531. /**
  91532. * Define wether the camera is intermediate.
  91533. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  91534. */
  91535. isIntermediate: boolean;
  91536. /**
  91537. * Define the viewport of the camera.
  91538. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  91539. */
  91540. viewport: Viewport;
  91541. /**
  91542. * Restricts the camera to viewing objects with the same layerMask.
  91543. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  91544. */
  91545. layerMask: number;
  91546. /**
  91547. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  91548. */
  91549. fovMode: number;
  91550. /**
  91551. * Rig mode of the camera.
  91552. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  91553. * This is normally controlled byt the camera themselves as internal use.
  91554. */
  91555. cameraRigMode: number;
  91556. /**
  91557. * Defines the distance between both "eyes" in case of a RIG
  91558. */
  91559. interaxialDistance: number;
  91560. /**
  91561. * Defines if stereoscopic rendering is done side by side or over under.
  91562. */
  91563. isStereoscopicSideBySide: boolean;
  91564. /**
  91565. * 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
  91566. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  91567. * else in the scene. (Eg. security camera)
  91568. *
  91569. * 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)
  91570. */
  91571. customRenderTargets: RenderTargetTexture[];
  91572. /**
  91573. * When set, the camera will render to this render target instead of the default canvas
  91574. *
  91575. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  91576. */
  91577. outputRenderTarget: Nullable<RenderTargetTexture>;
  91578. /**
  91579. * Observable triggered when the camera view matrix has changed.
  91580. */
  91581. onViewMatrixChangedObservable: Observable<Camera>;
  91582. /**
  91583. * Observable triggered when the camera Projection matrix has changed.
  91584. */
  91585. onProjectionMatrixChangedObservable: Observable<Camera>;
  91586. /**
  91587. * Observable triggered when the inputs have been processed.
  91588. */
  91589. onAfterCheckInputsObservable: Observable<Camera>;
  91590. /**
  91591. * Observable triggered when reset has been called and applied to the camera.
  91592. */
  91593. onRestoreStateObservable: Observable<Camera>;
  91594. /** @hidden */
  91595. _cameraRigParams: any;
  91596. /** @hidden */
  91597. _rigCameras: Camera[];
  91598. /** @hidden */
  91599. _rigPostProcess: Nullable<PostProcess>;
  91600. protected _webvrViewMatrix: Matrix;
  91601. /** @hidden */
  91602. _skipRendering: boolean;
  91603. /** @hidden */
  91604. _projectionMatrix: Matrix;
  91605. /** @hidden */
  91606. _postProcesses: Nullable<PostProcess>[];
  91607. /** @hidden */
  91608. _activeMeshes: SmartArray<AbstractMesh>;
  91609. protected _globalPosition: Vector3;
  91610. /** @hidden */
  91611. _computedViewMatrix: Matrix;
  91612. private _doNotComputeProjectionMatrix;
  91613. private _transformMatrix;
  91614. private _frustumPlanes;
  91615. private _refreshFrustumPlanes;
  91616. private _storedFov;
  91617. private _stateStored;
  91618. /**
  91619. * Instantiates a new camera object.
  91620. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  91621. * @see http://doc.babylonjs.com/features/cameras
  91622. * @param name Defines the name of the camera in the scene
  91623. * @param position Defines the position of the camera
  91624. * @param scene Defines the scene the camera belongs too
  91625. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  91626. */
  91627. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91628. /**
  91629. * Store current camera state (fov, position, etc..)
  91630. * @returns the camera
  91631. */
  91632. storeState(): Camera;
  91633. /**
  91634. * Restores the camera state values if it has been stored. You must call storeState() first
  91635. */
  91636. protected _restoreStateValues(): boolean;
  91637. /**
  91638. * Restored camera state. You must call storeState() first.
  91639. * @returns true if restored and false otherwise
  91640. */
  91641. restoreState(): boolean;
  91642. /**
  91643. * Gets the class name of the camera.
  91644. * @returns the class name
  91645. */
  91646. getClassName(): string;
  91647. /** @hidden */
  91648. readonly _isCamera: boolean;
  91649. /**
  91650. * Gets a string representation of the camera useful for debug purpose.
  91651. * @param fullDetails Defines that a more verboe level of logging is required
  91652. * @returns the string representation
  91653. */
  91654. toString(fullDetails?: boolean): string;
  91655. /**
  91656. * Gets the current world space position of the camera.
  91657. */
  91658. readonly globalPosition: Vector3;
  91659. /**
  91660. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  91661. * @returns the active meshe list
  91662. */
  91663. getActiveMeshes(): SmartArray<AbstractMesh>;
  91664. /**
  91665. * Check wether a mesh is part of the current active mesh list of the camera
  91666. * @param mesh Defines the mesh to check
  91667. * @returns true if active, false otherwise
  91668. */
  91669. isActiveMesh(mesh: Mesh): boolean;
  91670. /**
  91671. * Is this camera ready to be used/rendered
  91672. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  91673. * @return true if the camera is ready
  91674. */
  91675. isReady(completeCheck?: boolean): boolean;
  91676. /** @hidden */
  91677. _initCache(): void;
  91678. /** @hidden */
  91679. _updateCache(ignoreParentClass?: boolean): void;
  91680. /** @hidden */
  91681. _isSynchronized(): boolean;
  91682. /** @hidden */
  91683. _isSynchronizedViewMatrix(): boolean;
  91684. /** @hidden */
  91685. _isSynchronizedProjectionMatrix(): boolean;
  91686. /**
  91687. * Attach the input controls to a specific dom element to get the input from.
  91688. * @param element Defines the element the controls should be listened from
  91689. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91690. */
  91691. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91692. /**
  91693. * Detach the current controls from the specified dom element.
  91694. * @param element Defines the element to stop listening the inputs from
  91695. */
  91696. detachControl(element: HTMLElement): void;
  91697. /**
  91698. * Update the camera state according to the different inputs gathered during the frame.
  91699. */
  91700. update(): void;
  91701. /** @hidden */
  91702. _checkInputs(): void;
  91703. /** @hidden */
  91704. readonly rigCameras: Camera[];
  91705. /**
  91706. * Gets the post process used by the rig cameras
  91707. */
  91708. readonly rigPostProcess: Nullable<PostProcess>;
  91709. /**
  91710. * Internal, gets the first post proces.
  91711. * @returns the first post process to be run on this camera.
  91712. */
  91713. _getFirstPostProcess(): Nullable<PostProcess>;
  91714. private _cascadePostProcessesToRigCams;
  91715. /**
  91716. * Attach a post process to the camera.
  91717. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91718. * @param postProcess The post process to attach to the camera
  91719. * @param insertAt The position of the post process in case several of them are in use in the scene
  91720. * @returns the position the post process has been inserted at
  91721. */
  91722. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  91723. /**
  91724. * Detach a post process to the camera.
  91725. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91726. * @param postProcess The post process to detach from the camera
  91727. */
  91728. detachPostProcess(postProcess: PostProcess): void;
  91729. /**
  91730. * Gets the current world matrix of the camera
  91731. */
  91732. getWorldMatrix(): Matrix;
  91733. /** @hidden */
  91734. _getViewMatrix(): Matrix;
  91735. /**
  91736. * Gets the current view matrix of the camera.
  91737. * @param force forces the camera to recompute the matrix without looking at the cached state
  91738. * @returns the view matrix
  91739. */
  91740. getViewMatrix(force?: boolean): Matrix;
  91741. /**
  91742. * Freeze the projection matrix.
  91743. * It will prevent the cache check of the camera projection compute and can speed up perf
  91744. * if no parameter of the camera are meant to change
  91745. * @param projection Defines manually a projection if necessary
  91746. */
  91747. freezeProjectionMatrix(projection?: Matrix): void;
  91748. /**
  91749. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  91750. */
  91751. unfreezeProjectionMatrix(): void;
  91752. /**
  91753. * Gets the current projection matrix of the camera.
  91754. * @param force forces the camera to recompute the matrix without looking at the cached state
  91755. * @returns the projection matrix
  91756. */
  91757. getProjectionMatrix(force?: boolean): Matrix;
  91758. /**
  91759. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  91760. * @returns a Matrix
  91761. */
  91762. getTransformationMatrix(): Matrix;
  91763. private _updateFrustumPlanes;
  91764. /**
  91765. * Checks if a cullable object (mesh...) is in the camera frustum
  91766. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  91767. * @param target The object to check
  91768. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  91769. * @returns true if the object is in frustum otherwise false
  91770. */
  91771. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  91772. /**
  91773. * Checks if a cullable object (mesh...) is in the camera frustum
  91774. * Unlike isInFrustum this cheks the full bounding box
  91775. * @param target The object to check
  91776. * @returns true if the object is in frustum otherwise false
  91777. */
  91778. isCompletelyInFrustum(target: ICullable): boolean;
  91779. /**
  91780. * Gets a ray in the forward direction from the camera.
  91781. * @param length Defines the length of the ray to create
  91782. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  91783. * @param origin Defines the start point of the ray which defaults to the camera position
  91784. * @returns the forward ray
  91785. */
  91786. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  91787. /**
  91788. * Releases resources associated with this node.
  91789. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91790. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91791. */
  91792. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91793. /** @hidden */
  91794. _isLeftCamera: boolean;
  91795. /**
  91796. * Gets the left camera of a rig setup in case of Rigged Camera
  91797. */
  91798. readonly isLeftCamera: boolean;
  91799. /** @hidden */
  91800. _isRightCamera: boolean;
  91801. /**
  91802. * Gets the right camera of a rig setup in case of Rigged Camera
  91803. */
  91804. readonly isRightCamera: boolean;
  91805. /**
  91806. * Gets the left camera of a rig setup in case of Rigged Camera
  91807. */
  91808. readonly leftCamera: Nullable<FreeCamera>;
  91809. /**
  91810. * Gets the right camera of a rig setup in case of Rigged Camera
  91811. */
  91812. readonly rightCamera: Nullable<FreeCamera>;
  91813. /**
  91814. * Gets the left camera target of a rig setup in case of Rigged Camera
  91815. * @returns the target position
  91816. */
  91817. getLeftTarget(): Nullable<Vector3>;
  91818. /**
  91819. * Gets the right camera target of a rig setup in case of Rigged Camera
  91820. * @returns the target position
  91821. */
  91822. getRightTarget(): Nullable<Vector3>;
  91823. /**
  91824. * @hidden
  91825. */
  91826. setCameraRigMode(mode: number, rigParams: any): void;
  91827. /** @hidden */
  91828. static _setStereoscopicRigMode(camera: Camera): void;
  91829. /** @hidden */
  91830. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  91831. /** @hidden */
  91832. static _setVRRigMode(camera: Camera, rigParams: any): void;
  91833. /** @hidden */
  91834. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  91835. /** @hidden */
  91836. _getVRProjectionMatrix(): Matrix;
  91837. protected _updateCameraRotationMatrix(): void;
  91838. protected _updateWebVRCameraRotationMatrix(): void;
  91839. /**
  91840. * This function MUST be overwritten by the different WebVR cameras available.
  91841. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91842. * @hidden
  91843. */
  91844. _getWebVRProjectionMatrix(): Matrix;
  91845. /**
  91846. * This function MUST be overwritten by the different WebVR cameras available.
  91847. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91848. * @hidden
  91849. */
  91850. _getWebVRViewMatrix(): Matrix;
  91851. /** @hidden */
  91852. setCameraRigParameter(name: string, value: any): void;
  91853. /**
  91854. * needs to be overridden by children so sub has required properties to be copied
  91855. * @hidden
  91856. */
  91857. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  91858. /**
  91859. * May need to be overridden by children
  91860. * @hidden
  91861. */
  91862. _updateRigCameras(): void;
  91863. /** @hidden */
  91864. _setupInputs(): void;
  91865. /**
  91866. * Serialiaze the camera setup to a json represention
  91867. * @returns the JSON representation
  91868. */
  91869. serialize(): any;
  91870. /**
  91871. * Clones the current camera.
  91872. * @param name The cloned camera name
  91873. * @returns the cloned camera
  91874. */
  91875. clone(name: string): Camera;
  91876. /**
  91877. * Gets the direction of the camera relative to a given local axis.
  91878. * @param localAxis Defines the reference axis to provide a relative direction.
  91879. * @return the direction
  91880. */
  91881. getDirection(localAxis: Vector3): Vector3;
  91882. /**
  91883. * Returns the current camera absolute rotation
  91884. */
  91885. readonly absoluteRotation: Quaternion;
  91886. /**
  91887. * Gets the direction of the camera relative to a given local axis into a passed vector.
  91888. * @param localAxis Defines the reference axis to provide a relative direction.
  91889. * @param result Defines the vector to store the result in
  91890. */
  91891. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  91892. /**
  91893. * Gets a camera constructor for a given camera type
  91894. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  91895. * @param name The name of the camera the result will be able to instantiate
  91896. * @param scene The scene the result will construct the camera in
  91897. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  91898. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  91899. * @returns a factory method to construc the camera
  91900. */
  91901. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  91902. /**
  91903. * Compute the world matrix of the camera.
  91904. * @returns the camera workd matrix
  91905. */
  91906. computeWorldMatrix(): Matrix;
  91907. /**
  91908. * Parse a JSON and creates the camera from the parsed information
  91909. * @param parsedCamera The JSON to parse
  91910. * @param scene The scene to instantiate the camera in
  91911. * @returns the newly constructed camera
  91912. */
  91913. static Parse(parsedCamera: any, scene: Scene): Camera;
  91914. }
  91915. }
  91916. declare module BABYLON {
  91917. /**
  91918. * Class containing static functions to help procedurally build meshes
  91919. */
  91920. export class DiscBuilder {
  91921. /**
  91922. * Creates a plane polygonal mesh. By default, this is a disc
  91923. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  91924. * * 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
  91925. * * 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
  91926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91927. * * 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
  91928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91929. * @param name defines the name of the mesh
  91930. * @param options defines the options used to create the mesh
  91931. * @param scene defines the hosting scene
  91932. * @returns the plane polygonal mesh
  91933. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  91934. */
  91935. static CreateDisc(name: string, options: {
  91936. radius?: number;
  91937. tessellation?: number;
  91938. arc?: number;
  91939. updatable?: boolean;
  91940. sideOrientation?: number;
  91941. frontUVs?: Vector4;
  91942. backUVs?: Vector4;
  91943. }, scene?: Nullable<Scene>): Mesh;
  91944. }
  91945. }
  91946. declare module BABYLON {
  91947. /**
  91948. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  91949. *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.
  91950. * The SPS is also a particle system. It provides some methods to manage the particles.
  91951. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  91952. *
  91953. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  91954. */
  91955. export class SolidParticleSystem implements IDisposable {
  91956. /**
  91957. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  91958. * Example : var p = SPS.particles[i];
  91959. */
  91960. particles: SolidParticle[];
  91961. /**
  91962. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  91963. */
  91964. nbParticles: number;
  91965. /**
  91966. * If the particles must ever face the camera (default false). Useful for planar particles.
  91967. */
  91968. billboard: boolean;
  91969. /**
  91970. * Recompute normals when adding a shape
  91971. */
  91972. recomputeNormals: boolean;
  91973. /**
  91974. * This a counter ofr your own usage. It's not set by any SPS functions.
  91975. */
  91976. counter: number;
  91977. /**
  91978. * The SPS name. This name is also given to the underlying mesh.
  91979. */
  91980. name: string;
  91981. /**
  91982. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  91983. */
  91984. mesh: Mesh;
  91985. /**
  91986. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  91987. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  91988. */
  91989. vars: any;
  91990. /**
  91991. * This array is populated when the SPS is set as 'pickable'.
  91992. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  91993. * Each element of this array is an object `{idx: int, faceId: int}`.
  91994. * `idx` is the picked particle index in the `SPS.particles` array
  91995. * `faceId` is the picked face index counted within this particle.
  91996. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  91997. */
  91998. pickedParticles: {
  91999. idx: number;
  92000. faceId: number;
  92001. }[];
  92002. /**
  92003. * This array is populated when `enableDepthSort` is set to true.
  92004. * Each element of this array is an instance of the class DepthSortedParticle.
  92005. */
  92006. depthSortedParticles: DepthSortedParticle[];
  92007. /**
  92008. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  92009. * @hidden
  92010. */
  92011. _bSphereOnly: boolean;
  92012. /**
  92013. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  92014. * @hidden
  92015. */
  92016. _bSphereRadiusFactor: number;
  92017. private _scene;
  92018. private _positions;
  92019. private _indices;
  92020. private _normals;
  92021. private _colors;
  92022. private _uvs;
  92023. private _indices32;
  92024. private _positions32;
  92025. private _normals32;
  92026. private _fixedNormal32;
  92027. private _colors32;
  92028. private _uvs32;
  92029. private _index;
  92030. private _updatable;
  92031. private _pickable;
  92032. private _isVisibilityBoxLocked;
  92033. private _alwaysVisible;
  92034. private _depthSort;
  92035. private _expandable;
  92036. private _shapeCounter;
  92037. private _copy;
  92038. private _color;
  92039. private _computeParticleColor;
  92040. private _computeParticleTexture;
  92041. private _computeParticleRotation;
  92042. private _computeParticleVertex;
  92043. private _computeBoundingBox;
  92044. private _depthSortParticles;
  92045. private _camera;
  92046. private _mustUnrotateFixedNormals;
  92047. private _particlesIntersect;
  92048. private _needs32Bits;
  92049. /**
  92050. * Creates a SPS (Solid Particle System) object.
  92051. * @param name (String) is the SPS name, this will be the underlying mesh name.
  92052. * @param scene (Scene) is the scene in which the SPS is added.
  92053. * @param options defines the options of the sps e.g.
  92054. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92055. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92056. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92057. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  92058. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92059. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92060. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92061. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92062. */
  92063. constructor(name: string, scene: Scene, options?: {
  92064. updatable?: boolean;
  92065. isPickable?: boolean;
  92066. enableDepthSort?: boolean;
  92067. particleIntersection?: boolean;
  92068. boundingSphereOnly?: boolean;
  92069. bSphereRadiusFactor?: number;
  92070. expandable?: boolean;
  92071. });
  92072. /**
  92073. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92074. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92075. * @returns the created mesh
  92076. */
  92077. buildMesh(): Mesh;
  92078. /**
  92079. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92080. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92081. * Thus the particles generated from `digest()` have their property `position` set yet.
  92082. * @param mesh ( Mesh ) is the mesh to be digested
  92083. * @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
  92084. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92085. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92086. * @returns the current SPS
  92087. */
  92088. digest(mesh: Mesh, options?: {
  92089. facetNb?: number;
  92090. number?: number;
  92091. delta?: number;
  92092. }): SolidParticleSystem;
  92093. private _unrotateFixedNormals;
  92094. private _resetCopy;
  92095. private _meshBuilder;
  92096. private _posToShape;
  92097. private _uvsToShapeUV;
  92098. private _addParticle;
  92099. /**
  92100. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92101. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92102. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92103. * @param nb (positive integer) the number of particles to be created from this model
  92104. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92105. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92106. * @returns the number of shapes in the system
  92107. */
  92108. addShape(mesh: Mesh, nb: number, options?: {
  92109. positionFunction?: any;
  92110. vertexFunction?: any;
  92111. }): number;
  92112. private _rebuildParticle;
  92113. /**
  92114. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92115. * @returns the SPS.
  92116. */
  92117. rebuildMesh(): SolidParticleSystem;
  92118. /**
  92119. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92120. * This method calls `updateParticle()` for each particle of the SPS.
  92121. * For an animated SPS, it is usually called within the render loop.
  92122. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92123. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92124. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92125. * @returns the SPS.
  92126. */
  92127. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92128. /**
  92129. * Disposes the SPS.
  92130. */
  92131. dispose(): void;
  92132. /**
  92133. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92134. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92135. * @returns the SPS.
  92136. */
  92137. refreshVisibleSize(): SolidParticleSystem;
  92138. /**
  92139. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92140. * @param size the size (float) of the visibility box
  92141. * note : this doesn't lock the SPS mesh bounding box.
  92142. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92143. */
  92144. setVisibilityBox(size: number): void;
  92145. /**
  92146. * Gets whether the SPS as always visible or not
  92147. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92148. */
  92149. /**
  92150. * Sets the SPS as always visible or not
  92151. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92152. */
  92153. isAlwaysVisible: boolean;
  92154. /**
  92155. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92156. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92157. */
  92158. /**
  92159. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92160. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92161. */
  92162. isVisibilityBoxLocked: boolean;
  92163. /**
  92164. * Tells to `setParticles()` to compute the particle rotations or not.
  92165. * Default value : true. The SPS is faster when it's set to false.
  92166. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92167. */
  92168. /**
  92169. * Gets if `setParticles()` computes the particle rotations or not.
  92170. * Default value : true. The SPS is faster when it's set to false.
  92171. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92172. */
  92173. computeParticleRotation: boolean;
  92174. /**
  92175. * Tells to `setParticles()` to compute the particle colors or not.
  92176. * Default value : true. The SPS is faster when it's set to false.
  92177. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92178. */
  92179. /**
  92180. * Gets if `setParticles()` computes the particle colors or not.
  92181. * Default value : true. The SPS is faster when it's set to false.
  92182. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92183. */
  92184. computeParticleColor: boolean;
  92185. /**
  92186. * Gets if `setParticles()` computes the particle textures or not.
  92187. * Default value : true. The SPS is faster when it's set to false.
  92188. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92189. */
  92190. computeParticleTexture: boolean;
  92191. /**
  92192. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92193. * Default value : false. The SPS is faster when it's set to false.
  92194. * Note : the particle custom vertex positions aren't stored values.
  92195. */
  92196. /**
  92197. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  92198. * Default value : false. The SPS is faster when it's set to false.
  92199. * Note : the particle custom vertex positions aren't stored values.
  92200. */
  92201. computeParticleVertex: boolean;
  92202. /**
  92203. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92204. */
  92205. /**
  92206. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92207. */
  92208. computeBoundingBox: boolean;
  92209. /**
  92210. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92211. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92212. * Default : `true`
  92213. */
  92214. /**
  92215. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  92216. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92217. * Default : `true`
  92218. */
  92219. depthSortParticles: boolean;
  92220. /**
  92221. * Gets if the SPS is created as expandable at construction time.
  92222. * Default : `false`
  92223. */
  92224. readonly expandable: boolean;
  92225. /**
  92226. * This function does nothing. It may be overwritten to set all the particle first values.
  92227. * The SPS doesn't call this function, you may have to call it by your own.
  92228. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92229. */
  92230. initParticles(): void;
  92231. /**
  92232. * This function does nothing. It may be overwritten to recycle a particle.
  92233. * The SPS doesn't call this function, you may have to call it by your own.
  92234. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92235. * @param particle The particle to recycle
  92236. * @returns the recycled particle
  92237. */
  92238. recycleParticle(particle: SolidParticle): SolidParticle;
  92239. /**
  92240. * Updates a particle : this function should be overwritten by the user.
  92241. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92242. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92243. * @example : just set a particle position or velocity and recycle conditions
  92244. * @param particle The particle to update
  92245. * @returns the updated particle
  92246. */
  92247. updateParticle(particle: SolidParticle): SolidParticle;
  92248. /**
  92249. * Updates a vertex of a particle : it can be overwritten by the user.
  92250. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  92251. * @param particle the current particle
  92252. * @param vertex the current index of the current particle
  92253. * @param pt the index of the current vertex in the particle shape
  92254. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  92255. * @example : just set a vertex particle position
  92256. * @returns the updated vertex
  92257. */
  92258. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  92259. /**
  92260. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  92261. * This does nothing and may be overwritten by the user.
  92262. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92263. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92264. * @param update the boolean update value actually passed to setParticles()
  92265. */
  92266. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92267. /**
  92268. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  92269. * This will be passed three parameters.
  92270. * This does nothing and may be overwritten by the user.
  92271. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92272. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92273. * @param update the boolean update value actually passed to setParticles()
  92274. */
  92275. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92276. }
  92277. }
  92278. declare module BABYLON {
  92279. /**
  92280. * Represents one particle of a solid particle system.
  92281. */
  92282. export class SolidParticle {
  92283. /**
  92284. * particle global index
  92285. */
  92286. idx: number;
  92287. /**
  92288. * The color of the particle
  92289. */
  92290. color: Nullable<Color4>;
  92291. /**
  92292. * The world space position of the particle.
  92293. */
  92294. position: Vector3;
  92295. /**
  92296. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  92297. */
  92298. rotation: Vector3;
  92299. /**
  92300. * The world space rotation quaternion of the particle.
  92301. */
  92302. rotationQuaternion: Nullable<Quaternion>;
  92303. /**
  92304. * The scaling of the particle.
  92305. */
  92306. scaling: Vector3;
  92307. /**
  92308. * The uvs of the particle.
  92309. */
  92310. uvs: Vector4;
  92311. /**
  92312. * The current speed of the particle.
  92313. */
  92314. velocity: Vector3;
  92315. /**
  92316. * The pivot point in the particle local space.
  92317. */
  92318. pivot: Vector3;
  92319. /**
  92320. * Must the particle be translated from its pivot point in its local space ?
  92321. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  92322. * Default : false
  92323. */
  92324. translateFromPivot: boolean;
  92325. /**
  92326. * Is the particle active or not ?
  92327. */
  92328. alive: boolean;
  92329. /**
  92330. * Is the particle visible or not ?
  92331. */
  92332. isVisible: boolean;
  92333. /**
  92334. * Index of this particle in the global "positions" array (Internal use)
  92335. * @hidden
  92336. */
  92337. _pos: number;
  92338. /**
  92339. * @hidden Index of this particle in the global "indices" array (Internal use)
  92340. */
  92341. _ind: number;
  92342. /**
  92343. * @hidden ModelShape of this particle (Internal use)
  92344. */
  92345. _model: ModelShape;
  92346. /**
  92347. * ModelShape id of this particle
  92348. */
  92349. shapeId: number;
  92350. /**
  92351. * Index of the particle in its shape id
  92352. */
  92353. idxInShape: number;
  92354. /**
  92355. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  92356. */
  92357. _modelBoundingInfo: BoundingInfo;
  92358. /**
  92359. * @hidden Particle BoundingInfo object (Internal use)
  92360. */
  92361. _boundingInfo: BoundingInfo;
  92362. /**
  92363. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  92364. */
  92365. _sps: SolidParticleSystem;
  92366. /**
  92367. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  92368. */
  92369. _stillInvisible: boolean;
  92370. /**
  92371. * @hidden Last computed particle rotation matrix
  92372. */
  92373. _rotationMatrix: number[];
  92374. /**
  92375. * Parent particle Id, if any.
  92376. * Default null.
  92377. */
  92378. parentId: Nullable<number>;
  92379. /**
  92380. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  92381. * The possible values are :
  92382. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92383. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92384. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92385. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92386. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92387. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  92388. * */
  92389. cullingStrategy: number;
  92390. /**
  92391. * @hidden Internal global position in the SPS.
  92392. */
  92393. _globalPosition: Vector3;
  92394. /**
  92395. * Creates a Solid Particle object.
  92396. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  92397. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  92398. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  92399. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  92400. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  92401. * @param shapeId (integer) is the model shape identifier in the SPS.
  92402. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  92403. * @param sps defines the sps it is associated to
  92404. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  92405. */
  92406. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  92407. /**
  92408. * Legacy support, changed scale to scaling
  92409. */
  92410. /**
  92411. * Legacy support, changed scale to scaling
  92412. */
  92413. scale: Vector3;
  92414. /**
  92415. * Legacy support, changed quaternion to rotationQuaternion
  92416. */
  92417. /**
  92418. * Legacy support, changed quaternion to rotationQuaternion
  92419. */
  92420. quaternion: Nullable<Quaternion>;
  92421. /**
  92422. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  92423. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  92424. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  92425. * @returns true if it intersects
  92426. */
  92427. intersectsMesh(target: Mesh | SolidParticle): boolean;
  92428. /**
  92429. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  92430. * A particle is in the frustum if its bounding box intersects the frustum
  92431. * @param frustumPlanes defines the frustum to test
  92432. * @returns true if the particle is in the frustum planes
  92433. */
  92434. isInFrustum(frustumPlanes: Plane[]): boolean;
  92435. /**
  92436. * get the rotation matrix of the particle
  92437. * @hidden
  92438. */
  92439. getRotationMatrix(m: Matrix): void;
  92440. }
  92441. /**
  92442. * Represents the shape of the model used by one particle of a solid particle system.
  92443. * SPS internal tool, don't use it manually.
  92444. */
  92445. export class ModelShape {
  92446. /**
  92447. * The shape id
  92448. * @hidden
  92449. */
  92450. shapeID: number;
  92451. /**
  92452. * flat array of model positions (internal use)
  92453. * @hidden
  92454. */
  92455. _shape: Vector3[];
  92456. /**
  92457. * flat array of model UVs (internal use)
  92458. * @hidden
  92459. */
  92460. _shapeUV: number[];
  92461. /**
  92462. * length of the shape in the model indices array (internal use)
  92463. * @hidden
  92464. */
  92465. _indicesLength: number;
  92466. /**
  92467. * Custom position function (internal use)
  92468. * @hidden
  92469. */
  92470. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  92471. /**
  92472. * Custom vertex function (internal use)
  92473. * @hidden
  92474. */
  92475. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  92476. /**
  92477. * 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.
  92478. * SPS internal tool, don't use it manually.
  92479. * @hidden
  92480. */
  92481. 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>);
  92482. }
  92483. /**
  92484. * Represents a Depth Sorted Particle in the solid particle system.
  92485. */
  92486. export class DepthSortedParticle {
  92487. /**
  92488. * Index of the particle in the "indices" array
  92489. */
  92490. ind: number;
  92491. /**
  92492. * Length of the particle shape in the "indices" array
  92493. */
  92494. indicesLength: number;
  92495. /**
  92496. * Squared distance from the particle to the camera
  92497. */
  92498. sqDistance: number;
  92499. }
  92500. }
  92501. declare module BABYLON {
  92502. /**
  92503. * @hidden
  92504. */
  92505. export class _MeshCollisionData {
  92506. _checkCollisions: boolean;
  92507. _collisionMask: number;
  92508. _collisionGroup: number;
  92509. _collider: Nullable<Collider>;
  92510. _oldPositionForCollisions: Vector3;
  92511. _diffPositionForCollisions: Vector3;
  92512. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  92513. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  92514. }
  92515. }
  92516. declare module BABYLON {
  92517. /** @hidden */
  92518. class _FacetDataStorage {
  92519. facetPositions: Vector3[];
  92520. facetNormals: Vector3[];
  92521. facetPartitioning: number[][];
  92522. facetNb: number;
  92523. partitioningSubdivisions: number;
  92524. partitioningBBoxRatio: number;
  92525. facetDataEnabled: boolean;
  92526. facetParameters: any;
  92527. bbSize: Vector3;
  92528. subDiv: {
  92529. max: number;
  92530. X: number;
  92531. Y: number;
  92532. Z: number;
  92533. };
  92534. facetDepthSort: boolean;
  92535. facetDepthSortEnabled: boolean;
  92536. depthSortedIndices: IndicesArray;
  92537. depthSortedFacets: {
  92538. ind: number;
  92539. sqDistance: number;
  92540. }[];
  92541. facetDepthSortFunction: (f1: {
  92542. ind: number;
  92543. sqDistance: number;
  92544. }, f2: {
  92545. ind: number;
  92546. sqDistance: number;
  92547. }) => number;
  92548. facetDepthSortFrom: Vector3;
  92549. facetDepthSortOrigin: Vector3;
  92550. invertedMatrix: Matrix;
  92551. }
  92552. /**
  92553. * @hidden
  92554. **/
  92555. class _InternalAbstractMeshDataInfo {
  92556. _hasVertexAlpha: boolean;
  92557. _useVertexColors: boolean;
  92558. _numBoneInfluencers: number;
  92559. _applyFog: boolean;
  92560. _receiveShadows: boolean;
  92561. _facetData: _FacetDataStorage;
  92562. _visibility: number;
  92563. _skeleton: Nullable<Skeleton>;
  92564. _layerMask: number;
  92565. _computeBonesUsingShaders: boolean;
  92566. _isActive: boolean;
  92567. _onlyForInstances: boolean;
  92568. _isActiveIntermediate: boolean;
  92569. _onlyForInstancesIntermediate: boolean;
  92570. _actAsRegularMesh: boolean;
  92571. }
  92572. /**
  92573. * Class used to store all common mesh properties
  92574. */
  92575. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  92576. /** No occlusion */
  92577. static OCCLUSION_TYPE_NONE: number;
  92578. /** Occlusion set to optimisitic */
  92579. static OCCLUSION_TYPE_OPTIMISTIC: number;
  92580. /** Occlusion set to strict */
  92581. static OCCLUSION_TYPE_STRICT: number;
  92582. /** Use an accurante occlusion algorithm */
  92583. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  92584. /** Use a conservative occlusion algorithm */
  92585. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  92586. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  92587. * Test order :
  92588. * Is the bounding sphere outside the frustum ?
  92589. * If not, are the bounding box vertices outside the frustum ?
  92590. * It not, then the cullable object is in the frustum.
  92591. */
  92592. static readonly CULLINGSTRATEGY_STANDARD: number;
  92593. /** Culling strategy : Bounding Sphere Only.
  92594. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  92595. * It's also less accurate than the standard because some not visible objects can still be selected.
  92596. * Test : is the bounding sphere outside the frustum ?
  92597. * If not, then the cullable object is in the frustum.
  92598. */
  92599. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  92600. /** Culling strategy : Optimistic Inclusion.
  92601. * This in an inclusion test first, then the standard exclusion test.
  92602. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  92603. * 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.
  92604. * Anyway, it's as accurate as the standard strategy.
  92605. * Test :
  92606. * Is the cullable object bounding sphere center in the frustum ?
  92607. * If not, apply the default culling strategy.
  92608. */
  92609. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  92610. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  92611. * This in an inclusion test first, then the bounding sphere only exclusion test.
  92612. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  92613. * 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.
  92614. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  92615. * Test :
  92616. * Is the cullable object bounding sphere center in the frustum ?
  92617. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  92618. */
  92619. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  92620. /**
  92621. * No billboard
  92622. */
  92623. static readonly BILLBOARDMODE_NONE: number;
  92624. /** Billboard on X axis */
  92625. static readonly BILLBOARDMODE_X: number;
  92626. /** Billboard on Y axis */
  92627. static readonly BILLBOARDMODE_Y: number;
  92628. /** Billboard on Z axis */
  92629. static readonly BILLBOARDMODE_Z: number;
  92630. /** Billboard on all axes */
  92631. static readonly BILLBOARDMODE_ALL: number;
  92632. /** Billboard on using position instead of orientation */
  92633. static readonly BILLBOARDMODE_USE_POSITION: number;
  92634. /** @hidden */
  92635. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  92636. /**
  92637. * The culling strategy to use to check whether the mesh must be rendered or not.
  92638. * This value can be changed at any time and will be used on the next render mesh selection.
  92639. * The possible values are :
  92640. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92641. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92642. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92643. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92644. * Please read each static variable documentation to get details about the culling process.
  92645. * */
  92646. cullingStrategy: number;
  92647. /**
  92648. * Gets the number of facets in the mesh
  92649. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92650. */
  92651. readonly facetNb: number;
  92652. /**
  92653. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  92654. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92655. */
  92656. partitioningSubdivisions: number;
  92657. /**
  92658. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  92659. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  92660. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92661. */
  92662. partitioningBBoxRatio: number;
  92663. /**
  92664. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  92665. * Works only for updatable meshes.
  92666. * Doesn't work with multi-materials
  92667. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92668. */
  92669. mustDepthSortFacets: boolean;
  92670. /**
  92671. * The location (Vector3) where the facet depth sort must be computed from.
  92672. * By default, the active camera position.
  92673. * Used only when facet depth sort is enabled
  92674. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92675. */
  92676. facetDepthSortFrom: Vector3;
  92677. /**
  92678. * gets a boolean indicating if facetData is enabled
  92679. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92680. */
  92681. readonly isFacetDataEnabled: boolean;
  92682. /** @hidden */
  92683. _updateNonUniformScalingState(value: boolean): boolean;
  92684. /**
  92685. * An event triggered when this mesh collides with another one
  92686. */
  92687. onCollideObservable: Observable<AbstractMesh>;
  92688. /** Set a function to call when this mesh collides with another one */
  92689. onCollide: () => void;
  92690. /**
  92691. * An event triggered when the collision's position changes
  92692. */
  92693. onCollisionPositionChangeObservable: Observable<Vector3>;
  92694. /** Set a function to call when the collision's position changes */
  92695. onCollisionPositionChange: () => void;
  92696. /**
  92697. * An event triggered when material is changed
  92698. */
  92699. onMaterialChangedObservable: Observable<AbstractMesh>;
  92700. /**
  92701. * Gets or sets the orientation for POV movement & rotation
  92702. */
  92703. definedFacingForward: boolean;
  92704. /** @hidden */
  92705. _occlusionQuery: Nullable<WebGLQuery>;
  92706. /** @hidden */
  92707. _renderingGroup: Nullable<RenderingGroup>;
  92708. /**
  92709. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92710. */
  92711. /**
  92712. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92713. */
  92714. visibility: number;
  92715. /** Gets or sets the alpha index used to sort transparent meshes
  92716. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  92717. */
  92718. alphaIndex: number;
  92719. /**
  92720. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  92721. */
  92722. isVisible: boolean;
  92723. /**
  92724. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92725. */
  92726. isPickable: boolean;
  92727. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  92728. showSubMeshesBoundingBox: boolean;
  92729. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  92730. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  92731. */
  92732. isBlocker: boolean;
  92733. /**
  92734. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  92735. */
  92736. enablePointerMoveEvents: boolean;
  92737. /**
  92738. * Specifies the rendering group id for this mesh (0 by default)
  92739. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92740. */
  92741. renderingGroupId: number;
  92742. private _material;
  92743. /** Gets or sets current material */
  92744. material: Nullable<Material>;
  92745. /**
  92746. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  92747. * @see http://doc.babylonjs.com/babylon101/shadows
  92748. */
  92749. receiveShadows: boolean;
  92750. /** Defines color to use when rendering outline */
  92751. outlineColor: Color3;
  92752. /** Define width to use when rendering outline */
  92753. outlineWidth: number;
  92754. /** Defines color to use when rendering overlay */
  92755. overlayColor: Color3;
  92756. /** Defines alpha to use when rendering overlay */
  92757. overlayAlpha: number;
  92758. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  92759. hasVertexAlpha: boolean;
  92760. /** 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) */
  92761. useVertexColors: boolean;
  92762. /**
  92763. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  92764. */
  92765. computeBonesUsingShaders: boolean;
  92766. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  92767. numBoneInfluencers: number;
  92768. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  92769. applyFog: boolean;
  92770. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  92771. useOctreeForRenderingSelection: boolean;
  92772. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  92773. useOctreeForPicking: boolean;
  92774. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  92775. useOctreeForCollisions: boolean;
  92776. /**
  92777. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  92778. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  92779. */
  92780. layerMask: number;
  92781. /**
  92782. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  92783. */
  92784. alwaysSelectAsActiveMesh: boolean;
  92785. /**
  92786. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  92787. */
  92788. doNotSyncBoundingInfo: boolean;
  92789. /**
  92790. * Gets or sets the current action manager
  92791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92792. */
  92793. actionManager: Nullable<AbstractActionManager>;
  92794. private _meshCollisionData;
  92795. /**
  92796. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  92797. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92798. */
  92799. ellipsoid: Vector3;
  92800. /**
  92801. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  92802. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92803. */
  92804. ellipsoidOffset: Vector3;
  92805. /**
  92806. * Gets or sets a collision mask used to mask collisions (default is -1).
  92807. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92808. */
  92809. collisionMask: number;
  92810. /**
  92811. * Gets or sets the current collision group mask (-1 by default).
  92812. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92813. */
  92814. collisionGroup: number;
  92815. /**
  92816. * Defines edge width used when edgesRenderer is enabled
  92817. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92818. */
  92819. edgesWidth: number;
  92820. /**
  92821. * Defines edge color used when edgesRenderer is enabled
  92822. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92823. */
  92824. edgesColor: Color4;
  92825. /** @hidden */
  92826. _edgesRenderer: Nullable<IEdgesRenderer>;
  92827. /** @hidden */
  92828. _masterMesh: Nullable<AbstractMesh>;
  92829. /** @hidden */
  92830. _boundingInfo: Nullable<BoundingInfo>;
  92831. /** @hidden */
  92832. _renderId: number;
  92833. /**
  92834. * Gets or sets the list of subMeshes
  92835. * @see http://doc.babylonjs.com/how_to/multi_materials
  92836. */
  92837. subMeshes: SubMesh[];
  92838. /** @hidden */
  92839. _intersectionsInProgress: AbstractMesh[];
  92840. /** @hidden */
  92841. _unIndexed: boolean;
  92842. /** @hidden */
  92843. _lightSources: Light[];
  92844. /** Gets the list of lights affecting that mesh */
  92845. readonly lightSources: Light[];
  92846. /** @hidden */
  92847. readonly _positions: Nullable<Vector3[]>;
  92848. /** @hidden */
  92849. _waitingData: {
  92850. lods: Nullable<any>;
  92851. actions: Nullable<any>;
  92852. freezeWorldMatrix: Nullable<boolean>;
  92853. };
  92854. /** @hidden */
  92855. _bonesTransformMatrices: Nullable<Float32Array>;
  92856. /** @hidden */
  92857. _transformMatrixTexture: Nullable<RawTexture>;
  92858. /**
  92859. * Gets or sets a skeleton to apply skining transformations
  92860. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92861. */
  92862. skeleton: Nullable<Skeleton>;
  92863. /**
  92864. * An event triggered when the mesh is rebuilt.
  92865. */
  92866. onRebuildObservable: Observable<AbstractMesh>;
  92867. /**
  92868. * Creates a new AbstractMesh
  92869. * @param name defines the name of the mesh
  92870. * @param scene defines the hosting scene
  92871. */
  92872. constructor(name: string, scene?: Nullable<Scene>);
  92873. /**
  92874. * Returns the string "AbstractMesh"
  92875. * @returns "AbstractMesh"
  92876. */
  92877. getClassName(): string;
  92878. /**
  92879. * Gets a string representation of the current mesh
  92880. * @param fullDetails defines a boolean indicating if full details must be included
  92881. * @returns a string representation of the current mesh
  92882. */
  92883. toString(fullDetails?: boolean): string;
  92884. /**
  92885. * @hidden
  92886. */
  92887. protected _getEffectiveParent(): Nullable<Node>;
  92888. /** @hidden */
  92889. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92890. /** @hidden */
  92891. _rebuild(): void;
  92892. /** @hidden */
  92893. _resyncLightSources(): void;
  92894. /** @hidden */
  92895. _resyncLighSource(light: Light): void;
  92896. /** @hidden */
  92897. _unBindEffect(): void;
  92898. /** @hidden */
  92899. _removeLightSource(light: Light, dispose: boolean): void;
  92900. private _markSubMeshesAsDirty;
  92901. /** @hidden */
  92902. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  92903. /** @hidden */
  92904. _markSubMeshesAsAttributesDirty(): void;
  92905. /** @hidden */
  92906. _markSubMeshesAsMiscDirty(): void;
  92907. /**
  92908. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  92909. */
  92910. scaling: Vector3;
  92911. /**
  92912. * Returns true if the mesh is blocked. Implemented by child classes
  92913. */
  92914. readonly isBlocked: boolean;
  92915. /**
  92916. * Returns the mesh itself by default. Implemented by child classes
  92917. * @param camera defines the camera to use to pick the right LOD level
  92918. * @returns the currentAbstractMesh
  92919. */
  92920. getLOD(camera: Camera): Nullable<AbstractMesh>;
  92921. /**
  92922. * Returns 0 by default. Implemented by child classes
  92923. * @returns an integer
  92924. */
  92925. getTotalVertices(): number;
  92926. /**
  92927. * Returns a positive integer : the total number of indices in this mesh geometry.
  92928. * @returns the numner of indices or zero if the mesh has no geometry.
  92929. */
  92930. getTotalIndices(): number;
  92931. /**
  92932. * Returns null by default. Implemented by child classes
  92933. * @returns null
  92934. */
  92935. getIndices(): Nullable<IndicesArray>;
  92936. /**
  92937. * Returns the array of the requested vertex data kind. Implemented by child classes
  92938. * @param kind defines the vertex data kind to use
  92939. * @returns null
  92940. */
  92941. getVerticesData(kind: string): Nullable<FloatArray>;
  92942. /**
  92943. * Sets the vertex data of the mesh geometry for the requested `kind`.
  92944. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92945. * Note that a new underlying VertexBuffer object is created each call.
  92946. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  92947. * @param kind defines vertex data kind:
  92948. * * VertexBuffer.PositionKind
  92949. * * VertexBuffer.UVKind
  92950. * * VertexBuffer.UV2Kind
  92951. * * VertexBuffer.UV3Kind
  92952. * * VertexBuffer.UV4Kind
  92953. * * VertexBuffer.UV5Kind
  92954. * * VertexBuffer.UV6Kind
  92955. * * VertexBuffer.ColorKind
  92956. * * VertexBuffer.MatricesIndicesKind
  92957. * * VertexBuffer.MatricesIndicesExtraKind
  92958. * * VertexBuffer.MatricesWeightsKind
  92959. * * VertexBuffer.MatricesWeightsExtraKind
  92960. * @param data defines the data source
  92961. * @param updatable defines if the data must be flagged as updatable (or static)
  92962. * @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
  92963. * @returns the current mesh
  92964. */
  92965. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92966. /**
  92967. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  92968. * If the mesh has no geometry, it is simply returned as it is.
  92969. * @param kind defines vertex data kind:
  92970. * * VertexBuffer.PositionKind
  92971. * * VertexBuffer.UVKind
  92972. * * VertexBuffer.UV2Kind
  92973. * * VertexBuffer.UV3Kind
  92974. * * VertexBuffer.UV4Kind
  92975. * * VertexBuffer.UV5Kind
  92976. * * VertexBuffer.UV6Kind
  92977. * * VertexBuffer.ColorKind
  92978. * * VertexBuffer.MatricesIndicesKind
  92979. * * VertexBuffer.MatricesIndicesExtraKind
  92980. * * VertexBuffer.MatricesWeightsKind
  92981. * * VertexBuffer.MatricesWeightsExtraKind
  92982. * @param data defines the data source
  92983. * @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
  92984. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  92985. * @returns the current mesh
  92986. */
  92987. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92988. /**
  92989. * Sets the mesh indices,
  92990. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92991. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  92992. * @param totalVertices Defines the total number of vertices
  92993. * @returns the current mesh
  92994. */
  92995. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  92996. /**
  92997. * Gets a boolean indicating if specific vertex data is present
  92998. * @param kind defines the vertex data kind to use
  92999. * @returns true is data kind is present
  93000. */
  93001. isVerticesDataPresent(kind: string): boolean;
  93002. /**
  93003. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  93004. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  93005. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  93006. * @returns a BoundingInfo
  93007. */
  93008. getBoundingInfo(): BoundingInfo;
  93009. /**
  93010. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93011. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93012. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93013. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93014. * @returns the current mesh
  93015. */
  93016. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  93017. /**
  93018. * Overwrite the current bounding info
  93019. * @param boundingInfo defines the new bounding info
  93020. * @returns the current mesh
  93021. */
  93022. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  93023. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93024. readonly useBones: boolean;
  93025. /** @hidden */
  93026. _preActivate(): void;
  93027. /** @hidden */
  93028. _preActivateForIntermediateRendering(renderId: number): void;
  93029. /** @hidden */
  93030. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93031. /** @hidden */
  93032. _postActivate(): void;
  93033. /** @hidden */
  93034. _freeze(): void;
  93035. /** @hidden */
  93036. _unFreeze(): void;
  93037. /**
  93038. * Gets the current world matrix
  93039. * @returns a Matrix
  93040. */
  93041. getWorldMatrix(): Matrix;
  93042. /** @hidden */
  93043. _getWorldMatrixDeterminant(): number;
  93044. /**
  93045. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93046. */
  93047. readonly isAnInstance: boolean;
  93048. /**
  93049. * Gets a boolean indicating if this mesh has instances
  93050. */
  93051. readonly hasInstances: boolean;
  93052. /**
  93053. * Perform relative position change from the point of view of behind the front of the mesh.
  93054. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93055. * Supports definition of mesh facing forward or backward
  93056. * @param amountRight defines the distance on the right axis
  93057. * @param amountUp defines the distance on the up axis
  93058. * @param amountForward defines the distance on the forward axis
  93059. * @returns the current mesh
  93060. */
  93061. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  93062. /**
  93063. * Calculate relative position change from the point of view of behind the front of the mesh.
  93064. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93065. * Supports definition of mesh facing forward or backward
  93066. * @param amountRight defines the distance on the right axis
  93067. * @param amountUp defines the distance on the up axis
  93068. * @param amountForward defines the distance on the forward axis
  93069. * @returns the new displacement vector
  93070. */
  93071. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93072. /**
  93073. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93074. * Supports definition of mesh facing forward or backward
  93075. * @param flipBack defines the flip
  93076. * @param twirlClockwise defines the twirl
  93077. * @param tiltRight defines the tilt
  93078. * @returns the current mesh
  93079. */
  93080. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93081. /**
  93082. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93083. * Supports definition of mesh facing forward or backward.
  93084. * @param flipBack defines the flip
  93085. * @param twirlClockwise defines the twirl
  93086. * @param tiltRight defines the tilt
  93087. * @returns the new rotation vector
  93088. */
  93089. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93090. /**
  93091. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93092. * This means the mesh underlying bounding box and sphere are recomputed.
  93093. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93094. * @returns the current mesh
  93095. */
  93096. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93097. /** @hidden */
  93098. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93099. /** @hidden */
  93100. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93101. /** @hidden */
  93102. _updateBoundingInfo(): AbstractMesh;
  93103. /** @hidden */
  93104. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93105. /** @hidden */
  93106. protected _afterComputeWorldMatrix(): void;
  93107. /** @hidden */
  93108. readonly _effectiveMesh: AbstractMesh;
  93109. /**
  93110. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93111. * A mesh is in the frustum if its bounding box intersects the frustum
  93112. * @param frustumPlanes defines the frustum to test
  93113. * @returns true if the mesh is in the frustum planes
  93114. */
  93115. isInFrustum(frustumPlanes: Plane[]): boolean;
  93116. /**
  93117. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93118. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93119. * @param frustumPlanes defines the frustum to test
  93120. * @returns true if the mesh is completely in the frustum planes
  93121. */
  93122. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93123. /**
  93124. * True if the mesh intersects another mesh or a SolidParticle object
  93125. * @param mesh defines a target mesh or SolidParticle to test
  93126. * @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)
  93127. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93128. * @returns true if there is an intersection
  93129. */
  93130. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93131. /**
  93132. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93133. * @param point defines the point to test
  93134. * @returns true if there is an intersection
  93135. */
  93136. intersectsPoint(point: Vector3): boolean;
  93137. /**
  93138. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93139. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93140. */
  93141. checkCollisions: boolean;
  93142. /**
  93143. * Gets Collider object used to compute collisions (not physics)
  93144. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93145. */
  93146. readonly collider: Nullable<Collider>;
  93147. /**
  93148. * Move the mesh using collision engine
  93149. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93150. * @param displacement defines the requested displacement vector
  93151. * @returns the current mesh
  93152. */
  93153. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93154. private _onCollisionPositionChange;
  93155. /** @hidden */
  93156. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93157. /** @hidden */
  93158. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93159. /** @hidden */
  93160. _checkCollision(collider: Collider): AbstractMesh;
  93161. /** @hidden */
  93162. _generatePointsArray(): boolean;
  93163. /**
  93164. * Checks if the passed Ray intersects with the mesh
  93165. * @param ray defines the ray to use
  93166. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93167. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93168. * @returns the picking info
  93169. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93170. */
  93171. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93172. /**
  93173. * Clones the current mesh
  93174. * @param name defines the mesh name
  93175. * @param newParent defines the new mesh parent
  93176. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93177. * @returns the new mesh
  93178. */
  93179. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93180. /**
  93181. * Disposes all the submeshes of the current meshnp
  93182. * @returns the current mesh
  93183. */
  93184. releaseSubMeshes(): AbstractMesh;
  93185. /**
  93186. * Releases resources associated with this abstract mesh.
  93187. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93188. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93189. */
  93190. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93191. /**
  93192. * Adds the passed mesh as a child to the current mesh
  93193. * @param mesh defines the child mesh
  93194. * @returns the current mesh
  93195. */
  93196. addChild(mesh: AbstractMesh): AbstractMesh;
  93197. /**
  93198. * Removes the passed mesh from the current mesh children list
  93199. * @param mesh defines the child mesh
  93200. * @returns the current mesh
  93201. */
  93202. removeChild(mesh: AbstractMesh): AbstractMesh;
  93203. /** @hidden */
  93204. private _initFacetData;
  93205. /**
  93206. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93207. * This method can be called within the render loop.
  93208. * 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
  93209. * @returns the current mesh
  93210. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93211. */
  93212. updateFacetData(): AbstractMesh;
  93213. /**
  93214. * Returns the facetLocalNormals array.
  93215. * The normals are expressed in the mesh local spac
  93216. * @returns an array of Vector3
  93217. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93218. */
  93219. getFacetLocalNormals(): Vector3[];
  93220. /**
  93221. * Returns the facetLocalPositions array.
  93222. * The facet positions are expressed in the mesh local space
  93223. * @returns an array of Vector3
  93224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93225. */
  93226. getFacetLocalPositions(): Vector3[];
  93227. /**
  93228. * Returns the facetLocalPartioning array
  93229. * @returns an array of array of numbers
  93230. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93231. */
  93232. getFacetLocalPartitioning(): number[][];
  93233. /**
  93234. * Returns the i-th facet position in the world system.
  93235. * This method allocates a new Vector3 per call
  93236. * @param i defines the facet index
  93237. * @returns a new Vector3
  93238. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93239. */
  93240. getFacetPosition(i: number): Vector3;
  93241. /**
  93242. * Sets the reference Vector3 with the i-th facet position in the world system
  93243. * @param i defines the facet index
  93244. * @param ref defines the target vector
  93245. * @returns the current mesh
  93246. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93247. */
  93248. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  93249. /**
  93250. * Returns the i-th facet normal in the world system.
  93251. * This method allocates a new Vector3 per call
  93252. * @param i defines the facet index
  93253. * @returns a new Vector3
  93254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93255. */
  93256. getFacetNormal(i: number): Vector3;
  93257. /**
  93258. * Sets the reference Vector3 with the i-th facet normal in the world system
  93259. * @param i defines the facet index
  93260. * @param ref defines the target vector
  93261. * @returns the current mesh
  93262. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93263. */
  93264. getFacetNormalToRef(i: number, ref: Vector3): this;
  93265. /**
  93266. * 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)
  93267. * @param x defines x coordinate
  93268. * @param y defines y coordinate
  93269. * @param z defines z coordinate
  93270. * @returns the array of facet indexes
  93271. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93272. */
  93273. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  93274. /**
  93275. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  93276. * @param projected sets as the (x,y,z) world projection on the facet
  93277. * @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
  93278. * @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
  93279. * @param x defines x coordinate
  93280. * @param y defines y coordinate
  93281. * @param z defines z coordinate
  93282. * @returns the face index if found (or null instead)
  93283. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93284. */
  93285. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93286. /**
  93287. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  93288. * @param projected sets as the (x,y,z) local projection on the facet
  93289. * @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
  93290. * @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
  93291. * @param x defines x coordinate
  93292. * @param y defines y coordinate
  93293. * @param z defines z coordinate
  93294. * @returns the face index if found (or null instead)
  93295. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93296. */
  93297. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93298. /**
  93299. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  93300. * @returns the parameters
  93301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93302. */
  93303. getFacetDataParameters(): any;
  93304. /**
  93305. * Disables the feature FacetData and frees the related memory
  93306. * @returns the current mesh
  93307. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93308. */
  93309. disableFacetData(): AbstractMesh;
  93310. /**
  93311. * Updates the AbstractMesh indices array
  93312. * @param indices defines the data source
  93313. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93314. * @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)
  93315. * @returns the current mesh
  93316. */
  93317. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93318. /**
  93319. * Creates new normals data for the mesh
  93320. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  93321. * @returns the current mesh
  93322. */
  93323. createNormals(updatable: boolean): AbstractMesh;
  93324. /**
  93325. * Align the mesh with a normal
  93326. * @param normal defines the normal to use
  93327. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  93328. * @returns the current mesh
  93329. */
  93330. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  93331. /** @hidden */
  93332. _checkOcclusionQuery(): boolean;
  93333. /**
  93334. * Disables the mesh edge rendering mode
  93335. * @returns the currentAbstractMesh
  93336. */
  93337. disableEdgesRendering(): AbstractMesh;
  93338. /**
  93339. * Enables the edge rendering mode on the mesh.
  93340. * This mode makes the mesh edges visible
  93341. * @param epsilon defines the maximal distance between two angles to detect a face
  93342. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93343. * @returns the currentAbstractMesh
  93344. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93345. */
  93346. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93347. }
  93348. }
  93349. declare module BABYLON {
  93350. /**
  93351. * Interface used to define ActionEvent
  93352. */
  93353. export interface IActionEvent {
  93354. /** The mesh or sprite that triggered the action */
  93355. source: any;
  93356. /** The X mouse cursor position at the time of the event */
  93357. pointerX: number;
  93358. /** The Y mouse cursor position at the time of the event */
  93359. pointerY: number;
  93360. /** The mesh that is currently pointed at (can be null) */
  93361. meshUnderPointer: Nullable<AbstractMesh>;
  93362. /** the original (browser) event that triggered the ActionEvent */
  93363. sourceEvent?: any;
  93364. /** additional data for the event */
  93365. additionalData?: any;
  93366. }
  93367. /**
  93368. * ActionEvent is the event being sent when an action is triggered.
  93369. */
  93370. export class ActionEvent implements IActionEvent {
  93371. /** The mesh or sprite that triggered the action */
  93372. source: any;
  93373. /** The X mouse cursor position at the time of the event */
  93374. pointerX: number;
  93375. /** The Y mouse cursor position at the time of the event */
  93376. pointerY: number;
  93377. /** The mesh that is currently pointed at (can be null) */
  93378. meshUnderPointer: Nullable<AbstractMesh>;
  93379. /** the original (browser) event that triggered the ActionEvent */
  93380. sourceEvent?: any;
  93381. /** additional data for the event */
  93382. additionalData?: any;
  93383. /**
  93384. * Creates a new ActionEvent
  93385. * @param source The mesh or sprite that triggered the action
  93386. * @param pointerX The X mouse cursor position at the time of the event
  93387. * @param pointerY The Y mouse cursor position at the time of the event
  93388. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  93389. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  93390. * @param additionalData additional data for the event
  93391. */
  93392. constructor(
  93393. /** The mesh or sprite that triggered the action */
  93394. source: any,
  93395. /** The X mouse cursor position at the time of the event */
  93396. pointerX: number,
  93397. /** The Y mouse cursor position at the time of the event */
  93398. pointerY: number,
  93399. /** The mesh that is currently pointed at (can be null) */
  93400. meshUnderPointer: Nullable<AbstractMesh>,
  93401. /** the original (browser) event that triggered the ActionEvent */
  93402. sourceEvent?: any,
  93403. /** additional data for the event */
  93404. additionalData?: any);
  93405. /**
  93406. * Helper function to auto-create an ActionEvent from a source mesh.
  93407. * @param source The source mesh that triggered the event
  93408. * @param evt The original (browser) event
  93409. * @param additionalData additional data for the event
  93410. * @returns the new ActionEvent
  93411. */
  93412. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  93413. /**
  93414. * Helper function to auto-create an ActionEvent from a source sprite
  93415. * @param source The source sprite that triggered the event
  93416. * @param scene Scene associated with the sprite
  93417. * @param evt The original (browser) event
  93418. * @param additionalData additional data for the event
  93419. * @returns the new ActionEvent
  93420. */
  93421. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  93422. /**
  93423. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  93424. * @param scene the scene where the event occurred
  93425. * @param evt The original (browser) event
  93426. * @returns the new ActionEvent
  93427. */
  93428. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  93429. /**
  93430. * Helper function to auto-create an ActionEvent from a primitive
  93431. * @param prim defines the target primitive
  93432. * @param pointerPos defines the pointer position
  93433. * @param evt The original (browser) event
  93434. * @param additionalData additional data for the event
  93435. * @returns the new ActionEvent
  93436. */
  93437. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  93438. }
  93439. }
  93440. declare module BABYLON {
  93441. /**
  93442. * Abstract class used to decouple action Manager from scene and meshes.
  93443. * Do not instantiate.
  93444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93445. */
  93446. export abstract class AbstractActionManager implements IDisposable {
  93447. /** Gets the list of active triggers */
  93448. static Triggers: {
  93449. [key: string]: number;
  93450. };
  93451. /** Gets the cursor to use when hovering items */
  93452. hoverCursor: string;
  93453. /** Gets the list of actions */
  93454. actions: IAction[];
  93455. /**
  93456. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  93457. */
  93458. isRecursive: boolean;
  93459. /**
  93460. * Releases all associated resources
  93461. */
  93462. abstract dispose(): void;
  93463. /**
  93464. * Does this action manager has pointer triggers
  93465. */
  93466. abstract readonly hasPointerTriggers: boolean;
  93467. /**
  93468. * Does this action manager has pick triggers
  93469. */
  93470. abstract readonly hasPickTriggers: boolean;
  93471. /**
  93472. * Process a specific trigger
  93473. * @param trigger defines the trigger to process
  93474. * @param evt defines the event details to be processed
  93475. */
  93476. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  93477. /**
  93478. * Does this action manager handles actions of any of the given triggers
  93479. * @param triggers defines the triggers to be tested
  93480. * @return a boolean indicating whether one (or more) of the triggers is handled
  93481. */
  93482. abstract hasSpecificTriggers(triggers: number[]): boolean;
  93483. /**
  93484. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93485. * speed.
  93486. * @param triggerA defines the trigger to be tested
  93487. * @param triggerB defines the trigger to be tested
  93488. * @return a boolean indicating whether one (or more) of the triggers is handled
  93489. */
  93490. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93491. /**
  93492. * Does this action manager handles actions of a given trigger
  93493. * @param trigger defines the trigger to be tested
  93494. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93495. * @return whether the trigger is handled
  93496. */
  93497. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93498. /**
  93499. * Serialize this manager to a JSON object
  93500. * @param name defines the property name to store this manager
  93501. * @returns a JSON representation of this manager
  93502. */
  93503. abstract serialize(name: string): any;
  93504. /**
  93505. * Registers an action to this action manager
  93506. * @param action defines the action to be registered
  93507. * @return the action amended (prepared) after registration
  93508. */
  93509. abstract registerAction(action: IAction): Nullable<IAction>;
  93510. /**
  93511. * Unregisters an action to this action manager
  93512. * @param action defines the action to be unregistered
  93513. * @return a boolean indicating whether the action has been unregistered
  93514. */
  93515. abstract unregisterAction(action: IAction): Boolean;
  93516. /**
  93517. * Does exist one action manager with at least one trigger
  93518. **/
  93519. static readonly HasTriggers: boolean;
  93520. /**
  93521. * Does exist one action manager with at least one pick trigger
  93522. **/
  93523. static readonly HasPickTriggers: boolean;
  93524. /**
  93525. * Does exist one action manager that handles actions of a given trigger
  93526. * @param trigger defines the trigger to be tested
  93527. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  93528. **/
  93529. static HasSpecificTrigger(trigger: number): boolean;
  93530. }
  93531. }
  93532. declare module BABYLON {
  93533. /**
  93534. * Defines how a node can be built from a string name.
  93535. */
  93536. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  93537. /**
  93538. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  93539. */
  93540. export class Node implements IBehaviorAware<Node> {
  93541. /** @hidden */
  93542. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  93543. private static _NodeConstructors;
  93544. /**
  93545. * Add a new node constructor
  93546. * @param type defines the type name of the node to construct
  93547. * @param constructorFunc defines the constructor function
  93548. */
  93549. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  93550. /**
  93551. * Returns a node constructor based on type name
  93552. * @param type defines the type name
  93553. * @param name defines the new node name
  93554. * @param scene defines the hosting scene
  93555. * @param options defines optional options to transmit to constructors
  93556. * @returns the new constructor or null
  93557. */
  93558. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  93559. /**
  93560. * Gets or sets the name of the node
  93561. */
  93562. name: string;
  93563. /**
  93564. * Gets or sets the id of the node
  93565. */
  93566. id: string;
  93567. /**
  93568. * Gets or sets the unique id of the node
  93569. */
  93570. uniqueId: number;
  93571. /**
  93572. * Gets or sets a string used to store user defined state for the node
  93573. */
  93574. state: string;
  93575. /**
  93576. * Gets or sets an object used to store user defined information for the node
  93577. */
  93578. metadata: any;
  93579. /**
  93580. * For internal use only. Please do not use.
  93581. */
  93582. reservedDataStore: any;
  93583. /**
  93584. * List of inspectable custom properties (used by the Inspector)
  93585. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93586. */
  93587. inspectableCustomProperties: IInspectable[];
  93588. private _doNotSerialize;
  93589. /**
  93590. * Gets or sets a boolean used to define if the node must be serialized
  93591. */
  93592. doNotSerialize: boolean;
  93593. /** @hidden */
  93594. _isDisposed: boolean;
  93595. /**
  93596. * Gets a list of Animations associated with the node
  93597. */
  93598. animations: Animation[];
  93599. protected _ranges: {
  93600. [name: string]: Nullable<AnimationRange>;
  93601. };
  93602. /**
  93603. * Callback raised when the node is ready to be used
  93604. */
  93605. onReady: Nullable<(node: Node) => void>;
  93606. private _isEnabled;
  93607. private _isParentEnabled;
  93608. private _isReady;
  93609. /** @hidden */
  93610. _currentRenderId: number;
  93611. private _parentUpdateId;
  93612. /** @hidden */
  93613. _childUpdateId: number;
  93614. /** @hidden */
  93615. _waitingParentId: Nullable<string>;
  93616. /** @hidden */
  93617. _scene: Scene;
  93618. /** @hidden */
  93619. _cache: any;
  93620. private _parentNode;
  93621. private _children;
  93622. /** @hidden */
  93623. _worldMatrix: Matrix;
  93624. /** @hidden */
  93625. _worldMatrixDeterminant: number;
  93626. /** @hidden */
  93627. _worldMatrixDeterminantIsDirty: boolean;
  93628. /** @hidden */
  93629. private _sceneRootNodesIndex;
  93630. /**
  93631. * Gets a boolean indicating if the node has been disposed
  93632. * @returns true if the node was disposed
  93633. */
  93634. isDisposed(): boolean;
  93635. /**
  93636. * Gets or sets the parent of the node (without keeping the current position in the scene)
  93637. * @see https://doc.babylonjs.com/how_to/parenting
  93638. */
  93639. parent: Nullable<Node>;
  93640. private addToSceneRootNodes;
  93641. private removeFromSceneRootNodes;
  93642. private _animationPropertiesOverride;
  93643. /**
  93644. * Gets or sets the animation properties override
  93645. */
  93646. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  93647. /**
  93648. * Gets a string idenfifying the name of the class
  93649. * @returns "Node" string
  93650. */
  93651. getClassName(): string;
  93652. /** @hidden */
  93653. readonly _isNode: boolean;
  93654. /**
  93655. * An event triggered when the mesh is disposed
  93656. */
  93657. onDisposeObservable: Observable<Node>;
  93658. private _onDisposeObserver;
  93659. /**
  93660. * Sets a callback that will be raised when the node will be disposed
  93661. */
  93662. onDispose: () => void;
  93663. /**
  93664. * Creates a new Node
  93665. * @param name the name and id to be given to this node
  93666. * @param scene the scene this node will be added to
  93667. * @param addToRootNodes the node will be added to scene.rootNodes
  93668. */
  93669. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  93670. /**
  93671. * Gets the scene of the node
  93672. * @returns a scene
  93673. */
  93674. getScene(): Scene;
  93675. /**
  93676. * Gets the engine of the node
  93677. * @returns a Engine
  93678. */
  93679. getEngine(): Engine;
  93680. private _behaviors;
  93681. /**
  93682. * Attach a behavior to the node
  93683. * @see http://doc.babylonjs.com/features/behaviour
  93684. * @param behavior defines the behavior to attach
  93685. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  93686. * @returns the current Node
  93687. */
  93688. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  93689. /**
  93690. * Remove an attached behavior
  93691. * @see http://doc.babylonjs.com/features/behaviour
  93692. * @param behavior defines the behavior to attach
  93693. * @returns the current Node
  93694. */
  93695. removeBehavior(behavior: Behavior<Node>): Node;
  93696. /**
  93697. * Gets the list of attached behaviors
  93698. * @see http://doc.babylonjs.com/features/behaviour
  93699. */
  93700. readonly behaviors: Behavior<Node>[];
  93701. /**
  93702. * Gets an attached behavior by name
  93703. * @param name defines the name of the behavior to look for
  93704. * @see http://doc.babylonjs.com/features/behaviour
  93705. * @returns null if behavior was not found else the requested behavior
  93706. */
  93707. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  93708. /**
  93709. * Returns the latest update of the World matrix
  93710. * @returns a Matrix
  93711. */
  93712. getWorldMatrix(): Matrix;
  93713. /** @hidden */
  93714. _getWorldMatrixDeterminant(): number;
  93715. /**
  93716. * Returns directly the latest state of the mesh World matrix.
  93717. * A Matrix is returned.
  93718. */
  93719. readonly worldMatrixFromCache: Matrix;
  93720. /** @hidden */
  93721. _initCache(): void;
  93722. /** @hidden */
  93723. updateCache(force?: boolean): void;
  93724. /** @hidden */
  93725. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93726. /** @hidden */
  93727. _updateCache(ignoreParentClass?: boolean): void;
  93728. /** @hidden */
  93729. _isSynchronized(): boolean;
  93730. /** @hidden */
  93731. _markSyncedWithParent(): void;
  93732. /** @hidden */
  93733. isSynchronizedWithParent(): boolean;
  93734. /** @hidden */
  93735. isSynchronized(): boolean;
  93736. /**
  93737. * Is this node ready to be used/rendered
  93738. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93739. * @return true if the node is ready
  93740. */
  93741. isReady(completeCheck?: boolean): boolean;
  93742. /**
  93743. * Is this node enabled?
  93744. * 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
  93745. * @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
  93746. * @return whether this node (and its parent) is enabled
  93747. */
  93748. isEnabled(checkAncestors?: boolean): boolean;
  93749. /** @hidden */
  93750. protected _syncParentEnabledState(): void;
  93751. /**
  93752. * Set the enabled state of this node
  93753. * @param value defines the new enabled state
  93754. */
  93755. setEnabled(value: boolean): void;
  93756. /**
  93757. * Is this node a descendant of the given node?
  93758. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  93759. * @param ancestor defines the parent node to inspect
  93760. * @returns a boolean indicating if this node is a descendant of the given node
  93761. */
  93762. isDescendantOf(ancestor: Node): boolean;
  93763. /** @hidden */
  93764. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  93765. /**
  93766. * Will return all nodes that have this node as ascendant
  93767. * @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
  93768. * @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
  93769. * @return all children nodes of all types
  93770. */
  93771. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  93772. /**
  93773. * Get all child-meshes of this node
  93774. * @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)
  93775. * @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
  93776. * @returns an array of AbstractMesh
  93777. */
  93778. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  93779. /**
  93780. * Get all direct children of this node
  93781. * @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
  93782. * @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)
  93783. * @returns an array of Node
  93784. */
  93785. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  93786. /** @hidden */
  93787. _setReady(state: boolean): void;
  93788. /**
  93789. * Get an animation by name
  93790. * @param name defines the name of the animation to look for
  93791. * @returns null if not found else the requested animation
  93792. */
  93793. getAnimationByName(name: string): Nullable<Animation>;
  93794. /**
  93795. * Creates an animation range for this node
  93796. * @param name defines the name of the range
  93797. * @param from defines the starting key
  93798. * @param to defines the end key
  93799. */
  93800. createAnimationRange(name: string, from: number, to: number): void;
  93801. /**
  93802. * Delete a specific animation range
  93803. * @param name defines the name of the range to delete
  93804. * @param deleteFrames defines if animation frames from the range must be deleted as well
  93805. */
  93806. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93807. /**
  93808. * Get an animation range by name
  93809. * @param name defines the name of the animation range to look for
  93810. * @returns null if not found else the requested animation range
  93811. */
  93812. getAnimationRange(name: string): Nullable<AnimationRange>;
  93813. /**
  93814. * Gets the list of all animation ranges defined on this node
  93815. * @returns an array
  93816. */
  93817. getAnimationRanges(): Nullable<AnimationRange>[];
  93818. /**
  93819. * Will start the animation sequence
  93820. * @param name defines the range frames for animation sequence
  93821. * @param loop defines if the animation should loop (false by default)
  93822. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  93823. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  93824. * @returns the object created for this animation. If range does not exist, it will return null
  93825. */
  93826. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93827. /**
  93828. * Serialize animation ranges into a JSON compatible object
  93829. * @returns serialization object
  93830. */
  93831. serializeAnimationRanges(): any;
  93832. /**
  93833. * Computes the world matrix of the node
  93834. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93835. * @returns the world matrix
  93836. */
  93837. computeWorldMatrix(force?: boolean): Matrix;
  93838. /**
  93839. * Releases resources associated with this node.
  93840. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93841. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93842. */
  93843. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93844. /**
  93845. * Parse animation range data from a serialization object and store them into a given node
  93846. * @param node defines where to store the animation ranges
  93847. * @param parsedNode defines the serialization object to read data from
  93848. * @param scene defines the hosting scene
  93849. */
  93850. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  93851. /**
  93852. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  93853. * @param includeDescendants Include bounding info from descendants as well (true by default)
  93854. * @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
  93855. * @returns the new bounding vectors
  93856. */
  93857. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  93858. min: Vector3;
  93859. max: Vector3;
  93860. };
  93861. }
  93862. }
  93863. declare module BABYLON {
  93864. /**
  93865. * @hidden
  93866. */
  93867. export class _IAnimationState {
  93868. key: number;
  93869. repeatCount: number;
  93870. workValue?: any;
  93871. loopMode?: number;
  93872. offsetValue?: any;
  93873. highLimitValue?: any;
  93874. }
  93875. /**
  93876. * Class used to store any kind of animation
  93877. */
  93878. export class Animation {
  93879. /**Name of the animation */
  93880. name: string;
  93881. /**Property to animate */
  93882. targetProperty: string;
  93883. /**The frames per second of the animation */
  93884. framePerSecond: number;
  93885. /**The data type of the animation */
  93886. dataType: number;
  93887. /**The loop mode of the animation */
  93888. loopMode?: number | undefined;
  93889. /**Specifies if blending should be enabled */
  93890. enableBlending?: boolean | undefined;
  93891. /**
  93892. * Use matrix interpolation instead of using direct key value when animating matrices
  93893. */
  93894. static AllowMatricesInterpolation: boolean;
  93895. /**
  93896. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  93897. */
  93898. static AllowMatrixDecomposeForInterpolation: boolean;
  93899. /**
  93900. * Stores the key frames of the animation
  93901. */
  93902. private _keys;
  93903. /**
  93904. * Stores the easing function of the animation
  93905. */
  93906. private _easingFunction;
  93907. /**
  93908. * @hidden Internal use only
  93909. */
  93910. _runtimeAnimations: RuntimeAnimation[];
  93911. /**
  93912. * The set of event that will be linked to this animation
  93913. */
  93914. private _events;
  93915. /**
  93916. * Stores an array of target property paths
  93917. */
  93918. targetPropertyPath: string[];
  93919. /**
  93920. * Stores the blending speed of the animation
  93921. */
  93922. blendingSpeed: number;
  93923. /**
  93924. * Stores the animation ranges for the animation
  93925. */
  93926. private _ranges;
  93927. /**
  93928. * @hidden Internal use
  93929. */
  93930. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  93931. /**
  93932. * Sets up an animation
  93933. * @param property The property to animate
  93934. * @param animationType The animation type to apply
  93935. * @param framePerSecond The frames per second of the animation
  93936. * @param easingFunction The easing function used in the animation
  93937. * @returns The created animation
  93938. */
  93939. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  93940. /**
  93941. * Create and start an animation on a node
  93942. * @param name defines the name of the global animation that will be run on all nodes
  93943. * @param node defines the root node where the animation will take place
  93944. * @param targetProperty defines property to animate
  93945. * @param framePerSecond defines the number of frame per second yo use
  93946. * @param totalFrame defines the number of frames in total
  93947. * @param from defines the initial value
  93948. * @param to defines the final value
  93949. * @param loopMode defines which loop mode you want to use (off by default)
  93950. * @param easingFunction defines the easing function to use (linear by default)
  93951. * @param onAnimationEnd defines the callback to call when animation end
  93952. * @returns the animatable created for this animation
  93953. */
  93954. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93955. /**
  93956. * Create and start an animation on a node and its descendants
  93957. * @param name defines the name of the global animation that will be run on all nodes
  93958. * @param node defines the root node where the animation will take place
  93959. * @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
  93960. * @param targetProperty defines property to animate
  93961. * @param framePerSecond defines the number of frame per second to use
  93962. * @param totalFrame defines the number of frames in total
  93963. * @param from defines the initial value
  93964. * @param to defines the final value
  93965. * @param loopMode defines which loop mode you want to use (off by default)
  93966. * @param easingFunction defines the easing function to use (linear by default)
  93967. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93968. * @returns the list of animatables created for all nodes
  93969. * @example https://www.babylonjs-playground.com/#MH0VLI
  93970. */
  93971. 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[]>;
  93972. /**
  93973. * Creates a new animation, merges it with the existing animations and starts it
  93974. * @param name Name of the animation
  93975. * @param node Node which contains the scene that begins the animations
  93976. * @param targetProperty Specifies which property to animate
  93977. * @param framePerSecond The frames per second of the animation
  93978. * @param totalFrame The total number of frames
  93979. * @param from The frame at the beginning of the animation
  93980. * @param to The frame at the end of the animation
  93981. * @param loopMode Specifies the loop mode of the animation
  93982. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  93983. * @param onAnimationEnd Callback to run once the animation is complete
  93984. * @returns Nullable animation
  93985. */
  93986. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93987. /**
  93988. * Transition property of an host to the target Value
  93989. * @param property The property to transition
  93990. * @param targetValue The target Value of the property
  93991. * @param host The object where the property to animate belongs
  93992. * @param scene Scene used to run the animation
  93993. * @param frameRate Framerate (in frame/s) to use
  93994. * @param transition The transition type we want to use
  93995. * @param duration The duration of the animation, in milliseconds
  93996. * @param onAnimationEnd Callback trigger at the end of the animation
  93997. * @returns Nullable animation
  93998. */
  93999. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  94000. /**
  94001. * Return the array of runtime animations currently using this animation
  94002. */
  94003. readonly runtimeAnimations: RuntimeAnimation[];
  94004. /**
  94005. * Specifies if any of the runtime animations are currently running
  94006. */
  94007. readonly hasRunningRuntimeAnimations: boolean;
  94008. /**
  94009. * Initializes the animation
  94010. * @param name Name of the animation
  94011. * @param targetProperty Property to animate
  94012. * @param framePerSecond The frames per second of the animation
  94013. * @param dataType The data type of the animation
  94014. * @param loopMode The loop mode of the animation
  94015. * @param enableBlending Specifies if blending should be enabled
  94016. */
  94017. constructor(
  94018. /**Name of the animation */
  94019. name: string,
  94020. /**Property to animate */
  94021. targetProperty: string,
  94022. /**The frames per second of the animation */
  94023. framePerSecond: number,
  94024. /**The data type of the animation */
  94025. dataType: number,
  94026. /**The loop mode of the animation */
  94027. loopMode?: number | undefined,
  94028. /**Specifies if blending should be enabled */
  94029. enableBlending?: boolean | undefined);
  94030. /**
  94031. * Converts the animation to a string
  94032. * @param fullDetails support for multiple levels of logging within scene loading
  94033. * @returns String form of the animation
  94034. */
  94035. toString(fullDetails?: boolean): string;
  94036. /**
  94037. * Add an event to this animation
  94038. * @param event Event to add
  94039. */
  94040. addEvent(event: AnimationEvent): void;
  94041. /**
  94042. * Remove all events found at the given frame
  94043. * @param frame The frame to remove events from
  94044. */
  94045. removeEvents(frame: number): void;
  94046. /**
  94047. * Retrieves all the events from the animation
  94048. * @returns Events from the animation
  94049. */
  94050. getEvents(): AnimationEvent[];
  94051. /**
  94052. * Creates an animation range
  94053. * @param name Name of the animation range
  94054. * @param from Starting frame of the animation range
  94055. * @param to Ending frame of the animation
  94056. */
  94057. createRange(name: string, from: number, to: number): void;
  94058. /**
  94059. * Deletes an animation range by name
  94060. * @param name Name of the animation range to delete
  94061. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  94062. */
  94063. deleteRange(name: string, deleteFrames?: boolean): void;
  94064. /**
  94065. * Gets the animation range by name, or null if not defined
  94066. * @param name Name of the animation range
  94067. * @returns Nullable animation range
  94068. */
  94069. getRange(name: string): Nullable<AnimationRange>;
  94070. /**
  94071. * Gets the key frames from the animation
  94072. * @returns The key frames of the animation
  94073. */
  94074. getKeys(): Array<IAnimationKey>;
  94075. /**
  94076. * Gets the highest frame rate of the animation
  94077. * @returns Highest frame rate of the animation
  94078. */
  94079. getHighestFrame(): number;
  94080. /**
  94081. * Gets the easing function of the animation
  94082. * @returns Easing function of the animation
  94083. */
  94084. getEasingFunction(): IEasingFunction;
  94085. /**
  94086. * Sets the easing function of the animation
  94087. * @param easingFunction A custom mathematical formula for animation
  94088. */
  94089. setEasingFunction(easingFunction: EasingFunction): void;
  94090. /**
  94091. * Interpolates a scalar linearly
  94092. * @param startValue Start value of the animation curve
  94093. * @param endValue End value of the animation curve
  94094. * @param gradient Scalar amount to interpolate
  94095. * @returns Interpolated scalar value
  94096. */
  94097. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94098. /**
  94099. * Interpolates a scalar cubically
  94100. * @param startValue Start value of the animation curve
  94101. * @param outTangent End tangent of the animation
  94102. * @param endValue End value of the animation curve
  94103. * @param inTangent Start tangent of the animation curve
  94104. * @param gradient Scalar amount to interpolate
  94105. * @returns Interpolated scalar value
  94106. */
  94107. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94108. /**
  94109. * Interpolates a quaternion using a spherical linear interpolation
  94110. * @param startValue Start value of the animation curve
  94111. * @param endValue End value of the animation curve
  94112. * @param gradient Scalar amount to interpolate
  94113. * @returns Interpolated quaternion value
  94114. */
  94115. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94116. /**
  94117. * Interpolates a quaternion cubically
  94118. * @param startValue Start value of the animation curve
  94119. * @param outTangent End tangent of the animation curve
  94120. * @param endValue End value of the animation curve
  94121. * @param inTangent Start tangent of the animation curve
  94122. * @param gradient Scalar amount to interpolate
  94123. * @returns Interpolated quaternion value
  94124. */
  94125. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94126. /**
  94127. * Interpolates a Vector3 linearl
  94128. * @param startValue Start value of the animation curve
  94129. * @param endValue End value of the animation curve
  94130. * @param gradient Scalar amount to interpolate
  94131. * @returns Interpolated scalar value
  94132. */
  94133. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94134. /**
  94135. * Interpolates a Vector3 cubically
  94136. * @param startValue Start value of the animation curve
  94137. * @param outTangent End tangent of the animation
  94138. * @param endValue End value of the animation curve
  94139. * @param inTangent Start tangent of the animation curve
  94140. * @param gradient Scalar amount to interpolate
  94141. * @returns InterpolatedVector3 value
  94142. */
  94143. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94144. /**
  94145. * Interpolates a Vector2 linearly
  94146. * @param startValue Start value of the animation curve
  94147. * @param endValue End value of the animation curve
  94148. * @param gradient Scalar amount to interpolate
  94149. * @returns Interpolated Vector2 value
  94150. */
  94151. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94152. /**
  94153. * Interpolates a Vector2 cubically
  94154. * @param startValue Start value of the animation curve
  94155. * @param outTangent End tangent of the animation
  94156. * @param endValue End value of the animation curve
  94157. * @param inTangent Start tangent of the animation curve
  94158. * @param gradient Scalar amount to interpolate
  94159. * @returns Interpolated Vector2 value
  94160. */
  94161. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94162. /**
  94163. * Interpolates a size linearly
  94164. * @param startValue Start value of the animation curve
  94165. * @param endValue End value of the animation curve
  94166. * @param gradient Scalar amount to interpolate
  94167. * @returns Interpolated Size value
  94168. */
  94169. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94170. /**
  94171. * Interpolates a Color3 linearly
  94172. * @param startValue Start value of the animation curve
  94173. * @param endValue End value of the animation curve
  94174. * @param gradient Scalar amount to interpolate
  94175. * @returns Interpolated Color3 value
  94176. */
  94177. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94178. /**
  94179. * @hidden Internal use only
  94180. */
  94181. _getKeyValue(value: any): any;
  94182. /**
  94183. * @hidden Internal use only
  94184. */
  94185. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94186. /**
  94187. * Defines the function to use to interpolate matrices
  94188. * @param startValue defines the start matrix
  94189. * @param endValue defines the end matrix
  94190. * @param gradient defines the gradient between both matrices
  94191. * @param result defines an optional target matrix where to store the interpolation
  94192. * @returns the interpolated matrix
  94193. */
  94194. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94195. /**
  94196. * Makes a copy of the animation
  94197. * @returns Cloned animation
  94198. */
  94199. clone(): Animation;
  94200. /**
  94201. * Sets the key frames of the animation
  94202. * @param values The animation key frames to set
  94203. */
  94204. setKeys(values: Array<IAnimationKey>): void;
  94205. /**
  94206. * Serializes the animation to an object
  94207. * @returns Serialized object
  94208. */
  94209. serialize(): any;
  94210. /**
  94211. * Float animation type
  94212. */
  94213. private static _ANIMATIONTYPE_FLOAT;
  94214. /**
  94215. * Vector3 animation type
  94216. */
  94217. private static _ANIMATIONTYPE_VECTOR3;
  94218. /**
  94219. * Quaternion animation type
  94220. */
  94221. private static _ANIMATIONTYPE_QUATERNION;
  94222. /**
  94223. * Matrix animation type
  94224. */
  94225. private static _ANIMATIONTYPE_MATRIX;
  94226. /**
  94227. * Color3 animation type
  94228. */
  94229. private static _ANIMATIONTYPE_COLOR3;
  94230. /**
  94231. * Vector2 animation type
  94232. */
  94233. private static _ANIMATIONTYPE_VECTOR2;
  94234. /**
  94235. * Size animation type
  94236. */
  94237. private static _ANIMATIONTYPE_SIZE;
  94238. /**
  94239. * Relative Loop Mode
  94240. */
  94241. private static _ANIMATIONLOOPMODE_RELATIVE;
  94242. /**
  94243. * Cycle Loop Mode
  94244. */
  94245. private static _ANIMATIONLOOPMODE_CYCLE;
  94246. /**
  94247. * Constant Loop Mode
  94248. */
  94249. private static _ANIMATIONLOOPMODE_CONSTANT;
  94250. /**
  94251. * Get the float animation type
  94252. */
  94253. static readonly ANIMATIONTYPE_FLOAT: number;
  94254. /**
  94255. * Get the Vector3 animation type
  94256. */
  94257. static readonly ANIMATIONTYPE_VECTOR3: number;
  94258. /**
  94259. * Get the Vector2 animation type
  94260. */
  94261. static readonly ANIMATIONTYPE_VECTOR2: number;
  94262. /**
  94263. * Get the Size animation type
  94264. */
  94265. static readonly ANIMATIONTYPE_SIZE: number;
  94266. /**
  94267. * Get the Quaternion animation type
  94268. */
  94269. static readonly ANIMATIONTYPE_QUATERNION: number;
  94270. /**
  94271. * Get the Matrix animation type
  94272. */
  94273. static readonly ANIMATIONTYPE_MATRIX: number;
  94274. /**
  94275. * Get the Color3 animation type
  94276. */
  94277. static readonly ANIMATIONTYPE_COLOR3: number;
  94278. /**
  94279. * Get the Relative Loop Mode
  94280. */
  94281. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  94282. /**
  94283. * Get the Cycle Loop Mode
  94284. */
  94285. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  94286. /**
  94287. * Get the Constant Loop Mode
  94288. */
  94289. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  94290. /** @hidden */
  94291. static _UniversalLerp(left: any, right: any, amount: number): any;
  94292. /**
  94293. * Parses an animation object and creates an animation
  94294. * @param parsedAnimation Parsed animation object
  94295. * @returns Animation object
  94296. */
  94297. static Parse(parsedAnimation: any): Animation;
  94298. /**
  94299. * Appends the serialized animations from the source animations
  94300. * @param source Source containing the animations
  94301. * @param destination Target to store the animations
  94302. */
  94303. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94304. }
  94305. }
  94306. declare module BABYLON {
  94307. /**
  94308. * Interface containing an array of animations
  94309. */
  94310. export interface IAnimatable {
  94311. /**
  94312. * Array of animations
  94313. */
  94314. animations: Nullable<Array<Animation>>;
  94315. }
  94316. }
  94317. declare module BABYLON {
  94318. /**
  94319. * This represents all the required information to add a fresnel effect on a material:
  94320. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94321. */
  94322. export class FresnelParameters {
  94323. private _isEnabled;
  94324. /**
  94325. * Define if the fresnel effect is enable or not.
  94326. */
  94327. isEnabled: boolean;
  94328. /**
  94329. * Define the color used on edges (grazing angle)
  94330. */
  94331. leftColor: Color3;
  94332. /**
  94333. * Define the color used on center
  94334. */
  94335. rightColor: Color3;
  94336. /**
  94337. * Define bias applied to computed fresnel term
  94338. */
  94339. bias: number;
  94340. /**
  94341. * Defined the power exponent applied to fresnel term
  94342. */
  94343. power: number;
  94344. /**
  94345. * Clones the current fresnel and its valuues
  94346. * @returns a clone fresnel configuration
  94347. */
  94348. clone(): FresnelParameters;
  94349. /**
  94350. * Serializes the current fresnel parameters to a JSON representation.
  94351. * @return the JSON serialization
  94352. */
  94353. serialize(): any;
  94354. /**
  94355. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94356. * @param parsedFresnelParameters Define the JSON representation
  94357. * @returns the parsed parameters
  94358. */
  94359. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94360. }
  94361. }
  94362. declare module BABYLON {
  94363. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  94364. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94365. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94366. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94367. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94368. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94369. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94370. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94371. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94372. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94373. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94374. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94375. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94376. /**
  94377. * Decorator used to define property that can be serialized as reference to a camera
  94378. * @param sourceName defines the name of the property to decorate
  94379. */
  94380. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94381. /**
  94382. * Class used to help serialization objects
  94383. */
  94384. export class SerializationHelper {
  94385. /** @hidden */
  94386. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  94387. /** @hidden */
  94388. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  94389. /** @hidden */
  94390. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  94391. /** @hidden */
  94392. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  94393. /**
  94394. * Appends the serialized animations from the source animations
  94395. * @param source Source containing the animations
  94396. * @param destination Target to store the animations
  94397. */
  94398. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94399. /**
  94400. * Static function used to serialized a specific entity
  94401. * @param entity defines the entity to serialize
  94402. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  94403. * @returns a JSON compatible object representing the serialization of the entity
  94404. */
  94405. static Serialize<T>(entity: T, serializationObject?: any): any;
  94406. /**
  94407. * Creates a new entity from a serialization data object
  94408. * @param creationFunction defines a function used to instanciated the new entity
  94409. * @param source defines the source serialization data
  94410. * @param scene defines the hosting scene
  94411. * @param rootUrl defines the root url for resources
  94412. * @returns a new entity
  94413. */
  94414. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  94415. /**
  94416. * Clones an object
  94417. * @param creationFunction defines the function used to instanciate the new object
  94418. * @param source defines the source object
  94419. * @returns the cloned object
  94420. */
  94421. static Clone<T>(creationFunction: () => T, source: T): T;
  94422. /**
  94423. * Instanciates a new object based on a source one (some data will be shared between both object)
  94424. * @param creationFunction defines the function used to instanciate the new object
  94425. * @param source defines the source object
  94426. * @returns the new object
  94427. */
  94428. static Instanciate<T>(creationFunction: () => T, source: T): T;
  94429. }
  94430. }
  94431. declare module BABYLON {
  94432. /**
  94433. * Class used to manipulate GUIDs
  94434. */
  94435. export class GUID {
  94436. /**
  94437. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94438. * Be aware Math.random() could cause collisions, but:
  94439. * "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"
  94440. * @returns a pseudo random id
  94441. */
  94442. static RandomId(): string;
  94443. }
  94444. }
  94445. declare module BABYLON {
  94446. /**
  94447. * Base class of all the textures in babylon.
  94448. * It groups all the common properties the materials, post process, lights... might need
  94449. * in order to make a correct use of the texture.
  94450. */
  94451. export class BaseTexture implements IAnimatable {
  94452. /**
  94453. * Default anisotropic filtering level for the application.
  94454. * It is set to 4 as a good tradeoff between perf and quality.
  94455. */
  94456. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  94457. /**
  94458. * Gets or sets the unique id of the texture
  94459. */
  94460. uniqueId: number;
  94461. /**
  94462. * Define the name of the texture.
  94463. */
  94464. name: string;
  94465. /**
  94466. * Gets or sets an object used to store user defined information.
  94467. */
  94468. metadata: any;
  94469. /**
  94470. * For internal use only. Please do not use.
  94471. */
  94472. reservedDataStore: any;
  94473. private _hasAlpha;
  94474. /**
  94475. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  94476. */
  94477. hasAlpha: boolean;
  94478. /**
  94479. * Defines if the alpha value should be determined via the rgb values.
  94480. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  94481. */
  94482. getAlphaFromRGB: boolean;
  94483. /**
  94484. * Intensity or strength of the texture.
  94485. * It is commonly used by materials to fine tune the intensity of the texture
  94486. */
  94487. level: number;
  94488. /**
  94489. * Define the UV chanel to use starting from 0 and defaulting to 0.
  94490. * This is part of the texture as textures usually maps to one uv set.
  94491. */
  94492. coordinatesIndex: number;
  94493. private _coordinatesMode;
  94494. /**
  94495. * How a texture is mapped.
  94496. *
  94497. * | Value | Type | Description |
  94498. * | ----- | ----------------------------------- | ----------- |
  94499. * | 0 | EXPLICIT_MODE | |
  94500. * | 1 | SPHERICAL_MODE | |
  94501. * | 2 | PLANAR_MODE | |
  94502. * | 3 | CUBIC_MODE | |
  94503. * | 4 | PROJECTION_MODE | |
  94504. * | 5 | SKYBOX_MODE | |
  94505. * | 6 | INVCUBIC_MODE | |
  94506. * | 7 | EQUIRECTANGULAR_MODE | |
  94507. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  94508. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  94509. */
  94510. coordinatesMode: number;
  94511. /**
  94512. * | Value | Type | Description |
  94513. * | ----- | ------------------ | ----------- |
  94514. * | 0 | CLAMP_ADDRESSMODE | |
  94515. * | 1 | WRAP_ADDRESSMODE | |
  94516. * | 2 | MIRROR_ADDRESSMODE | |
  94517. */
  94518. wrapU: number;
  94519. /**
  94520. * | Value | Type | Description |
  94521. * | ----- | ------------------ | ----------- |
  94522. * | 0 | CLAMP_ADDRESSMODE | |
  94523. * | 1 | WRAP_ADDRESSMODE | |
  94524. * | 2 | MIRROR_ADDRESSMODE | |
  94525. */
  94526. wrapV: number;
  94527. /**
  94528. * | Value | Type | Description |
  94529. * | ----- | ------------------ | ----------- |
  94530. * | 0 | CLAMP_ADDRESSMODE | |
  94531. * | 1 | WRAP_ADDRESSMODE | |
  94532. * | 2 | MIRROR_ADDRESSMODE | |
  94533. */
  94534. wrapR: number;
  94535. /**
  94536. * With compliant hardware and browser (supporting anisotropic filtering)
  94537. * this defines the level of anisotropic filtering in the texture.
  94538. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  94539. */
  94540. anisotropicFilteringLevel: number;
  94541. /**
  94542. * Define if the texture is a cube texture or if false a 2d texture.
  94543. */
  94544. isCube: boolean;
  94545. /**
  94546. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  94547. */
  94548. is3D: boolean;
  94549. /**
  94550. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  94551. * HDR texture are usually stored in linear space.
  94552. * This only impacts the PBR and Background materials
  94553. */
  94554. gammaSpace: boolean;
  94555. /**
  94556. * Gets or sets whether or not the texture contains RGBD data.
  94557. */
  94558. isRGBD: boolean;
  94559. /**
  94560. * Is Z inverted in the texture (useful in a cube texture).
  94561. */
  94562. invertZ: boolean;
  94563. /**
  94564. * Are mip maps generated for this texture or not.
  94565. */
  94566. readonly noMipmap: boolean;
  94567. /**
  94568. * @hidden
  94569. */
  94570. lodLevelInAlpha: boolean;
  94571. /**
  94572. * With prefiltered texture, defined the offset used during the prefiltering steps.
  94573. */
  94574. lodGenerationOffset: number;
  94575. /**
  94576. * With prefiltered texture, defined the scale used during the prefiltering steps.
  94577. */
  94578. lodGenerationScale: number;
  94579. /**
  94580. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  94581. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  94582. * average roughness values.
  94583. */
  94584. linearSpecularLOD: boolean;
  94585. /**
  94586. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  94587. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  94588. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  94589. */
  94590. irradianceTexture: Nullable<BaseTexture>;
  94591. /**
  94592. * Define if the texture is a render target.
  94593. */
  94594. isRenderTarget: boolean;
  94595. /**
  94596. * Define the unique id of the texture in the scene.
  94597. */
  94598. readonly uid: string;
  94599. /**
  94600. * Return a string representation of the texture.
  94601. * @returns the texture as a string
  94602. */
  94603. toString(): string;
  94604. /**
  94605. * Get the class name of the texture.
  94606. * @returns "BaseTexture"
  94607. */
  94608. getClassName(): string;
  94609. /**
  94610. * Define the list of animation attached to the texture.
  94611. */
  94612. animations: Animation[];
  94613. /**
  94614. * An event triggered when the texture is disposed.
  94615. */
  94616. onDisposeObservable: Observable<BaseTexture>;
  94617. private _onDisposeObserver;
  94618. /**
  94619. * Callback triggered when the texture has been disposed.
  94620. * Kept for back compatibility, you can use the onDisposeObservable instead.
  94621. */
  94622. onDispose: () => void;
  94623. /**
  94624. * Define the current state of the loading sequence when in delayed load mode.
  94625. */
  94626. delayLoadState: number;
  94627. private _scene;
  94628. /** @hidden */
  94629. _texture: Nullable<InternalTexture>;
  94630. private _uid;
  94631. /**
  94632. * Define if the texture is preventinga material to render or not.
  94633. * If not and the texture is not ready, the engine will use a default black texture instead.
  94634. */
  94635. readonly isBlocking: boolean;
  94636. /**
  94637. * Instantiates a new BaseTexture.
  94638. * Base class of all the textures in babylon.
  94639. * It groups all the common properties the materials, post process, lights... might need
  94640. * in order to make a correct use of the texture.
  94641. * @param scene Define the scene the texture blongs to
  94642. */
  94643. constructor(scene: Nullable<Scene>);
  94644. /**
  94645. * Get the scene the texture belongs to.
  94646. * @returns the scene or null if undefined
  94647. */
  94648. getScene(): Nullable<Scene>;
  94649. /**
  94650. * Get the texture transform matrix used to offset tile the texture for istance.
  94651. * @returns the transformation matrix
  94652. */
  94653. getTextureMatrix(): Matrix;
  94654. /**
  94655. * Get the texture reflection matrix used to rotate/transform the reflection.
  94656. * @returns the reflection matrix
  94657. */
  94658. getReflectionTextureMatrix(): Matrix;
  94659. /**
  94660. * Get the underlying lower level texture from Babylon.
  94661. * @returns the insternal texture
  94662. */
  94663. getInternalTexture(): Nullable<InternalTexture>;
  94664. /**
  94665. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  94666. * @returns true if ready or not blocking
  94667. */
  94668. isReadyOrNotBlocking(): boolean;
  94669. /**
  94670. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  94671. * @returns true if fully ready
  94672. */
  94673. isReady(): boolean;
  94674. private _cachedSize;
  94675. /**
  94676. * Get the size of the texture.
  94677. * @returns the texture size.
  94678. */
  94679. getSize(): ISize;
  94680. /**
  94681. * Get the base size of the texture.
  94682. * It can be different from the size if the texture has been resized for POT for instance
  94683. * @returns the base size
  94684. */
  94685. getBaseSize(): ISize;
  94686. /**
  94687. * Update the sampling mode of the texture.
  94688. * Default is Trilinear mode.
  94689. *
  94690. * | Value | Type | Description |
  94691. * | ----- | ------------------ | ----------- |
  94692. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  94693. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  94694. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  94695. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  94696. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  94697. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  94698. * | 7 | NEAREST_LINEAR | |
  94699. * | 8 | NEAREST_NEAREST | |
  94700. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  94701. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  94702. * | 11 | LINEAR_LINEAR | |
  94703. * | 12 | LINEAR_NEAREST | |
  94704. *
  94705. * > _mag_: magnification filter (close to the viewer)
  94706. * > _min_: minification filter (far from the viewer)
  94707. * > _mip_: filter used between mip map levels
  94708. *@param samplingMode Define the new sampling mode of the texture
  94709. */
  94710. updateSamplingMode(samplingMode: number): void;
  94711. /**
  94712. * Scales the texture if is `canRescale()`
  94713. * @param ratio the resize factor we want to use to rescale
  94714. */
  94715. scale(ratio: number): void;
  94716. /**
  94717. * Get if the texture can rescale.
  94718. */
  94719. readonly canRescale: boolean;
  94720. /** @hidden */
  94721. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  94722. /** @hidden */
  94723. _rebuild(): void;
  94724. /**
  94725. * Triggers the load sequence in delayed load mode.
  94726. */
  94727. delayLoad(): void;
  94728. /**
  94729. * Clones the texture.
  94730. * @returns the cloned texture
  94731. */
  94732. clone(): Nullable<BaseTexture>;
  94733. /**
  94734. * Get the texture underlying type (INT, FLOAT...)
  94735. */
  94736. readonly textureType: number;
  94737. /**
  94738. * Get the texture underlying format (RGB, RGBA...)
  94739. */
  94740. readonly textureFormat: number;
  94741. /**
  94742. * Indicates that textures need to be re-calculated for all materials
  94743. */
  94744. protected _markAllSubMeshesAsTexturesDirty(): void;
  94745. /**
  94746. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  94747. * This will returns an RGBA array buffer containing either in values (0-255) or
  94748. * float values (0-1) depending of the underlying buffer type.
  94749. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  94750. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  94751. * @param buffer defines a user defined buffer to fill with data (can be null)
  94752. * @returns The Array buffer containing the pixels data.
  94753. */
  94754. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  94755. /**
  94756. * Release and destroy the underlying lower level texture aka internalTexture.
  94757. */
  94758. releaseInternalTexture(): void;
  94759. /** @hidden */
  94760. readonly _lodTextureHigh: Nullable<BaseTexture>;
  94761. /** @hidden */
  94762. readonly _lodTextureMid: Nullable<BaseTexture>;
  94763. /** @hidden */
  94764. readonly _lodTextureLow: Nullable<BaseTexture>;
  94765. /**
  94766. * Dispose the texture and release its associated resources.
  94767. */
  94768. dispose(): void;
  94769. /**
  94770. * Serialize the texture into a JSON representation that can be parsed later on.
  94771. * @returns the JSON representation of the texture
  94772. */
  94773. serialize(): any;
  94774. /**
  94775. * Helper function to be called back once a list of texture contains only ready textures.
  94776. * @param textures Define the list of textures to wait for
  94777. * @param callback Define the callback triggered once the entire list will be ready
  94778. */
  94779. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  94780. }
  94781. }
  94782. declare module BABYLON {
  94783. /**
  94784. * Options to be used when creating an effect.
  94785. */
  94786. export interface IEffectCreationOptions {
  94787. /**
  94788. * Atrributes that will be used in the shader.
  94789. */
  94790. attributes: string[];
  94791. /**
  94792. * Uniform varible names that will be set in the shader.
  94793. */
  94794. uniformsNames: string[];
  94795. /**
  94796. * Uniform buffer varible names that will be set in the shader.
  94797. */
  94798. uniformBuffersNames: string[];
  94799. /**
  94800. * Sampler texture variable names that will be set in the shader.
  94801. */
  94802. samplers: string[];
  94803. /**
  94804. * Define statements that will be set in the shader.
  94805. */
  94806. defines: any;
  94807. /**
  94808. * Possible fallbacks for this effect to improve performance when needed.
  94809. */
  94810. fallbacks: Nullable<IEffectFallbacks>;
  94811. /**
  94812. * Callback that will be called when the shader is compiled.
  94813. */
  94814. onCompiled: Nullable<(effect: Effect) => void>;
  94815. /**
  94816. * Callback that will be called if an error occurs during shader compilation.
  94817. */
  94818. onError: Nullable<(effect: Effect, errors: string) => void>;
  94819. /**
  94820. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94821. */
  94822. indexParameters?: any;
  94823. /**
  94824. * Max number of lights that can be used in the shader.
  94825. */
  94826. maxSimultaneousLights?: number;
  94827. /**
  94828. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94829. */
  94830. transformFeedbackVaryings?: Nullable<string[]>;
  94831. }
  94832. /**
  94833. * Effect containing vertex and fragment shader that can be executed on an object.
  94834. */
  94835. export class Effect implements IDisposable {
  94836. /**
  94837. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94838. */
  94839. static ShadersRepository: string;
  94840. /**
  94841. * Name of the effect.
  94842. */
  94843. name: any;
  94844. /**
  94845. * String container all the define statements that should be set on the shader.
  94846. */
  94847. defines: string;
  94848. /**
  94849. * Callback that will be called when the shader is compiled.
  94850. */
  94851. onCompiled: Nullable<(effect: Effect) => void>;
  94852. /**
  94853. * Callback that will be called if an error occurs during shader compilation.
  94854. */
  94855. onError: Nullable<(effect: Effect, errors: string) => void>;
  94856. /**
  94857. * Callback that will be called when effect is bound.
  94858. */
  94859. onBind: Nullable<(effect: Effect) => void>;
  94860. /**
  94861. * Unique ID of the effect.
  94862. */
  94863. uniqueId: number;
  94864. /**
  94865. * Observable that will be called when the shader is compiled.
  94866. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94867. */
  94868. onCompileObservable: Observable<Effect>;
  94869. /**
  94870. * Observable that will be called if an error occurs during shader compilation.
  94871. */
  94872. onErrorObservable: Observable<Effect>;
  94873. /** @hidden */
  94874. _onBindObservable: Nullable<Observable<Effect>>;
  94875. /**
  94876. * Observable that will be called when effect is bound.
  94877. */
  94878. readonly onBindObservable: Observable<Effect>;
  94879. /** @hidden */
  94880. _bonesComputationForcedToCPU: boolean;
  94881. private static _uniqueIdSeed;
  94882. private _engine;
  94883. private _uniformBuffersNames;
  94884. private _uniformsNames;
  94885. private _samplerList;
  94886. private _samplers;
  94887. private _isReady;
  94888. private _compilationError;
  94889. private _allFallbacksProcessed;
  94890. private _attributesNames;
  94891. private _attributes;
  94892. private _uniforms;
  94893. /**
  94894. * Key for the effect.
  94895. * @hidden
  94896. */
  94897. _key: string;
  94898. private _indexParameters;
  94899. private _fallbacks;
  94900. private _vertexSourceCode;
  94901. private _fragmentSourceCode;
  94902. private _vertexSourceCodeOverride;
  94903. private _fragmentSourceCodeOverride;
  94904. private _transformFeedbackVaryings;
  94905. /**
  94906. * Compiled shader to webGL program.
  94907. * @hidden
  94908. */
  94909. _pipelineContext: Nullable<IPipelineContext>;
  94910. private _valueCache;
  94911. private static _baseCache;
  94912. /**
  94913. * Instantiates an effect.
  94914. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94915. * @param baseName Name of the effect.
  94916. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94917. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94918. * @param samplers List of sampler variables that will be passed to the shader.
  94919. * @param engine Engine to be used to render the effect
  94920. * @param defines Define statements to be added to the shader.
  94921. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94922. * @param onCompiled Callback that will be called when the shader is compiled.
  94923. * @param onError Callback that will be called if an error occurs during shader compilation.
  94924. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94925. */
  94926. 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);
  94927. private _useFinalCode;
  94928. /**
  94929. * Unique key for this effect
  94930. */
  94931. readonly key: string;
  94932. /**
  94933. * If the effect has been compiled and prepared.
  94934. * @returns if the effect is compiled and prepared.
  94935. */
  94936. isReady(): boolean;
  94937. private _isReadyInternal;
  94938. /**
  94939. * The engine the effect was initialized with.
  94940. * @returns the engine.
  94941. */
  94942. getEngine(): Engine;
  94943. /**
  94944. * The pipeline context for this effect
  94945. * @returns the associated pipeline context
  94946. */
  94947. getPipelineContext(): Nullable<IPipelineContext>;
  94948. /**
  94949. * The set of names of attribute variables for the shader.
  94950. * @returns An array of attribute names.
  94951. */
  94952. getAttributesNames(): string[];
  94953. /**
  94954. * Returns the attribute at the given index.
  94955. * @param index The index of the attribute.
  94956. * @returns The location of the attribute.
  94957. */
  94958. getAttributeLocation(index: number): number;
  94959. /**
  94960. * Returns the attribute based on the name of the variable.
  94961. * @param name of the attribute to look up.
  94962. * @returns the attribute location.
  94963. */
  94964. getAttributeLocationByName(name: string): number;
  94965. /**
  94966. * The number of attributes.
  94967. * @returns the numnber of attributes.
  94968. */
  94969. getAttributesCount(): number;
  94970. /**
  94971. * Gets the index of a uniform variable.
  94972. * @param uniformName of the uniform to look up.
  94973. * @returns the index.
  94974. */
  94975. getUniformIndex(uniformName: string): number;
  94976. /**
  94977. * Returns the attribute based on the name of the variable.
  94978. * @param uniformName of the uniform to look up.
  94979. * @returns the location of the uniform.
  94980. */
  94981. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94982. /**
  94983. * Returns an array of sampler variable names
  94984. * @returns The array of sampler variable neames.
  94985. */
  94986. getSamplers(): string[];
  94987. /**
  94988. * The error from the last compilation.
  94989. * @returns the error string.
  94990. */
  94991. getCompilationError(): string;
  94992. /**
  94993. * Gets a boolean indicating that all fallbacks were used during compilation
  94994. * @returns true if all fallbacks were used
  94995. */
  94996. allFallbacksProcessed(): boolean;
  94997. /**
  94998. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  94999. * @param func The callback to be used.
  95000. */
  95001. executeWhenCompiled(func: (effect: Effect) => void): void;
  95002. private _checkIsReady;
  95003. private _loadShader;
  95004. /**
  95005. * Recompiles the webGL program
  95006. * @param vertexSourceCode The source code for the vertex shader.
  95007. * @param fragmentSourceCode The source code for the fragment shader.
  95008. * @param onCompiled Callback called when completed.
  95009. * @param onError Callback called on error.
  95010. * @hidden
  95011. */
  95012. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  95013. /**
  95014. * Prepares the effect
  95015. * @hidden
  95016. */
  95017. _prepareEffect(): void;
  95018. private _processCompilationErrors;
  95019. /**
  95020. * Checks if the effect is supported. (Must be called after compilation)
  95021. */
  95022. readonly isSupported: boolean;
  95023. /**
  95024. * Binds a texture to the engine to be used as output of the shader.
  95025. * @param channel Name of the output variable.
  95026. * @param texture Texture to bind.
  95027. * @hidden
  95028. */
  95029. _bindTexture(channel: string, texture: InternalTexture): void;
  95030. /**
  95031. * Sets a texture on the engine to be used in the shader.
  95032. * @param channel Name of the sampler variable.
  95033. * @param texture Texture to set.
  95034. */
  95035. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95036. /**
  95037. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95038. * @param channel Name of the sampler variable.
  95039. * @param texture Texture to set.
  95040. */
  95041. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95042. /**
  95043. * Sets an array of textures on the engine to be used in the shader.
  95044. * @param channel Name of the variable.
  95045. * @param textures Textures to set.
  95046. */
  95047. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95048. /**
  95049. * 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)
  95050. * @param channel Name of the sampler variable.
  95051. * @param postProcess Post process to get the input texture from.
  95052. */
  95053. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95054. /**
  95055. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95056. * 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)
  95057. * @param channel Name of the sampler variable.
  95058. * @param postProcess Post process to get the output texture from.
  95059. */
  95060. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95061. /** @hidden */
  95062. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95063. /** @hidden */
  95064. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95065. /** @hidden */
  95066. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95067. /** @hidden */
  95068. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95069. /**
  95070. * Binds a buffer to a uniform.
  95071. * @param buffer Buffer to bind.
  95072. * @param name Name of the uniform variable to bind to.
  95073. */
  95074. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95075. /**
  95076. * Binds block to a uniform.
  95077. * @param blockName Name of the block to bind.
  95078. * @param index Index to bind.
  95079. */
  95080. bindUniformBlock(blockName: string, index: number): void;
  95081. /**
  95082. * Sets an interger value on a uniform variable.
  95083. * @param uniformName Name of the variable.
  95084. * @param value Value to be set.
  95085. * @returns this effect.
  95086. */
  95087. setInt(uniformName: string, value: number): Effect;
  95088. /**
  95089. * Sets an int array on a uniform variable.
  95090. * @param uniformName Name of the variable.
  95091. * @param array array to be set.
  95092. * @returns this effect.
  95093. */
  95094. setIntArray(uniformName: string, array: Int32Array): Effect;
  95095. /**
  95096. * 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)
  95097. * @param uniformName Name of the variable.
  95098. * @param array array to be set.
  95099. * @returns this effect.
  95100. */
  95101. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95102. /**
  95103. * 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)
  95104. * @param uniformName Name of the variable.
  95105. * @param array array to be set.
  95106. * @returns this effect.
  95107. */
  95108. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95109. /**
  95110. * 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)
  95111. * @param uniformName Name of the variable.
  95112. * @param array array to be set.
  95113. * @returns this effect.
  95114. */
  95115. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95116. /**
  95117. * Sets an float array on a uniform variable.
  95118. * @param uniformName Name of the variable.
  95119. * @param array array to be set.
  95120. * @returns this effect.
  95121. */
  95122. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95123. /**
  95124. * 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)
  95125. * @param uniformName Name of the variable.
  95126. * @param array array to be set.
  95127. * @returns this effect.
  95128. */
  95129. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95130. /**
  95131. * 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)
  95132. * @param uniformName Name of the variable.
  95133. * @param array array to be set.
  95134. * @returns this effect.
  95135. */
  95136. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95137. /**
  95138. * 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)
  95139. * @param uniformName Name of the variable.
  95140. * @param array array to be set.
  95141. * @returns this effect.
  95142. */
  95143. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95144. /**
  95145. * Sets an array on a uniform variable.
  95146. * @param uniformName Name of the variable.
  95147. * @param array array to be set.
  95148. * @returns this effect.
  95149. */
  95150. setArray(uniformName: string, array: number[]): Effect;
  95151. /**
  95152. * 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)
  95153. * @param uniformName Name of the variable.
  95154. * @param array array to be set.
  95155. * @returns this effect.
  95156. */
  95157. setArray2(uniformName: string, array: number[]): Effect;
  95158. /**
  95159. * 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)
  95160. * @param uniformName Name of the variable.
  95161. * @param array array to be set.
  95162. * @returns this effect.
  95163. */
  95164. setArray3(uniformName: string, array: number[]): Effect;
  95165. /**
  95166. * 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)
  95167. * @param uniformName Name of the variable.
  95168. * @param array array to be set.
  95169. * @returns this effect.
  95170. */
  95171. setArray4(uniformName: string, array: number[]): Effect;
  95172. /**
  95173. * Sets matrices on a uniform variable.
  95174. * @param uniformName Name of the variable.
  95175. * @param matrices matrices to be set.
  95176. * @returns this effect.
  95177. */
  95178. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95179. /**
  95180. * Sets matrix on a uniform variable.
  95181. * @param uniformName Name of the variable.
  95182. * @param matrix matrix to be set.
  95183. * @returns this effect.
  95184. */
  95185. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95186. /**
  95187. * 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)
  95188. * @param uniformName Name of the variable.
  95189. * @param matrix matrix to be set.
  95190. * @returns this effect.
  95191. */
  95192. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95193. /**
  95194. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95195. * @param uniformName Name of the variable.
  95196. * @param matrix matrix to be set.
  95197. * @returns this effect.
  95198. */
  95199. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95200. /**
  95201. * Sets a float on a uniform variable.
  95202. * @param uniformName Name of the variable.
  95203. * @param value value to be set.
  95204. * @returns this effect.
  95205. */
  95206. setFloat(uniformName: string, value: number): Effect;
  95207. /**
  95208. * Sets a boolean on a uniform variable.
  95209. * @param uniformName Name of the variable.
  95210. * @param bool value to be set.
  95211. * @returns this effect.
  95212. */
  95213. setBool(uniformName: string, bool: boolean): Effect;
  95214. /**
  95215. * Sets a Vector2 on a uniform variable.
  95216. * @param uniformName Name of the variable.
  95217. * @param vector2 vector2 to be set.
  95218. * @returns this effect.
  95219. */
  95220. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95221. /**
  95222. * Sets a float2 on a uniform variable.
  95223. * @param uniformName Name of the variable.
  95224. * @param x First float in float2.
  95225. * @param y Second float in float2.
  95226. * @returns this effect.
  95227. */
  95228. setFloat2(uniformName: string, x: number, y: number): Effect;
  95229. /**
  95230. * Sets a Vector3 on a uniform variable.
  95231. * @param uniformName Name of the variable.
  95232. * @param vector3 Value to be set.
  95233. * @returns this effect.
  95234. */
  95235. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95236. /**
  95237. * Sets a float3 on a uniform variable.
  95238. * @param uniformName Name of the variable.
  95239. * @param x First float in float3.
  95240. * @param y Second float in float3.
  95241. * @param z Third float in float3.
  95242. * @returns this effect.
  95243. */
  95244. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95245. /**
  95246. * Sets a Vector4 on a uniform variable.
  95247. * @param uniformName Name of the variable.
  95248. * @param vector4 Value to be set.
  95249. * @returns this effect.
  95250. */
  95251. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95252. /**
  95253. * Sets a float4 on a uniform variable.
  95254. * @param uniformName Name of the variable.
  95255. * @param x First float in float4.
  95256. * @param y Second float in float4.
  95257. * @param z Third float in float4.
  95258. * @param w Fourth float in float4.
  95259. * @returns this effect.
  95260. */
  95261. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95262. /**
  95263. * Sets a Color3 on a uniform variable.
  95264. * @param uniformName Name of the variable.
  95265. * @param color3 Value to be set.
  95266. * @returns this effect.
  95267. */
  95268. setColor3(uniformName: string, color3: IColor3Like): Effect;
  95269. /**
  95270. * Sets a Color4 on a uniform variable.
  95271. * @param uniformName Name of the variable.
  95272. * @param color3 Value to be set.
  95273. * @param alpha Alpha value to be set.
  95274. * @returns this effect.
  95275. */
  95276. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  95277. /**
  95278. * Sets a Color4 on a uniform variable
  95279. * @param uniformName defines the name of the variable
  95280. * @param color4 defines the value to be set
  95281. * @returns this effect.
  95282. */
  95283. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  95284. /** Release all associated resources */
  95285. dispose(): void;
  95286. /**
  95287. * This function will add a new shader to the shader store
  95288. * @param name the name of the shader
  95289. * @param pixelShader optional pixel shader content
  95290. * @param vertexShader optional vertex shader content
  95291. */
  95292. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  95293. /**
  95294. * Store of each shader (The can be looked up using effect.key)
  95295. */
  95296. static ShadersStore: {
  95297. [key: string]: string;
  95298. };
  95299. /**
  95300. * Store of each included file for a shader (The can be looked up using effect.key)
  95301. */
  95302. static IncludesShadersStore: {
  95303. [key: string]: string;
  95304. };
  95305. /**
  95306. * Resets the cache of effects.
  95307. */
  95308. static ResetCache(): void;
  95309. }
  95310. }
  95311. declare module BABYLON {
  95312. /**
  95313. * Class used to describe the capabilities of the engine relatively to the current browser
  95314. */
  95315. export class EngineCapabilities {
  95316. /** Maximum textures units per fragment shader */
  95317. maxTexturesImageUnits: number;
  95318. /** Maximum texture units per vertex shader */
  95319. maxVertexTextureImageUnits: number;
  95320. /** Maximum textures units in the entire pipeline */
  95321. maxCombinedTexturesImageUnits: number;
  95322. /** Maximum texture size */
  95323. maxTextureSize: number;
  95324. /** Maximum cube texture size */
  95325. maxCubemapTextureSize: number;
  95326. /** Maximum render texture size */
  95327. maxRenderTextureSize: number;
  95328. /** Maximum number of vertex attributes */
  95329. maxVertexAttribs: number;
  95330. /** Maximum number of varyings */
  95331. maxVaryingVectors: number;
  95332. /** Maximum number of uniforms per vertex shader */
  95333. maxVertexUniformVectors: number;
  95334. /** Maximum number of uniforms per fragment shader */
  95335. maxFragmentUniformVectors: number;
  95336. /** Defines if standard derivates (dx/dy) are supported */
  95337. standardDerivatives: boolean;
  95338. /** Defines if s3tc texture compression is supported */
  95339. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95340. /** Defines if pvrtc texture compression is supported */
  95341. pvrtc: any;
  95342. /** Defines if etc1 texture compression is supported */
  95343. etc1: any;
  95344. /** Defines if etc2 texture compression is supported */
  95345. etc2: any;
  95346. /** Defines if astc texture compression is supported */
  95347. astc: any;
  95348. /** Defines if float textures are supported */
  95349. textureFloat: boolean;
  95350. /** Defines if vertex array objects are supported */
  95351. vertexArrayObject: boolean;
  95352. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95353. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95354. /** Gets the maximum level of anisotropy supported */
  95355. maxAnisotropy: number;
  95356. /** Defines if instancing is supported */
  95357. instancedArrays: boolean;
  95358. /** Defines if 32 bits indices are supported */
  95359. uintIndices: boolean;
  95360. /** Defines if high precision shaders are supported */
  95361. highPrecisionShaderSupported: boolean;
  95362. /** Defines if depth reading in the fragment shader is supported */
  95363. fragmentDepthSupported: boolean;
  95364. /** Defines if float texture linear filtering is supported*/
  95365. textureFloatLinearFiltering: boolean;
  95366. /** Defines if rendering to float textures is supported */
  95367. textureFloatRender: boolean;
  95368. /** Defines if half float textures are supported*/
  95369. textureHalfFloat: boolean;
  95370. /** Defines if half float texture linear filtering is supported*/
  95371. textureHalfFloatLinearFiltering: boolean;
  95372. /** Defines if rendering to half float textures is supported */
  95373. textureHalfFloatRender: boolean;
  95374. /** Defines if textureLOD shader command is supported */
  95375. textureLOD: boolean;
  95376. /** Defines if draw buffers extension is supported */
  95377. drawBuffersExtension: boolean;
  95378. /** Defines if depth textures are supported */
  95379. depthTextureExtension: boolean;
  95380. /** Defines if float color buffer are supported */
  95381. colorBufferFloat: boolean;
  95382. /** Gets disjoint timer query extension (null if not supported) */
  95383. timerQuery: EXT_disjoint_timer_query;
  95384. /** Defines if timestamp can be used with timer query */
  95385. canUseTimestampForTimerQuery: boolean;
  95386. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95387. multiview: any;
  95388. /** Function used to let the system compiles shaders in background */
  95389. parallelShaderCompile: {
  95390. COMPLETION_STATUS_KHR: number;
  95391. };
  95392. /** Max number of texture samples for MSAA */
  95393. maxMSAASamples: number;
  95394. /** Defines if the blend min max extension is supported */
  95395. blendMinMax: boolean;
  95396. }
  95397. }
  95398. declare module BABYLON {
  95399. /**
  95400. * @hidden
  95401. **/
  95402. export class DepthCullingState {
  95403. private _isDepthTestDirty;
  95404. private _isDepthMaskDirty;
  95405. private _isDepthFuncDirty;
  95406. private _isCullFaceDirty;
  95407. private _isCullDirty;
  95408. private _isZOffsetDirty;
  95409. private _isFrontFaceDirty;
  95410. private _depthTest;
  95411. private _depthMask;
  95412. private _depthFunc;
  95413. private _cull;
  95414. private _cullFace;
  95415. private _zOffset;
  95416. private _frontFace;
  95417. /**
  95418. * Initializes the state.
  95419. */
  95420. constructor();
  95421. readonly isDirty: boolean;
  95422. zOffset: number;
  95423. cullFace: Nullable<number>;
  95424. cull: Nullable<boolean>;
  95425. depthFunc: Nullable<number>;
  95426. depthMask: boolean;
  95427. depthTest: boolean;
  95428. frontFace: Nullable<number>;
  95429. reset(): void;
  95430. apply(gl: WebGLRenderingContext): void;
  95431. }
  95432. }
  95433. declare module BABYLON {
  95434. /**
  95435. * @hidden
  95436. **/
  95437. export class StencilState {
  95438. /** 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 */
  95439. static readonly ALWAYS: number;
  95440. /** Passed to stencilOperation to specify that stencil value must be kept */
  95441. static readonly KEEP: number;
  95442. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95443. static readonly REPLACE: number;
  95444. private _isStencilTestDirty;
  95445. private _isStencilMaskDirty;
  95446. private _isStencilFuncDirty;
  95447. private _isStencilOpDirty;
  95448. private _stencilTest;
  95449. private _stencilMask;
  95450. private _stencilFunc;
  95451. private _stencilFuncRef;
  95452. private _stencilFuncMask;
  95453. private _stencilOpStencilFail;
  95454. private _stencilOpDepthFail;
  95455. private _stencilOpStencilDepthPass;
  95456. readonly isDirty: boolean;
  95457. stencilFunc: number;
  95458. stencilFuncRef: number;
  95459. stencilFuncMask: number;
  95460. stencilOpStencilFail: number;
  95461. stencilOpDepthFail: number;
  95462. stencilOpStencilDepthPass: number;
  95463. stencilMask: number;
  95464. stencilTest: boolean;
  95465. constructor();
  95466. reset(): void;
  95467. apply(gl: WebGLRenderingContext): void;
  95468. }
  95469. }
  95470. declare module BABYLON {
  95471. /**
  95472. * @hidden
  95473. **/
  95474. export class AlphaState {
  95475. private _isAlphaBlendDirty;
  95476. private _isBlendFunctionParametersDirty;
  95477. private _isBlendEquationParametersDirty;
  95478. private _isBlendConstantsDirty;
  95479. private _alphaBlend;
  95480. private _blendFunctionParameters;
  95481. private _blendEquationParameters;
  95482. private _blendConstants;
  95483. /**
  95484. * Initializes the state.
  95485. */
  95486. constructor();
  95487. readonly isDirty: boolean;
  95488. alphaBlend: boolean;
  95489. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  95490. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  95491. setAlphaEquationParameters(rgb: number, alpha: number): void;
  95492. reset(): void;
  95493. apply(gl: WebGLRenderingContext): void;
  95494. }
  95495. }
  95496. declare module BABYLON {
  95497. /** @hidden */
  95498. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95499. attributeProcessor(attribute: string): string;
  95500. varyingProcessor(varying: string, isFragment: boolean): string;
  95501. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95502. }
  95503. }
  95504. declare module BABYLON {
  95505. /**
  95506. * Interface for attribute information associated with buffer instanciation
  95507. */
  95508. export class InstancingAttributeInfo {
  95509. /**
  95510. * Index/offset of the attribute in the vertex shader
  95511. */
  95512. index: number;
  95513. /**
  95514. * size of the attribute, 1, 2, 3 or 4
  95515. */
  95516. attributeSize: number;
  95517. /**
  95518. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95519. * default is FLOAT
  95520. */
  95521. attribyteType: number;
  95522. /**
  95523. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95524. */
  95525. normalized: boolean;
  95526. /**
  95527. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95528. */
  95529. offset: number;
  95530. /**
  95531. * Name of the GLSL attribute, for debugging purpose only
  95532. */
  95533. attributeName: string;
  95534. }
  95535. }
  95536. declare module BABYLON {
  95537. interface ThinEngine {
  95538. /**
  95539. * Update a video texture
  95540. * @param texture defines the texture to update
  95541. * @param video defines the video element to use
  95542. * @param invertY defines if data must be stored with Y axis inverted
  95543. */
  95544. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95545. }
  95546. }
  95547. declare module BABYLON {
  95548. /**
  95549. * Settings for finer control over video usage
  95550. */
  95551. export interface VideoTextureSettings {
  95552. /**
  95553. * Applies `autoplay` to video, if specified
  95554. */
  95555. autoPlay?: boolean;
  95556. /**
  95557. * Applies `loop` to video, if specified
  95558. */
  95559. loop?: boolean;
  95560. /**
  95561. * Automatically updates internal texture from video at every frame in the render loop
  95562. */
  95563. autoUpdateTexture: boolean;
  95564. /**
  95565. * Image src displayed during the video loading or until the user interacts with the video.
  95566. */
  95567. poster?: string;
  95568. }
  95569. /**
  95570. * If you want to display a video in your scene, this is the special texture for that.
  95571. * This special texture works similar to other textures, with the exception of a few parameters.
  95572. * @see https://doc.babylonjs.com/how_to/video_texture
  95573. */
  95574. export class VideoTexture extends Texture {
  95575. /**
  95576. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95577. */
  95578. readonly autoUpdateTexture: boolean;
  95579. /**
  95580. * The video instance used by the texture internally
  95581. */
  95582. readonly video: HTMLVideoElement;
  95583. private _onUserActionRequestedObservable;
  95584. /**
  95585. * Event triggerd when a dom action is required by the user to play the video.
  95586. * This happens due to recent changes in browser policies preventing video to auto start.
  95587. */
  95588. readonly onUserActionRequestedObservable: Observable<Texture>;
  95589. private _generateMipMaps;
  95590. private _engine;
  95591. private _stillImageCaptured;
  95592. private _displayingPosterTexture;
  95593. private _settings;
  95594. private _createInternalTextureOnEvent;
  95595. private _frameId;
  95596. /**
  95597. * Creates a video texture.
  95598. * If you want to display a video in your scene, this is the special texture for that.
  95599. * This special texture works similar to other textures, with the exception of a few parameters.
  95600. * @see https://doc.babylonjs.com/how_to/video_texture
  95601. * @param name optional name, will detect from video source, if not defined
  95602. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95603. * @param scene is obviously the current scene.
  95604. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95605. * @param invertY is false by default but can be used to invert video on Y axis
  95606. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95607. * @param settings allows finer control over video usage
  95608. */
  95609. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95610. private _getName;
  95611. private _getVideo;
  95612. private _createInternalTexture;
  95613. private reset;
  95614. /**
  95615. * @hidden Internal method to initiate `update`.
  95616. */
  95617. _rebuild(): void;
  95618. /**
  95619. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95620. */
  95621. update(): void;
  95622. /**
  95623. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95624. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95625. */
  95626. updateTexture(isVisible: boolean): void;
  95627. protected _updateInternalTexture: () => void;
  95628. /**
  95629. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95630. * @param url New url.
  95631. */
  95632. updateURL(url: string): void;
  95633. /**
  95634. * Dispose the texture and release its associated resources.
  95635. */
  95636. dispose(): void;
  95637. /**
  95638. * Creates a video texture straight from a stream.
  95639. * @param scene Define the scene the texture should be created in
  95640. * @param stream Define the stream the texture should be created from
  95641. * @returns The created video texture as a promise
  95642. */
  95643. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95644. /**
  95645. * Creates a video texture straight from your WebCam video feed.
  95646. * @param scene Define the scene the texture should be created in
  95647. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95648. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95649. * @returns The created video texture as a promise
  95650. */
  95651. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95652. minWidth: number;
  95653. maxWidth: number;
  95654. minHeight: number;
  95655. maxHeight: number;
  95656. deviceId: string;
  95657. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95658. /**
  95659. * Creates a video texture straight from your WebCam video feed.
  95660. * @param scene Define the scene the texture should be created in
  95661. * @param onReady Define a callback to triggered once the texture will be ready
  95662. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95663. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95664. */
  95665. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95666. minWidth: number;
  95667. maxWidth: number;
  95668. minHeight: number;
  95669. maxHeight: number;
  95670. deviceId: string;
  95671. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95672. }
  95673. }
  95674. declare module BABYLON {
  95675. /**
  95676. * Defines the interface used by objects working like Scene
  95677. * @hidden
  95678. */
  95679. interface ISceneLike {
  95680. _addPendingData(data: any): void;
  95681. _removePendingData(data: any): void;
  95682. offlineProvider: IOfflineProvider;
  95683. }
  95684. /** Interface defining initialization parameters for Engine class */
  95685. export interface EngineOptions extends WebGLContextAttributes {
  95686. /**
  95687. * Defines if the engine should no exceed a specified device ratio
  95688. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95689. */
  95690. limitDeviceRatio?: number;
  95691. /**
  95692. * Defines if webvr should be enabled automatically
  95693. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95694. */
  95695. autoEnableWebVR?: boolean;
  95696. /**
  95697. * Defines if webgl2 should be turned off even if supported
  95698. * @see http://doc.babylonjs.com/features/webgl2
  95699. */
  95700. disableWebGL2Support?: boolean;
  95701. /**
  95702. * Defines if webaudio should be initialized as well
  95703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95704. */
  95705. audioEngine?: boolean;
  95706. /**
  95707. * Defines if animations should run using a deterministic lock step
  95708. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95709. */
  95710. deterministicLockstep?: boolean;
  95711. /** Defines the maximum steps to use with deterministic lock step mode */
  95712. lockstepMaxSteps?: number;
  95713. /**
  95714. * Defines that engine should ignore context lost events
  95715. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95716. */
  95717. doNotHandleContextLost?: boolean;
  95718. /**
  95719. * Defines that engine should ignore modifying touch action attribute and style
  95720. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95721. */
  95722. doNotHandleTouchAction?: boolean;
  95723. /**
  95724. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95725. */
  95726. useHighPrecisionFloats?: boolean;
  95727. }
  95728. /**
  95729. * The base engine class (root of all engines)
  95730. */
  95731. export class ThinEngine {
  95732. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95733. static ExceptionList: ({
  95734. key: string;
  95735. capture: string;
  95736. captureConstraint: number;
  95737. targets: string[];
  95738. } | {
  95739. key: string;
  95740. capture: null;
  95741. captureConstraint: null;
  95742. targets: string[];
  95743. })[];
  95744. /** @hidden */
  95745. static _TextureLoaders: IInternalTextureLoader[];
  95746. /**
  95747. * Returns the current npm package of the sdk
  95748. */
  95749. static readonly NpmPackage: string;
  95750. /**
  95751. * Returns the current version of the framework
  95752. */
  95753. static readonly Version: string;
  95754. /**
  95755. * Returns a string describing the current engine
  95756. */
  95757. readonly description: string;
  95758. /**
  95759. * Gets or sets the epsilon value used by collision engine
  95760. */
  95761. static CollisionsEpsilon: number;
  95762. /**
  95763. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95764. */
  95765. static ShadersRepository: string;
  95766. /** @hidden */
  95767. _shaderProcessor: IShaderProcessor;
  95768. /**
  95769. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95770. */
  95771. forcePOTTextures: boolean;
  95772. /**
  95773. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95774. */
  95775. isFullscreen: boolean;
  95776. /**
  95777. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95778. */
  95779. cullBackFaces: boolean;
  95780. /**
  95781. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95782. */
  95783. renderEvenInBackground: boolean;
  95784. /**
  95785. * Gets or sets a boolean indicating that cache can be kept between frames
  95786. */
  95787. preventCacheWipeBetweenFrames: boolean;
  95788. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95789. validateShaderPrograms: boolean;
  95790. /**
  95791. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95792. */
  95793. disableUniformBuffers: boolean;
  95794. /** @hidden */
  95795. _uniformBuffers: UniformBuffer[];
  95796. /**
  95797. * Gets a boolean indicating that the engine supports uniform buffers
  95798. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95799. */
  95800. readonly supportsUniformBuffers: boolean;
  95801. /** @hidden */
  95802. _gl: WebGLRenderingContext;
  95803. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  95804. protected _windowIsBackground: boolean;
  95805. protected _webGLVersion: number;
  95806. protected _highPrecisionShadersAllowed: boolean;
  95807. /** @hidden */
  95808. readonly _shouldUseHighPrecisionShader: boolean;
  95809. /**
  95810. * Gets a boolean indicating that only power of 2 textures are supported
  95811. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95812. */
  95813. readonly needPOTTextures: boolean;
  95814. /** @hidden */
  95815. _badOS: boolean;
  95816. /** @hidden */
  95817. _badDesktopOS: boolean;
  95818. private _hardwareScalingLevel;
  95819. /** @hidden */
  95820. _caps: EngineCapabilities;
  95821. private _isStencilEnable;
  95822. protected _colorWrite: boolean;
  95823. private _glVersion;
  95824. private _glRenderer;
  95825. private _glVendor;
  95826. /** @hidden */
  95827. _videoTextureSupported: boolean;
  95828. protected _renderingQueueLaunched: boolean;
  95829. protected _activeRenderLoops: (() => void)[];
  95830. /**
  95831. * Observable signaled when a context lost event is raised
  95832. */
  95833. onContextLostObservable: Observable<ThinEngine>;
  95834. /**
  95835. * Observable signaled when a context restored event is raised
  95836. */
  95837. onContextRestoredObservable: Observable<ThinEngine>;
  95838. private _onContextLost;
  95839. private _onContextRestored;
  95840. protected _contextWasLost: boolean;
  95841. /** @hidden */
  95842. _doNotHandleContextLost: boolean;
  95843. /**
  95844. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95845. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95846. */
  95847. doNotHandleContextLost: boolean;
  95848. /**
  95849. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95850. */
  95851. disableVertexArrayObjects: boolean;
  95852. /** @hidden */
  95853. protected _depthCullingState: DepthCullingState;
  95854. /** @hidden */
  95855. protected _stencilState: StencilState;
  95856. /** @hidden */
  95857. protected _alphaState: AlphaState;
  95858. /** @hidden */
  95859. _internalTexturesCache: InternalTexture[];
  95860. /** @hidden */
  95861. protected _activeChannel: number;
  95862. private _currentTextureChannel;
  95863. /** @hidden */
  95864. protected _boundTexturesCache: {
  95865. [key: string]: Nullable<InternalTexture>;
  95866. };
  95867. /** @hidden */
  95868. protected _currentEffect: Nullable<Effect>;
  95869. /** @hidden */
  95870. protected _currentProgram: Nullable<WebGLProgram>;
  95871. private _compiledEffects;
  95872. private _vertexAttribArraysEnabled;
  95873. /** @hidden */
  95874. protected _cachedViewport: Nullable<IViewportLike>;
  95875. private _cachedVertexArrayObject;
  95876. /** @hidden */
  95877. protected _cachedVertexBuffers: any;
  95878. /** @hidden */
  95879. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  95880. /** @hidden */
  95881. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  95882. /** @hidden */
  95883. _currentRenderTarget: Nullable<InternalTexture>;
  95884. private _uintIndicesCurrentlySet;
  95885. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  95886. /** @hidden */
  95887. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  95888. private _currentBufferPointers;
  95889. private _currentInstanceLocations;
  95890. private _currentInstanceBuffers;
  95891. private _textureUnits;
  95892. /** @hidden */
  95893. _workingCanvas: Nullable<HTMLCanvasElement>;
  95894. /** @hidden */
  95895. _workingContext: Nullable<CanvasRenderingContext2D>;
  95896. /** @hidden */
  95897. _bindedRenderFunction: any;
  95898. private _vaoRecordInProgress;
  95899. private _mustWipeVertexAttributes;
  95900. private _emptyTexture;
  95901. private _emptyCubeTexture;
  95902. private _emptyTexture3D;
  95903. /** @hidden */
  95904. _frameHandler: number;
  95905. private _nextFreeTextureSlots;
  95906. private _maxSimultaneousTextures;
  95907. private _activeRequests;
  95908. protected _texturesSupported: string[];
  95909. /** @hidden */
  95910. _textureFormatInUse: Nullable<string>;
  95911. protected readonly _supportsHardwareTextureRescaling: boolean;
  95912. /**
  95913. * Gets the list of texture formats supported
  95914. */
  95915. readonly texturesSupported: Array<string>;
  95916. /**
  95917. * Gets the list of texture formats in use
  95918. */
  95919. readonly textureFormatInUse: Nullable<string>;
  95920. /**
  95921. * Gets the current viewport
  95922. */
  95923. readonly currentViewport: Nullable<IViewportLike>;
  95924. /**
  95925. * Gets the default empty texture
  95926. */
  95927. readonly emptyTexture: InternalTexture;
  95928. /**
  95929. * Gets the default empty 3D texture
  95930. */
  95931. readonly emptyTexture3D: InternalTexture;
  95932. /**
  95933. * Gets the default empty cube texture
  95934. */
  95935. readonly emptyCubeTexture: InternalTexture;
  95936. /**
  95937. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  95938. */
  95939. readonly premultipliedAlpha: boolean;
  95940. /**
  95941. * Observable event triggered before each texture is initialized
  95942. */
  95943. onBeforeTextureInitObservable: Observable<Texture>;
  95944. /**
  95945. * Creates a new engine
  95946. * @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
  95947. * @param antialias defines enable antialiasing (default: false)
  95948. * @param options defines further options to be sent to the getContext() function
  95949. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  95950. */
  95951. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  95952. private _rebuildInternalTextures;
  95953. private _rebuildEffects;
  95954. /**
  95955. * Gets a boolean indicating if all created effects are ready
  95956. * @returns true if all effects are ready
  95957. */
  95958. areAllEffectsReady(): boolean;
  95959. protected _rebuildBuffers(): void;
  95960. private _initGLContext;
  95961. /**
  95962. * Gets version of the current webGL context
  95963. */
  95964. readonly webGLVersion: number;
  95965. /**
  95966. * Gets a string idenfifying the name of the class
  95967. * @returns "Engine" string
  95968. */
  95969. getClassName(): string;
  95970. /**
  95971. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  95972. */
  95973. readonly isStencilEnable: boolean;
  95974. /** @hidden */
  95975. _prepareWorkingCanvas(): void;
  95976. /**
  95977. * Reset the texture cache to empty state
  95978. */
  95979. resetTextureCache(): void;
  95980. /**
  95981. * Gets an object containing information about the current webGL context
  95982. * @returns an object containing the vender, the renderer and the version of the current webGL context
  95983. */
  95984. getGlInfo(): {
  95985. vendor: string;
  95986. renderer: string;
  95987. version: string;
  95988. };
  95989. /**
  95990. * Defines the hardware scaling level.
  95991. * By default the hardware scaling level is computed from the window device ratio.
  95992. * 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.
  95993. * @param level defines the level to use
  95994. */
  95995. setHardwareScalingLevel(level: number): void;
  95996. /**
  95997. * Gets the current hardware scaling level.
  95998. * By default the hardware scaling level is computed from the window device ratio.
  95999. * 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.
  96000. * @returns a number indicating the current hardware scaling level
  96001. */
  96002. getHardwareScalingLevel(): number;
  96003. /**
  96004. * Gets the list of loaded textures
  96005. * @returns an array containing all loaded textures
  96006. */
  96007. getLoadedTexturesCache(): InternalTexture[];
  96008. /**
  96009. * Gets the object containing all engine capabilities
  96010. * @returns the EngineCapabilities object
  96011. */
  96012. getCaps(): EngineCapabilities;
  96013. /**
  96014. * stop executing a render loop function and remove it from the execution array
  96015. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96016. */
  96017. stopRenderLoop(renderFunction?: () => void): void;
  96018. /** @hidden */
  96019. _renderLoop(): void;
  96020. /**
  96021. * Gets the HTML canvas attached with the current webGL context
  96022. * @returns a HTML canvas
  96023. */
  96024. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96025. /**
  96026. * Gets host window
  96027. * @returns the host window object
  96028. */
  96029. getHostWindow(): Window;
  96030. /**
  96031. * Gets the current render width
  96032. * @param useScreen defines if screen size must be used (or the current render target if any)
  96033. * @returns a number defining the current render width
  96034. */
  96035. getRenderWidth(useScreen?: boolean): number;
  96036. /**
  96037. * Gets the current render height
  96038. * @param useScreen defines if screen size must be used (or the current render target if any)
  96039. * @returns a number defining the current render height
  96040. */
  96041. getRenderHeight(useScreen?: boolean): number;
  96042. /**
  96043. * Can be used to override the current requestAnimationFrame requester.
  96044. * @hidden
  96045. */
  96046. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96047. /**
  96048. * Register and execute a render loop. The engine can have more than one render function
  96049. * @param renderFunction defines the function to continuously execute
  96050. */
  96051. runRenderLoop(renderFunction: () => void): void;
  96052. /**
  96053. * Clear the current render buffer or the current render target (if any is set up)
  96054. * @param color defines the color to use
  96055. * @param backBuffer defines if the back buffer must be cleared
  96056. * @param depth defines if the depth buffer must be cleared
  96057. * @param stencil defines if the stencil buffer must be cleared
  96058. */
  96059. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96060. private _viewportCached;
  96061. /** @hidden */
  96062. _viewport(x: number, y: number, width: number, height: number): void;
  96063. /**
  96064. * Set the WebGL's viewport
  96065. * @param viewport defines the viewport element to be used
  96066. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96067. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96068. */
  96069. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96070. /**
  96071. * Begin a new frame
  96072. */
  96073. beginFrame(): void;
  96074. /**
  96075. * Enf the current frame
  96076. */
  96077. endFrame(): void;
  96078. /**
  96079. * Resize the view according to the canvas' size
  96080. */
  96081. resize(): void;
  96082. /**
  96083. * Force a specific size of the canvas
  96084. * @param width defines the new canvas' width
  96085. * @param height defines the new canvas' height
  96086. */
  96087. setSize(width: number, height: number): void;
  96088. /**
  96089. * Binds the frame buffer to the specified texture.
  96090. * @param texture The texture to render to or null for the default canvas
  96091. * @param faceIndex The face of the texture to render to in case of cube texture
  96092. * @param requiredWidth The width of the target to render to
  96093. * @param requiredHeight The height of the target to render to
  96094. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96095. * @param depthStencilTexture The depth stencil texture to use to render
  96096. * @param lodLevel defines le lod level to bind to the frame buffer
  96097. */
  96098. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96099. /** @hidden */
  96100. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96101. /**
  96102. * Unbind the current render target texture from the webGL context
  96103. * @param texture defines the render target texture to unbind
  96104. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96105. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96106. */
  96107. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96108. /**
  96109. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96110. */
  96111. flushFramebuffer(): void;
  96112. /**
  96113. * Unbind the current render target and bind the default framebuffer
  96114. */
  96115. restoreDefaultFramebuffer(): void;
  96116. private _resetVertexBufferBinding;
  96117. /**
  96118. * Creates a vertex buffer
  96119. * @param data the data for the vertex buffer
  96120. * @returns the new WebGL static buffer
  96121. */
  96122. createVertexBuffer(data: DataArray): DataBuffer;
  96123. private _createVertexBuffer;
  96124. /**
  96125. * Creates a dynamic vertex buffer
  96126. * @param data the data for the dynamic vertex buffer
  96127. * @returns the new WebGL dynamic buffer
  96128. */
  96129. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96130. /**
  96131. * Updates a dynamic vertex buffer.
  96132. * @param vertexBuffer the vertex buffer to update
  96133. * @param data the data used to update the vertex buffer
  96134. * @param byteOffset the byte offset of the data
  96135. * @param byteLength the byte length of the data
  96136. */
  96137. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96138. protected _resetIndexBufferBinding(): void;
  96139. /**
  96140. * Creates a new index buffer
  96141. * @param indices defines the content of the index buffer
  96142. * @param updatable defines if the index buffer must be updatable
  96143. * @returns a new webGL buffer
  96144. */
  96145. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96146. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96147. /**
  96148. * Bind a webGL buffer to the webGL context
  96149. * @param buffer defines the buffer to bind
  96150. */
  96151. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96152. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  96153. private bindBuffer;
  96154. /**
  96155. * update the bound buffer with the given data
  96156. * @param data defines the data to update
  96157. */
  96158. updateArrayBuffer(data: Float32Array): void;
  96159. private _vertexAttribPointer;
  96160. private _bindIndexBufferWithCache;
  96161. private _bindVertexBuffersAttributes;
  96162. /**
  96163. * Records a vertex array object
  96164. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96165. * @param vertexBuffers defines the list of vertex buffers to store
  96166. * @param indexBuffer defines the index buffer to store
  96167. * @param effect defines the effect to store
  96168. * @returns the new vertex array object
  96169. */
  96170. recordVertexArrayObject(vertexBuffers: {
  96171. [key: string]: VertexBuffer;
  96172. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96173. /**
  96174. * Bind a specific vertex array object
  96175. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96176. * @param vertexArrayObject defines the vertex array object to bind
  96177. * @param indexBuffer defines the index buffer to bind
  96178. */
  96179. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96180. /**
  96181. * Bind webGl buffers directly to the webGL context
  96182. * @param vertexBuffer defines the vertex buffer to bind
  96183. * @param indexBuffer defines the index buffer to bind
  96184. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96185. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96186. * @param effect defines the effect associated with the vertex buffer
  96187. */
  96188. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96189. private _unbindVertexArrayObject;
  96190. /**
  96191. * Bind a list of vertex buffers to the webGL context
  96192. * @param vertexBuffers defines the list of vertex buffers to bind
  96193. * @param indexBuffer defines the index buffer to bind
  96194. * @param effect defines the effect associated with the vertex buffers
  96195. */
  96196. bindBuffers(vertexBuffers: {
  96197. [key: string]: Nullable<VertexBuffer>;
  96198. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96199. /**
  96200. * Unbind all instance attributes
  96201. */
  96202. unbindInstanceAttributes(): void;
  96203. /**
  96204. * Release and free the memory of a vertex array object
  96205. * @param vao defines the vertex array object to delete
  96206. */
  96207. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96208. /** @hidden */
  96209. _releaseBuffer(buffer: DataBuffer): boolean;
  96210. protected _deleteBuffer(buffer: DataBuffer): void;
  96211. /**
  96212. * Creates a webGL buffer to use with instanciation
  96213. * @param capacity defines the size of the buffer
  96214. * @returns the webGL buffer
  96215. */
  96216. createInstancesBuffer(capacity: number): DataBuffer;
  96217. /**
  96218. * Delete a webGL buffer used with instanciation
  96219. * @param buffer defines the webGL buffer to delete
  96220. */
  96221. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96222. /**
  96223. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96224. * @param instancesBuffer defines the webGL buffer to update and bind
  96225. * @param data defines the data to store in the buffer
  96226. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96227. */
  96228. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96229. /**
  96230. * Apply all cached states (depth, culling, stencil and alpha)
  96231. */
  96232. applyStates(): void;
  96233. /**
  96234. * Send a draw order
  96235. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96236. * @param indexStart defines the starting index
  96237. * @param indexCount defines the number of index to draw
  96238. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96239. */
  96240. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96241. /**
  96242. * Draw a list of points
  96243. * @param verticesStart defines the index of first vertex to draw
  96244. * @param verticesCount defines the count of vertices to draw
  96245. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96246. */
  96247. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96248. /**
  96249. * Draw a list of unindexed primitives
  96250. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96251. * @param verticesStart defines the index of first vertex to draw
  96252. * @param verticesCount defines the count of vertices to draw
  96253. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96254. */
  96255. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96256. /**
  96257. * Draw a list of indexed primitives
  96258. * @param fillMode defines the primitive to use
  96259. * @param indexStart defines the starting index
  96260. * @param indexCount defines the number of index to draw
  96261. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96262. */
  96263. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96264. /**
  96265. * Draw a list of unindexed primitives
  96266. * @param fillMode defines the primitive to use
  96267. * @param verticesStart defines the index of first vertex to draw
  96268. * @param verticesCount defines the count of vertices to draw
  96269. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96270. */
  96271. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96272. private _drawMode;
  96273. /** @hidden */
  96274. protected _reportDrawCall(): void;
  96275. /** @hidden */
  96276. _releaseEffect(effect: Effect): void;
  96277. /** @hidden */
  96278. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96279. /**
  96280. * Create a new effect (used to store vertex/fragment shaders)
  96281. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96282. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  96283. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96284. * @param samplers defines an array of string used to represent textures
  96285. * @param defines defines the string containing the defines to use to compile the shaders
  96286. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96287. * @param onCompiled defines a function to call when the effect creation is successful
  96288. * @param onError defines a function to call when the effect creation has failed
  96289. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96290. * @returns the new Effect
  96291. */
  96292. 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;
  96293. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96294. private _compileShader;
  96295. private _compileRawShader;
  96296. /**
  96297. * Directly creates a webGL program
  96298. * @param pipelineContext defines the pipeline context to attach to
  96299. * @param vertexCode defines the vertex shader code to use
  96300. * @param fragmentCode defines the fragment shader code to use
  96301. * @param context defines the webGL context to use (if not set, the current one will be used)
  96302. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96303. * @returns the new webGL program
  96304. */
  96305. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96306. /**
  96307. * Creates a webGL program
  96308. * @param pipelineContext defines the pipeline context to attach to
  96309. * @param vertexCode defines the vertex shader code to use
  96310. * @param fragmentCode defines the fragment shader code to use
  96311. * @param defines defines the string containing the defines to use to compile the shaders
  96312. * @param context defines the webGL context to use (if not set, the current one will be used)
  96313. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96314. * @returns the new webGL program
  96315. */
  96316. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96317. /**
  96318. * Creates a new pipeline context
  96319. * @returns the new pipeline
  96320. */
  96321. createPipelineContext(): IPipelineContext;
  96322. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96323. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96324. /** @hidden */
  96325. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96326. /** @hidden */
  96327. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96328. /** @hidden */
  96329. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96330. /**
  96331. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96332. * @param pipelineContext defines the pipeline context to use
  96333. * @param uniformsNames defines the list of uniform names
  96334. * @returns an array of webGL uniform locations
  96335. */
  96336. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96337. /**
  96338. * Gets the lsit of active attributes for a given webGL program
  96339. * @param pipelineContext defines the pipeline context to use
  96340. * @param attributesNames defines the list of attribute names to get
  96341. * @returns an array of indices indicating the offset of each attribute
  96342. */
  96343. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96344. /**
  96345. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96346. * @param effect defines the effect to activate
  96347. */
  96348. enableEffect(effect: Nullable<Effect>): void;
  96349. /**
  96350. * Set the value of an uniform to an array of int32
  96351. * @param uniform defines the webGL uniform location where to store the value
  96352. * @param array defines the array of int32 to store
  96353. */
  96354. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96355. /**
  96356. * Set the value of an uniform to an array of int32 (stored as vec2)
  96357. * @param uniform defines the webGL uniform location where to store the value
  96358. * @param array defines the array of int32 to store
  96359. */
  96360. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96361. /**
  96362. * Set the value of an uniform to an array of int32 (stored as vec3)
  96363. * @param uniform defines the webGL uniform location where to store the value
  96364. * @param array defines the array of int32 to store
  96365. */
  96366. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96367. /**
  96368. * Set the value of an uniform to an array of int32 (stored as vec4)
  96369. * @param uniform defines the webGL uniform location where to store the value
  96370. * @param array defines the array of int32 to store
  96371. */
  96372. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96373. /**
  96374. * Set the value of an uniform to an array of float32
  96375. * @param uniform defines the webGL uniform location where to store the value
  96376. * @param array defines the array of float32 to store
  96377. */
  96378. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96379. /**
  96380. * Set the value of an uniform to an array of float32 (stored as vec2)
  96381. * @param uniform defines the webGL uniform location where to store the value
  96382. * @param array defines the array of float32 to store
  96383. */
  96384. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96385. /**
  96386. * Set the value of an uniform to an array of float32 (stored as vec3)
  96387. * @param uniform defines the webGL uniform location where to store the value
  96388. * @param array defines the array of float32 to store
  96389. */
  96390. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96391. /**
  96392. * Set the value of an uniform to an array of float32 (stored as vec4)
  96393. * @param uniform defines the webGL uniform location where to store the value
  96394. * @param array defines the array of float32 to store
  96395. */
  96396. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96397. /**
  96398. * Set the value of an uniform to an array of number
  96399. * @param uniform defines the webGL uniform location where to store the value
  96400. * @param array defines the array of number to store
  96401. */
  96402. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96403. /**
  96404. * Set the value of an uniform to an array of number (stored as vec2)
  96405. * @param uniform defines the webGL uniform location where to store the value
  96406. * @param array defines the array of number to store
  96407. */
  96408. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96409. /**
  96410. * Set the value of an uniform to an array of number (stored as vec3)
  96411. * @param uniform defines the webGL uniform location where to store the value
  96412. * @param array defines the array of number to store
  96413. */
  96414. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96415. /**
  96416. * Set the value of an uniform to an array of number (stored as vec4)
  96417. * @param uniform defines the webGL uniform location where to store the value
  96418. * @param array defines the array of number to store
  96419. */
  96420. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96421. /**
  96422. * Set the value of an uniform to an array of float32 (stored as matrices)
  96423. * @param uniform defines the webGL uniform location where to store the value
  96424. * @param matrices defines the array of float32 to store
  96425. */
  96426. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96427. /**
  96428. * Set the value of an uniform to a matrix (3x3)
  96429. * @param uniform defines the webGL uniform location where to store the value
  96430. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96431. */
  96432. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96433. /**
  96434. * Set the value of an uniform to a matrix (2x2)
  96435. * @param uniform defines the webGL uniform location where to store the value
  96436. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96437. */
  96438. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96439. /**
  96440. * Set the value of an uniform to a number (int)
  96441. * @param uniform defines the webGL uniform location where to store the value
  96442. * @param value defines the int number to store
  96443. */
  96444. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96445. /**
  96446. * Set the value of an uniform to a number (float)
  96447. * @param uniform defines the webGL uniform location where to store the value
  96448. * @param value defines the float number to store
  96449. */
  96450. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96451. /**
  96452. * Set the value of an uniform to a vec2
  96453. * @param uniform defines the webGL uniform location where to store the value
  96454. * @param x defines the 1st component of the value
  96455. * @param y defines the 2nd component of the value
  96456. */
  96457. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96458. /**
  96459. * Set the value of an uniform to a vec3
  96460. * @param uniform defines the webGL uniform location where to store the value
  96461. * @param x defines the 1st component of the value
  96462. * @param y defines the 2nd component of the value
  96463. * @param z defines the 3rd component of the value
  96464. */
  96465. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96466. /**
  96467. * Set the value of an uniform to a boolean
  96468. * @param uniform defines the webGL uniform location where to store the value
  96469. * @param bool defines the boolean to store
  96470. */
  96471. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96472. /**
  96473. * Set the value of an uniform to a vec4
  96474. * @param uniform defines the webGL uniform location where to store the value
  96475. * @param x defines the 1st component of the value
  96476. * @param y defines the 2nd component of the value
  96477. * @param z defines the 3rd component of the value
  96478. * @param w defines the 4th component of the value
  96479. */
  96480. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96481. /**
  96482. * Sets a Color4 on a uniform variable
  96483. * @param uniform defines the uniform location
  96484. * @param color4 defines the value to be set
  96485. */
  96486. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96487. /**
  96488. * Gets the depth culling state manager
  96489. */
  96490. readonly depthCullingState: DepthCullingState;
  96491. /**
  96492. * Gets the alpha state manager
  96493. */
  96494. readonly alphaState: AlphaState;
  96495. /**
  96496. * Gets the stencil state manager
  96497. */
  96498. readonly stencilState: StencilState;
  96499. /**
  96500. * Clears the list of texture accessible through engine.
  96501. * This can help preventing texture load conflict due to name collision.
  96502. */
  96503. clearInternalTexturesCache(): void;
  96504. /**
  96505. * Force the entire cache to be cleared
  96506. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96507. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96508. */
  96509. wipeCaches(bruteForce?: boolean): void;
  96510. /** @hidden */
  96511. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96512. min: number;
  96513. mag: number;
  96514. };
  96515. /** @hidden */
  96516. _createTexture(): WebGLTexture;
  96517. /**
  96518. * Usually called from Texture.ts.
  96519. * Passed information to create a WebGLTexture
  96520. * @param urlArg defines a value which contains one of the following:
  96521. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96522. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96523. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96524. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96525. * @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)
  96526. * @param scene needed for loading to the correct scene
  96527. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96528. * @param onLoad optional callback to be called upon successful completion
  96529. * @param onError optional callback to be called upon failure
  96530. * @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
  96531. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96532. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96533. * @param forcedExtension defines the extension to use to pick the right loader
  96534. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96535. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96536. */
  96537. 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;
  96538. /**
  96539. * @hidden
  96540. */
  96541. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  96542. /**
  96543. * Creates a raw texture
  96544. * @param data defines the data to store in the texture
  96545. * @param width defines the width of the texture
  96546. * @param height defines the height of the texture
  96547. * @param format defines the format of the data
  96548. * @param generateMipMaps defines if the engine should generate the mip levels
  96549. * @param invertY defines if data must be stored with Y axis inverted
  96550. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96551. * @param compression defines the compression used (null by default)
  96552. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  96553. * @returns the raw texture inside an InternalTexture
  96554. */
  96555. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  96556. /**
  96557. * Creates a new raw cube texture
  96558. * @param data defines the array of data to use to create each face
  96559. * @param size defines the size of the textures
  96560. * @param format defines the format of the data
  96561. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  96562. * @param generateMipMaps defines if the engine should generate the mip levels
  96563. * @param invertY defines if data must be stored with Y axis inverted
  96564. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96565. * @param compression defines the compression used (null by default)
  96566. * @returns the cube texture as an InternalTexture
  96567. */
  96568. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  96569. /**
  96570. * Creates a new raw 3D texture
  96571. * @param data defines the data used to create the texture
  96572. * @param width defines the width of the texture
  96573. * @param height defines the height of the texture
  96574. * @param depth defines the depth of the texture
  96575. * @param format defines the format of the texture
  96576. * @param generateMipMaps defines if the engine must generate mip levels
  96577. * @param invertY defines if data must be stored with Y axis inverted
  96578. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96579. * @param compression defines the compressed used (can be null)
  96580. * @param textureType defines the compressed used (can be null)
  96581. * @returns a new raw 3D texture (stored in an InternalTexture)
  96582. */
  96583. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  96584. private _unpackFlipYCached;
  96585. /**
  96586. * In case you are sharing the context with other applications, it might
  96587. * be interested to not cache the unpack flip y state to ensure a consistent
  96588. * value would be set.
  96589. */
  96590. enableUnpackFlipYCached: boolean;
  96591. /** @hidden */
  96592. _unpackFlipY(value: boolean): void;
  96593. /** @hidden */
  96594. _getUnpackAlignement(): number;
  96595. /**
  96596. * Update the sampling mode of a given texture
  96597. * @param samplingMode defines the required sampling mode
  96598. * @param texture defines the texture to update
  96599. */
  96600. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96601. /**
  96602. * Updates a depth texture Comparison Mode and Function.
  96603. * If the comparison Function is equal to 0, the mode will be set to none.
  96604. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96605. * @param texture The texture to set the comparison function for
  96606. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96607. */
  96608. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96609. /** @hidden */
  96610. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96611. width: number;
  96612. height: number;
  96613. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96614. /**
  96615. * Creates a depth stencil texture.
  96616. * This is only available in WebGL 2 or with the depth texture extension available.
  96617. * @param size The size of face edge in the texture.
  96618. * @param options The options defining the texture.
  96619. * @returns The texture
  96620. */
  96621. createDepthStencilTexture(size: number | {
  96622. width: number;
  96623. height: number;
  96624. }, options: DepthTextureCreationOptions): InternalTexture;
  96625. /**
  96626. * Creates a depth stencil texture.
  96627. * This is only available in WebGL 2 or with the depth texture extension available.
  96628. * @param size The size of face edge in the texture.
  96629. * @param options The options defining the texture.
  96630. * @returns The texture
  96631. */
  96632. private _createDepthStencilTexture;
  96633. /** @hidden */
  96634. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96635. /** @hidden */
  96636. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96637. /** @hidden */
  96638. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96639. /** @hidden */
  96640. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96641. /**
  96642. * @hidden
  96643. */
  96644. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96645. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96646. private _prepareWebGLTexture;
  96647. /** @hidden */
  96648. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96649. /** @hidden */
  96650. _releaseFramebufferObjects(texture: InternalTexture): void;
  96651. /** @hidden */
  96652. _releaseTexture(texture: InternalTexture): void;
  96653. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  96654. protected _setProgram(program: WebGLProgram): void;
  96655. protected _boundUniforms: {
  96656. [key: number]: WebGLUniformLocation;
  96657. };
  96658. /**
  96659. * Binds an effect to the webGL context
  96660. * @param effect defines the effect to bind
  96661. */
  96662. bindSamplers(effect: Effect): void;
  96663. private _activateCurrentTexture;
  96664. /** @hidden */
  96665. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96666. /** @hidden */
  96667. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96668. /**
  96669. * Unbind all textures from the webGL context
  96670. */
  96671. unbindAllTextures(): void;
  96672. /**
  96673. * Sets a texture to the according uniform.
  96674. * @param channel The texture channel
  96675. * @param uniform The uniform to set
  96676. * @param texture The texture to apply
  96677. */
  96678. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96679. private _bindSamplerUniformToChannel;
  96680. private _getTextureWrapMode;
  96681. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  96682. /**
  96683. * Sets an array of texture to the webGL context
  96684. * @param channel defines the channel where the texture array must be set
  96685. * @param uniform defines the associated uniform location
  96686. * @param textures defines the array of textures to bind
  96687. */
  96688. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96689. /** @hidden */
  96690. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96691. private _setTextureParameterFloat;
  96692. private _setTextureParameterInteger;
  96693. /**
  96694. * Unbind all vertex attributes from the webGL context
  96695. */
  96696. unbindAllAttributes(): void;
  96697. /**
  96698. * 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
  96699. */
  96700. releaseEffects(): void;
  96701. /**
  96702. * Dispose and release all associated resources
  96703. */
  96704. dispose(): void;
  96705. /**
  96706. * Attach a new callback raised when context lost event is fired
  96707. * @param callback defines the callback to call
  96708. */
  96709. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96710. /**
  96711. * Attach a new callback raised when context restored event is fired
  96712. * @param callback defines the callback to call
  96713. */
  96714. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96715. /**
  96716. * Get the current error code of the webGL context
  96717. * @returns the error code
  96718. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96719. */
  96720. getError(): number;
  96721. private _canRenderToFloatFramebuffer;
  96722. private _canRenderToHalfFloatFramebuffer;
  96723. private _canRenderToFramebuffer;
  96724. /** @hidden */
  96725. _getWebGLTextureType(type: number): number;
  96726. /** @hidden */
  96727. _getInternalFormat(format: number): number;
  96728. /** @hidden */
  96729. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96730. /** @hidden */
  96731. _getRGBAMultiSampleBufferFormat(type: number): number;
  96732. /** @hidden */
  96733. _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;
  96734. /**
  96735. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96736. * @returns true if the engine can be created
  96737. * @ignorenaming
  96738. */
  96739. static isSupported(): boolean;
  96740. /**
  96741. * Find the next highest power of two.
  96742. * @param x Number to start search from.
  96743. * @return Next highest power of two.
  96744. */
  96745. static CeilingPOT(x: number): number;
  96746. /**
  96747. * Find the next lowest power of two.
  96748. * @param x Number to start search from.
  96749. * @return Next lowest power of two.
  96750. */
  96751. static FloorPOT(x: number): number;
  96752. /**
  96753. * Find the nearest power of two.
  96754. * @param x Number to start search from.
  96755. * @return Next nearest power of two.
  96756. */
  96757. static NearestPOT(x: number): number;
  96758. /**
  96759. * Get the closest exponent of two
  96760. * @param value defines the value to approximate
  96761. * @param max defines the maximum value to return
  96762. * @param mode defines how to define the closest value
  96763. * @returns closest exponent of two of the given value
  96764. */
  96765. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96766. /**
  96767. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96768. * @param func - the function to be called
  96769. * @param requester - the object that will request the next frame. Falls back to window.
  96770. * @returns frame number
  96771. */
  96772. static QueueNewFrame(func: () => void, requester?: any): number;
  96773. }
  96774. }
  96775. declare module BABYLON {
  96776. /**
  96777. * Class representing spherical harmonics coefficients to the 3rd degree
  96778. */
  96779. export class SphericalHarmonics {
  96780. /**
  96781. * Defines whether or not the harmonics have been prescaled for rendering.
  96782. */
  96783. preScaled: boolean;
  96784. /**
  96785. * The l0,0 coefficients of the spherical harmonics
  96786. */
  96787. l00: Vector3;
  96788. /**
  96789. * The l1,-1 coefficients of the spherical harmonics
  96790. */
  96791. l1_1: Vector3;
  96792. /**
  96793. * The l1,0 coefficients of the spherical harmonics
  96794. */
  96795. l10: Vector3;
  96796. /**
  96797. * The l1,1 coefficients of the spherical harmonics
  96798. */
  96799. l11: Vector3;
  96800. /**
  96801. * The l2,-2 coefficients of the spherical harmonics
  96802. */
  96803. l2_2: Vector3;
  96804. /**
  96805. * The l2,-1 coefficients of the spherical harmonics
  96806. */
  96807. l2_1: Vector3;
  96808. /**
  96809. * The l2,0 coefficients of the spherical harmonics
  96810. */
  96811. l20: Vector3;
  96812. /**
  96813. * The l2,1 coefficients of the spherical harmonics
  96814. */
  96815. l21: Vector3;
  96816. /**
  96817. * The l2,2 coefficients of the spherical harmonics
  96818. */
  96819. l22: Vector3;
  96820. /**
  96821. * Adds a light to the spherical harmonics
  96822. * @param direction the direction of the light
  96823. * @param color the color of the light
  96824. * @param deltaSolidAngle the delta solid angle of the light
  96825. */
  96826. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  96827. /**
  96828. * Scales the spherical harmonics by the given amount
  96829. * @param scale the amount to scale
  96830. */
  96831. scaleInPlace(scale: number): void;
  96832. /**
  96833. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  96834. *
  96835. * ```
  96836. * E_lm = A_l * L_lm
  96837. * ```
  96838. *
  96839. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  96840. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  96841. * the scaling factors are given in equation 9.
  96842. */
  96843. convertIncidentRadianceToIrradiance(): void;
  96844. /**
  96845. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  96846. *
  96847. * ```
  96848. * L = (1/pi) * E * rho
  96849. * ```
  96850. *
  96851. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  96852. */
  96853. convertIrradianceToLambertianRadiance(): void;
  96854. /**
  96855. * Integrates the reconstruction coefficients directly in to the SH preventing further
  96856. * required operations at run time.
  96857. *
  96858. * This is simply done by scaling back the SH with Ylm constants parameter.
  96859. * The trigonometric part being applied by the shader at run time.
  96860. */
  96861. preScaleForRendering(): void;
  96862. /**
  96863. * Constructs a spherical harmonics from an array.
  96864. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  96865. * @returns the spherical harmonics
  96866. */
  96867. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  96868. /**
  96869. * Gets the spherical harmonics from polynomial
  96870. * @param polynomial the spherical polynomial
  96871. * @returns the spherical harmonics
  96872. */
  96873. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  96874. }
  96875. /**
  96876. * Class representing spherical polynomial coefficients to the 3rd degree
  96877. */
  96878. export class SphericalPolynomial {
  96879. private _harmonics;
  96880. /**
  96881. * The spherical harmonics used to create the polynomials.
  96882. */
  96883. readonly preScaledHarmonics: SphericalHarmonics;
  96884. /**
  96885. * The x coefficients of the spherical polynomial
  96886. */
  96887. x: Vector3;
  96888. /**
  96889. * The y coefficients of the spherical polynomial
  96890. */
  96891. y: Vector3;
  96892. /**
  96893. * The z coefficients of the spherical polynomial
  96894. */
  96895. z: Vector3;
  96896. /**
  96897. * The xx coefficients of the spherical polynomial
  96898. */
  96899. xx: Vector3;
  96900. /**
  96901. * The yy coefficients of the spherical polynomial
  96902. */
  96903. yy: Vector3;
  96904. /**
  96905. * The zz coefficients of the spherical polynomial
  96906. */
  96907. zz: Vector3;
  96908. /**
  96909. * The xy coefficients of the spherical polynomial
  96910. */
  96911. xy: Vector3;
  96912. /**
  96913. * The yz coefficients of the spherical polynomial
  96914. */
  96915. yz: Vector3;
  96916. /**
  96917. * The zx coefficients of the spherical polynomial
  96918. */
  96919. zx: Vector3;
  96920. /**
  96921. * Adds an ambient color to the spherical polynomial
  96922. * @param color the color to add
  96923. */
  96924. addAmbient(color: Color3): void;
  96925. /**
  96926. * Scales the spherical polynomial by the given amount
  96927. * @param scale the amount to scale
  96928. */
  96929. scaleInPlace(scale: number): void;
  96930. /**
  96931. * Gets the spherical polynomial from harmonics
  96932. * @param harmonics the spherical harmonics
  96933. * @returns the spherical polynomial
  96934. */
  96935. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  96936. /**
  96937. * Constructs a spherical polynomial from an array.
  96938. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  96939. * @returns the spherical polynomial
  96940. */
  96941. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  96942. }
  96943. }
  96944. declare module BABYLON {
  96945. /**
  96946. * Defines the source of the internal texture
  96947. */
  96948. export enum InternalTextureSource {
  96949. /**
  96950. * The source of the texture data is unknown
  96951. */
  96952. Unknown = 0,
  96953. /**
  96954. * Texture data comes from an URL
  96955. */
  96956. Url = 1,
  96957. /**
  96958. * Texture data is only used for temporary storage
  96959. */
  96960. Temp = 2,
  96961. /**
  96962. * Texture data comes from raw data (ArrayBuffer)
  96963. */
  96964. Raw = 3,
  96965. /**
  96966. * Texture content is dynamic (video or dynamic texture)
  96967. */
  96968. Dynamic = 4,
  96969. /**
  96970. * Texture content is generated by rendering to it
  96971. */
  96972. RenderTarget = 5,
  96973. /**
  96974. * Texture content is part of a multi render target process
  96975. */
  96976. MultiRenderTarget = 6,
  96977. /**
  96978. * Texture data comes from a cube data file
  96979. */
  96980. Cube = 7,
  96981. /**
  96982. * Texture data comes from a raw cube data
  96983. */
  96984. CubeRaw = 8,
  96985. /**
  96986. * Texture data come from a prefiltered cube data file
  96987. */
  96988. CubePrefiltered = 9,
  96989. /**
  96990. * Texture content is raw 3D data
  96991. */
  96992. Raw3D = 10,
  96993. /**
  96994. * Texture content is a depth texture
  96995. */
  96996. Depth = 11,
  96997. /**
  96998. * Texture data comes from a raw cube data encoded with RGBD
  96999. */
  97000. CubeRawRGBD = 12
  97001. }
  97002. /**
  97003. * Class used to store data associated with WebGL texture data for the engine
  97004. * This class should not be used directly
  97005. */
  97006. export class InternalTexture {
  97007. /** @hidden */
  97008. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  97009. /**
  97010. * Defines if the texture is ready
  97011. */
  97012. isReady: boolean;
  97013. /**
  97014. * Defines if the texture is a cube texture
  97015. */
  97016. isCube: boolean;
  97017. /**
  97018. * Defines if the texture contains 3D data
  97019. */
  97020. is3D: boolean;
  97021. /**
  97022. * Defines if the texture contains multiview data
  97023. */
  97024. isMultiview: boolean;
  97025. /**
  97026. * Gets the URL used to load this texture
  97027. */
  97028. url: string;
  97029. /**
  97030. * Gets the sampling mode of the texture
  97031. */
  97032. samplingMode: number;
  97033. /**
  97034. * Gets a boolean indicating if the texture needs mipmaps generation
  97035. */
  97036. generateMipMaps: boolean;
  97037. /**
  97038. * Gets the number of samples used by the texture (WebGL2+ only)
  97039. */
  97040. samples: number;
  97041. /**
  97042. * Gets the type of the texture (int, float...)
  97043. */
  97044. type: number;
  97045. /**
  97046. * Gets the format of the texture (RGB, RGBA...)
  97047. */
  97048. format: number;
  97049. /**
  97050. * Observable called when the texture is loaded
  97051. */
  97052. onLoadedObservable: Observable<InternalTexture>;
  97053. /**
  97054. * Gets the width of the texture
  97055. */
  97056. width: number;
  97057. /**
  97058. * Gets the height of the texture
  97059. */
  97060. height: number;
  97061. /**
  97062. * Gets the depth of the texture
  97063. */
  97064. depth: number;
  97065. /**
  97066. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97067. */
  97068. baseWidth: number;
  97069. /**
  97070. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97071. */
  97072. baseHeight: number;
  97073. /**
  97074. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97075. */
  97076. baseDepth: number;
  97077. /**
  97078. * Gets a boolean indicating if the texture is inverted on Y axis
  97079. */
  97080. invertY: boolean;
  97081. /** @hidden */
  97082. _invertVScale: boolean;
  97083. /** @hidden */
  97084. _associatedChannel: number;
  97085. /** @hidden */
  97086. _source: InternalTextureSource;
  97087. /** @hidden */
  97088. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  97089. /** @hidden */
  97090. _bufferView: Nullable<ArrayBufferView>;
  97091. /** @hidden */
  97092. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97093. /** @hidden */
  97094. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97095. /** @hidden */
  97096. _size: number;
  97097. /** @hidden */
  97098. _extension: string;
  97099. /** @hidden */
  97100. _files: Nullable<string[]>;
  97101. /** @hidden */
  97102. _workingCanvas: Nullable<HTMLCanvasElement>;
  97103. /** @hidden */
  97104. _workingContext: Nullable<CanvasRenderingContext2D>;
  97105. /** @hidden */
  97106. _framebuffer: Nullable<WebGLFramebuffer>;
  97107. /** @hidden */
  97108. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97109. /** @hidden */
  97110. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97111. /** @hidden */
  97112. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97113. /** @hidden */
  97114. _attachments: Nullable<number[]>;
  97115. /** @hidden */
  97116. _cachedCoordinatesMode: Nullable<number>;
  97117. /** @hidden */
  97118. _cachedWrapU: Nullable<number>;
  97119. /** @hidden */
  97120. _cachedWrapV: Nullable<number>;
  97121. /** @hidden */
  97122. _cachedWrapR: Nullable<number>;
  97123. /** @hidden */
  97124. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97125. /** @hidden */
  97126. _isDisabled: boolean;
  97127. /** @hidden */
  97128. _compression: Nullable<string>;
  97129. /** @hidden */
  97130. _generateStencilBuffer: boolean;
  97131. /** @hidden */
  97132. _generateDepthBuffer: boolean;
  97133. /** @hidden */
  97134. _comparisonFunction: number;
  97135. /** @hidden */
  97136. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97137. /** @hidden */
  97138. _lodGenerationScale: number;
  97139. /** @hidden */
  97140. _lodGenerationOffset: number;
  97141. /** @hidden */
  97142. _colorTextureArray: Nullable<WebGLTexture>;
  97143. /** @hidden */
  97144. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97145. /** @hidden */
  97146. _lodTextureHigh: Nullable<BaseTexture>;
  97147. /** @hidden */
  97148. _lodTextureMid: Nullable<BaseTexture>;
  97149. /** @hidden */
  97150. _lodTextureLow: Nullable<BaseTexture>;
  97151. /** @hidden */
  97152. _isRGBD: boolean;
  97153. /** @hidden */
  97154. _linearSpecularLOD: boolean;
  97155. /** @hidden */
  97156. _irradianceTexture: Nullable<BaseTexture>;
  97157. /** @hidden */
  97158. _webGLTexture: Nullable<WebGLTexture>;
  97159. /** @hidden */
  97160. _references: number;
  97161. private _engine;
  97162. /**
  97163. * Gets the Engine the texture belongs to.
  97164. * @returns The babylon engine
  97165. */
  97166. getEngine(): ThinEngine;
  97167. /**
  97168. * Gets the data source type of the texture
  97169. */
  97170. readonly source: InternalTextureSource;
  97171. /**
  97172. * Creates a new InternalTexture
  97173. * @param engine defines the engine to use
  97174. * @param source defines the type of data that will be used
  97175. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97176. */
  97177. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  97178. /**
  97179. * Increments the number of references (ie. the number of Texture that point to it)
  97180. */
  97181. incrementReferences(): void;
  97182. /**
  97183. * Change the size of the texture (not the size of the content)
  97184. * @param width defines the new width
  97185. * @param height defines the new height
  97186. * @param depth defines the new depth (1 by default)
  97187. */
  97188. updateSize(width: int, height: int, depth?: int): void;
  97189. /** @hidden */
  97190. _rebuild(): void;
  97191. /** @hidden */
  97192. _swapAndDie(target: InternalTexture): void;
  97193. /**
  97194. * Dispose the current allocated resources
  97195. */
  97196. dispose(): void;
  97197. }
  97198. }
  97199. declare module BABYLON {
  97200. /**
  97201. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97203. */
  97204. export class Analyser {
  97205. /**
  97206. * Gets or sets the smoothing
  97207. * @ignorenaming
  97208. */
  97209. SMOOTHING: number;
  97210. /**
  97211. * Gets or sets the FFT table size
  97212. * @ignorenaming
  97213. */
  97214. FFT_SIZE: number;
  97215. /**
  97216. * Gets or sets the bar graph amplitude
  97217. * @ignorenaming
  97218. */
  97219. BARGRAPHAMPLITUDE: number;
  97220. /**
  97221. * Gets or sets the position of the debug canvas
  97222. * @ignorenaming
  97223. */
  97224. DEBUGCANVASPOS: {
  97225. x: number;
  97226. y: number;
  97227. };
  97228. /**
  97229. * Gets or sets the debug canvas size
  97230. * @ignorenaming
  97231. */
  97232. DEBUGCANVASSIZE: {
  97233. width: number;
  97234. height: number;
  97235. };
  97236. private _byteFreqs;
  97237. private _byteTime;
  97238. private _floatFreqs;
  97239. private _webAudioAnalyser;
  97240. private _debugCanvas;
  97241. private _debugCanvasContext;
  97242. private _scene;
  97243. private _registerFunc;
  97244. private _audioEngine;
  97245. /**
  97246. * Creates a new analyser
  97247. * @param scene defines hosting scene
  97248. */
  97249. constructor(scene: Scene);
  97250. /**
  97251. * Get the number of data values you will have to play with for the visualization
  97252. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97253. * @returns a number
  97254. */
  97255. getFrequencyBinCount(): number;
  97256. /**
  97257. * Gets the current frequency data as a byte array
  97258. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97259. * @returns a Uint8Array
  97260. */
  97261. getByteFrequencyData(): Uint8Array;
  97262. /**
  97263. * Gets the current waveform as a byte array
  97264. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97265. * @returns a Uint8Array
  97266. */
  97267. getByteTimeDomainData(): Uint8Array;
  97268. /**
  97269. * Gets the current frequency data as a float array
  97270. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97271. * @returns a Float32Array
  97272. */
  97273. getFloatFrequencyData(): Float32Array;
  97274. /**
  97275. * Renders the debug canvas
  97276. */
  97277. drawDebugCanvas(): void;
  97278. /**
  97279. * Stops rendering the debug canvas and removes it
  97280. */
  97281. stopDebugCanvas(): void;
  97282. /**
  97283. * Connects two audio nodes
  97284. * @param inputAudioNode defines first node to connect
  97285. * @param outputAudioNode defines second node to connect
  97286. */
  97287. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97288. /**
  97289. * Releases all associated resources
  97290. */
  97291. dispose(): void;
  97292. }
  97293. }
  97294. declare module BABYLON {
  97295. /**
  97296. * This represents an audio engine and it is responsible
  97297. * to play, synchronize and analyse sounds throughout the application.
  97298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97299. */
  97300. export interface IAudioEngine extends IDisposable {
  97301. /**
  97302. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97303. */
  97304. readonly canUseWebAudio: boolean;
  97305. /**
  97306. * Gets the current AudioContext if available.
  97307. */
  97308. readonly audioContext: Nullable<AudioContext>;
  97309. /**
  97310. * The master gain node defines the global audio volume of your audio engine.
  97311. */
  97312. readonly masterGain: GainNode;
  97313. /**
  97314. * Gets whether or not mp3 are supported by your browser.
  97315. */
  97316. readonly isMP3supported: boolean;
  97317. /**
  97318. * Gets whether or not ogg are supported by your browser.
  97319. */
  97320. readonly isOGGsupported: boolean;
  97321. /**
  97322. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97323. * @ignoreNaming
  97324. */
  97325. WarnedWebAudioUnsupported: boolean;
  97326. /**
  97327. * Defines if the audio engine relies on a custom unlocked button.
  97328. * In this case, the embedded button will not be displayed.
  97329. */
  97330. useCustomUnlockedButton: boolean;
  97331. /**
  97332. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97333. */
  97334. readonly unlocked: boolean;
  97335. /**
  97336. * Event raised when audio has been unlocked on the browser.
  97337. */
  97338. onAudioUnlockedObservable: Observable<AudioEngine>;
  97339. /**
  97340. * Event raised when audio has been locked on the browser.
  97341. */
  97342. onAudioLockedObservable: Observable<AudioEngine>;
  97343. /**
  97344. * Flags the audio engine in Locked state.
  97345. * This happens due to new browser policies preventing audio to autoplay.
  97346. */
  97347. lock(): void;
  97348. /**
  97349. * Unlocks the audio engine once a user action has been done on the dom.
  97350. * This is helpful to resume play once browser policies have been satisfied.
  97351. */
  97352. unlock(): void;
  97353. }
  97354. /**
  97355. * This represents the default audio engine used in babylon.
  97356. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97358. */
  97359. export class AudioEngine implements IAudioEngine {
  97360. private _audioContext;
  97361. private _audioContextInitialized;
  97362. private _muteButton;
  97363. private _hostElement;
  97364. /**
  97365. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97366. */
  97367. canUseWebAudio: boolean;
  97368. /**
  97369. * The master gain node defines the global audio volume of your audio engine.
  97370. */
  97371. masterGain: GainNode;
  97372. /**
  97373. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97374. * @ignoreNaming
  97375. */
  97376. WarnedWebAudioUnsupported: boolean;
  97377. /**
  97378. * Gets whether or not mp3 are supported by your browser.
  97379. */
  97380. isMP3supported: boolean;
  97381. /**
  97382. * Gets whether or not ogg are supported by your browser.
  97383. */
  97384. isOGGsupported: boolean;
  97385. /**
  97386. * Gets whether audio has been unlocked on the device.
  97387. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  97388. * a user interaction has happened.
  97389. */
  97390. unlocked: boolean;
  97391. /**
  97392. * Defines if the audio engine relies on a custom unlocked button.
  97393. * In this case, the embedded button will not be displayed.
  97394. */
  97395. useCustomUnlockedButton: boolean;
  97396. /**
  97397. * Event raised when audio has been unlocked on the browser.
  97398. */
  97399. onAudioUnlockedObservable: Observable<AudioEngine>;
  97400. /**
  97401. * Event raised when audio has been locked on the browser.
  97402. */
  97403. onAudioLockedObservable: Observable<AudioEngine>;
  97404. /**
  97405. * Gets the current AudioContext if available.
  97406. */
  97407. readonly audioContext: Nullable<AudioContext>;
  97408. private _connectedAnalyser;
  97409. /**
  97410. * Instantiates a new audio engine.
  97411. *
  97412. * There should be only one per page as some browsers restrict the number
  97413. * of audio contexts you can create.
  97414. * @param hostElement defines the host element where to display the mute icon if necessary
  97415. */
  97416. constructor(hostElement?: Nullable<HTMLElement>);
  97417. /**
  97418. * Flags the audio engine in Locked state.
  97419. * This happens due to new browser policies preventing audio to autoplay.
  97420. */
  97421. lock(): void;
  97422. /**
  97423. * Unlocks the audio engine once a user action has been done on the dom.
  97424. * This is helpful to resume play once browser policies have been satisfied.
  97425. */
  97426. unlock(): void;
  97427. private _resumeAudioContext;
  97428. private _initializeAudioContext;
  97429. private _tryToRun;
  97430. private _triggerRunningState;
  97431. private _triggerSuspendedState;
  97432. private _displayMuteButton;
  97433. private _moveButtonToTopLeft;
  97434. private _onResize;
  97435. private _hideMuteButton;
  97436. /**
  97437. * Destroy and release the resources associated with the audio ccontext.
  97438. */
  97439. dispose(): void;
  97440. /**
  97441. * Gets the global volume sets on the master gain.
  97442. * @returns the global volume if set or -1 otherwise
  97443. */
  97444. getGlobalVolume(): number;
  97445. /**
  97446. * Sets the global volume of your experience (sets on the master gain).
  97447. * @param newVolume Defines the new global volume of the application
  97448. */
  97449. setGlobalVolume(newVolume: number): void;
  97450. /**
  97451. * Connect the audio engine to an audio analyser allowing some amazing
  97452. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97454. * @param analyser The analyser to connect to the engine
  97455. */
  97456. connectToAnalyser(analyser: Analyser): void;
  97457. }
  97458. }
  97459. declare module BABYLON {
  97460. /**
  97461. * Interface used to present a loading screen while loading a scene
  97462. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97463. */
  97464. export interface ILoadingScreen {
  97465. /**
  97466. * Function called to display the loading screen
  97467. */
  97468. displayLoadingUI: () => void;
  97469. /**
  97470. * Function called to hide the loading screen
  97471. */
  97472. hideLoadingUI: () => void;
  97473. /**
  97474. * Gets or sets the color to use for the background
  97475. */
  97476. loadingUIBackgroundColor: string;
  97477. /**
  97478. * Gets or sets the text to display while loading
  97479. */
  97480. loadingUIText: string;
  97481. }
  97482. /**
  97483. * Class used for the default loading screen
  97484. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97485. */
  97486. export class DefaultLoadingScreen implements ILoadingScreen {
  97487. private _renderingCanvas;
  97488. private _loadingText;
  97489. private _loadingDivBackgroundColor;
  97490. private _loadingDiv;
  97491. private _loadingTextDiv;
  97492. /** Gets or sets the logo url to use for the default loading screen */
  97493. static DefaultLogoUrl: string;
  97494. /** Gets or sets the spinner url to use for the default loading screen */
  97495. static DefaultSpinnerUrl: string;
  97496. /**
  97497. * Creates a new default loading screen
  97498. * @param _renderingCanvas defines the canvas used to render the scene
  97499. * @param _loadingText defines the default text to display
  97500. * @param _loadingDivBackgroundColor defines the default background color
  97501. */
  97502. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  97503. /**
  97504. * Function called to display the loading screen
  97505. */
  97506. displayLoadingUI(): void;
  97507. /**
  97508. * Function called to hide the loading screen
  97509. */
  97510. hideLoadingUI(): void;
  97511. /**
  97512. * Gets or sets the text to display while loading
  97513. */
  97514. loadingUIText: string;
  97515. /**
  97516. * Gets or sets the color to use for the background
  97517. */
  97518. loadingUIBackgroundColor: string;
  97519. private _resizeLoadingUI;
  97520. }
  97521. }
  97522. declare module BABYLON {
  97523. /**
  97524. * Interface for any object that can request an animation frame
  97525. */
  97526. export interface ICustomAnimationFrameRequester {
  97527. /**
  97528. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  97529. */
  97530. renderFunction?: Function;
  97531. /**
  97532. * Called to request the next frame to render to
  97533. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  97534. */
  97535. requestAnimationFrame: Function;
  97536. /**
  97537. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  97538. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  97539. */
  97540. requestID?: number;
  97541. }
  97542. }
  97543. declare module BABYLON {
  97544. /**
  97545. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97546. */
  97547. export class PerformanceMonitor {
  97548. private _enabled;
  97549. private _rollingFrameTime;
  97550. private _lastFrameTimeMs;
  97551. /**
  97552. * constructor
  97553. * @param frameSampleSize The number of samples required to saturate the sliding window
  97554. */
  97555. constructor(frameSampleSize?: number);
  97556. /**
  97557. * Samples current frame
  97558. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97559. */
  97560. sampleFrame(timeMs?: number): void;
  97561. /**
  97562. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97563. */
  97564. readonly averageFrameTime: number;
  97565. /**
  97566. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97567. */
  97568. readonly averageFrameTimeVariance: number;
  97569. /**
  97570. * Returns the frame time of the most recent frame
  97571. */
  97572. readonly instantaneousFrameTime: number;
  97573. /**
  97574. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  97575. */
  97576. readonly averageFPS: number;
  97577. /**
  97578. * Returns the average framerate in frames per second using the most recent frame time
  97579. */
  97580. readonly instantaneousFPS: number;
  97581. /**
  97582. * Returns true if enough samples have been taken to completely fill the sliding window
  97583. */
  97584. readonly isSaturated: boolean;
  97585. /**
  97586. * Enables contributions to the sliding window sample set
  97587. */
  97588. enable(): void;
  97589. /**
  97590. * Disables contributions to the sliding window sample set
  97591. * Samples will not be interpolated over the disabled period
  97592. */
  97593. disable(): void;
  97594. /**
  97595. * Returns true if sampling is enabled
  97596. */
  97597. readonly isEnabled: boolean;
  97598. /**
  97599. * Resets performance monitor
  97600. */
  97601. reset(): void;
  97602. }
  97603. /**
  97604. * RollingAverage
  97605. *
  97606. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  97607. */
  97608. export class RollingAverage {
  97609. /**
  97610. * Current average
  97611. */
  97612. average: number;
  97613. /**
  97614. * Current variance
  97615. */
  97616. variance: number;
  97617. protected _samples: Array<number>;
  97618. protected _sampleCount: number;
  97619. protected _pos: number;
  97620. protected _m2: number;
  97621. /**
  97622. * constructor
  97623. * @param length The number of samples required to saturate the sliding window
  97624. */
  97625. constructor(length: number);
  97626. /**
  97627. * Adds a sample to the sample set
  97628. * @param v The sample value
  97629. */
  97630. add(v: number): void;
  97631. /**
  97632. * Returns previously added values or null if outside of history or outside the sliding window domain
  97633. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  97634. * @return Value previously recorded with add() or null if outside of range
  97635. */
  97636. history(i: number): number;
  97637. /**
  97638. * Returns true if enough samples have been taken to completely fill the sliding window
  97639. * @return true if sample-set saturated
  97640. */
  97641. isSaturated(): boolean;
  97642. /**
  97643. * Resets the rolling average (equivalent to 0 samples taken so far)
  97644. */
  97645. reset(): void;
  97646. /**
  97647. * Wraps a value around the sample range boundaries
  97648. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  97649. * @return Wrapped position in sample range
  97650. */
  97651. protected _wrapPosition(i: number): number;
  97652. }
  97653. }
  97654. declare module BABYLON {
  97655. /**
  97656. * This class is used to track a performance counter which is number based.
  97657. * The user has access to many properties which give statistics of different nature.
  97658. *
  97659. * The implementer can track two kinds of Performance Counter: time and count.
  97660. * 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.
  97661. * 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.
  97662. */
  97663. export class PerfCounter {
  97664. /**
  97665. * Gets or sets a global boolean to turn on and off all the counters
  97666. */
  97667. static Enabled: boolean;
  97668. /**
  97669. * Returns the smallest value ever
  97670. */
  97671. readonly min: number;
  97672. /**
  97673. * Returns the biggest value ever
  97674. */
  97675. readonly max: number;
  97676. /**
  97677. * Returns the average value since the performance counter is running
  97678. */
  97679. readonly average: number;
  97680. /**
  97681. * Returns the average value of the last second the counter was monitored
  97682. */
  97683. readonly lastSecAverage: number;
  97684. /**
  97685. * Returns the current value
  97686. */
  97687. readonly current: number;
  97688. /**
  97689. * Gets the accumulated total
  97690. */
  97691. readonly total: number;
  97692. /**
  97693. * Gets the total value count
  97694. */
  97695. readonly count: number;
  97696. /**
  97697. * Creates a new counter
  97698. */
  97699. constructor();
  97700. /**
  97701. * Call this method to start monitoring a new frame.
  97702. * 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.
  97703. */
  97704. fetchNewFrame(): void;
  97705. /**
  97706. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  97707. * @param newCount the count value to add to the monitored count
  97708. * @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.
  97709. */
  97710. addCount(newCount: number, fetchResult: boolean): void;
  97711. /**
  97712. * Start monitoring this performance counter
  97713. */
  97714. beginMonitoring(): void;
  97715. /**
  97716. * Compute the time lapsed since the previous beginMonitoring() call.
  97717. * @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
  97718. */
  97719. endMonitoring(newFrame?: boolean): void;
  97720. private _fetchResult;
  97721. private _startMonitoringTime;
  97722. private _min;
  97723. private _max;
  97724. private _average;
  97725. private _current;
  97726. private _totalValueCount;
  97727. private _totalAccumulated;
  97728. private _lastSecAverage;
  97729. private _lastSecAccumulated;
  97730. private _lastSecTime;
  97731. private _lastSecValueCount;
  97732. }
  97733. }
  97734. declare module BABYLON {
  97735. /**
  97736. * Defines the interface used by display changed events
  97737. */
  97738. export interface IDisplayChangedEventArgs {
  97739. /** Gets the vrDisplay object (if any) */
  97740. vrDisplay: Nullable<any>;
  97741. /** Gets a boolean indicating if webVR is supported */
  97742. vrSupported: boolean;
  97743. }
  97744. /**
  97745. * Defines the interface used by objects containing a viewport (like a camera)
  97746. */
  97747. interface IViewportOwnerLike {
  97748. /**
  97749. * Gets or sets the viewport
  97750. */
  97751. viewport: IViewportLike;
  97752. }
  97753. /**
  97754. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  97755. */
  97756. export class Engine extends ThinEngine {
  97757. /** Defines that alpha blending is disabled */
  97758. static readonly ALPHA_DISABLE: number;
  97759. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  97760. static readonly ALPHA_ADD: number;
  97761. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  97762. static readonly ALPHA_COMBINE: number;
  97763. /** Defines that alpha blending to DEST - SRC * DEST */
  97764. static readonly ALPHA_SUBTRACT: number;
  97765. /** Defines that alpha blending to SRC * DEST */
  97766. static readonly ALPHA_MULTIPLY: number;
  97767. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  97768. static readonly ALPHA_MAXIMIZED: number;
  97769. /** Defines that alpha blending to SRC + DEST */
  97770. static readonly ALPHA_ONEONE: number;
  97771. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  97772. static readonly ALPHA_PREMULTIPLIED: number;
  97773. /**
  97774. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  97775. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  97776. */
  97777. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  97778. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  97779. static readonly ALPHA_INTERPOLATE: number;
  97780. /**
  97781. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  97782. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  97783. */
  97784. static readonly ALPHA_SCREENMODE: number;
  97785. /** Defines that the ressource is not delayed*/
  97786. static readonly DELAYLOADSTATE_NONE: number;
  97787. /** Defines that the ressource was successfully delay loaded */
  97788. static readonly DELAYLOADSTATE_LOADED: number;
  97789. /** Defines that the ressource is currently delay loading */
  97790. static readonly DELAYLOADSTATE_LOADING: number;
  97791. /** Defines that the ressource is delayed and has not started loading */
  97792. static readonly DELAYLOADSTATE_NOTLOADED: number;
  97793. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  97794. static readonly NEVER: number;
  97795. /** 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 */
  97796. static readonly ALWAYS: number;
  97797. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  97798. static readonly LESS: number;
  97799. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  97800. static readonly EQUAL: number;
  97801. /** 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 */
  97802. static readonly LEQUAL: number;
  97803. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  97804. static readonly GREATER: number;
  97805. /** 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 */
  97806. static readonly GEQUAL: number;
  97807. /** 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 */
  97808. static readonly NOTEQUAL: number;
  97809. /** Passed to stencilOperation to specify that stencil value must be kept */
  97810. static readonly KEEP: number;
  97811. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97812. static readonly REPLACE: number;
  97813. /** Passed to stencilOperation to specify that stencil value must be incremented */
  97814. static readonly INCR: number;
  97815. /** Passed to stencilOperation to specify that stencil value must be decremented */
  97816. static readonly DECR: number;
  97817. /** Passed to stencilOperation to specify that stencil value must be inverted */
  97818. static readonly INVERT: number;
  97819. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  97820. static readonly INCR_WRAP: number;
  97821. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  97822. static readonly DECR_WRAP: number;
  97823. /** Texture is not repeating outside of 0..1 UVs */
  97824. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  97825. /** Texture is repeating outside of 0..1 UVs */
  97826. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  97827. /** Texture is repeating and mirrored */
  97828. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  97829. /** ALPHA */
  97830. static readonly TEXTUREFORMAT_ALPHA: number;
  97831. /** LUMINANCE */
  97832. static readonly TEXTUREFORMAT_LUMINANCE: number;
  97833. /** LUMINANCE_ALPHA */
  97834. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  97835. /** RGB */
  97836. static readonly TEXTUREFORMAT_RGB: number;
  97837. /** RGBA */
  97838. static readonly TEXTUREFORMAT_RGBA: number;
  97839. /** RED */
  97840. static readonly TEXTUREFORMAT_RED: number;
  97841. /** RED (2nd reference) */
  97842. static readonly TEXTUREFORMAT_R: number;
  97843. /** RG */
  97844. static readonly TEXTUREFORMAT_RG: number;
  97845. /** RED_INTEGER */
  97846. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  97847. /** RED_INTEGER (2nd reference) */
  97848. static readonly TEXTUREFORMAT_R_INTEGER: number;
  97849. /** RG_INTEGER */
  97850. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  97851. /** RGB_INTEGER */
  97852. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  97853. /** RGBA_INTEGER */
  97854. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  97855. /** UNSIGNED_BYTE */
  97856. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  97857. /** UNSIGNED_BYTE (2nd reference) */
  97858. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  97859. /** FLOAT */
  97860. static readonly TEXTURETYPE_FLOAT: number;
  97861. /** HALF_FLOAT */
  97862. static readonly TEXTURETYPE_HALF_FLOAT: number;
  97863. /** BYTE */
  97864. static readonly TEXTURETYPE_BYTE: number;
  97865. /** SHORT */
  97866. static readonly TEXTURETYPE_SHORT: number;
  97867. /** UNSIGNED_SHORT */
  97868. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  97869. /** INT */
  97870. static readonly TEXTURETYPE_INT: number;
  97871. /** UNSIGNED_INT */
  97872. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  97873. /** UNSIGNED_SHORT_4_4_4_4 */
  97874. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  97875. /** UNSIGNED_SHORT_5_5_5_1 */
  97876. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  97877. /** UNSIGNED_SHORT_5_6_5 */
  97878. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  97879. /** UNSIGNED_INT_2_10_10_10_REV */
  97880. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  97881. /** UNSIGNED_INT_24_8 */
  97882. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  97883. /** UNSIGNED_INT_10F_11F_11F_REV */
  97884. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  97885. /** UNSIGNED_INT_5_9_9_9_REV */
  97886. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  97887. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  97888. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  97889. /** nearest is mag = nearest and min = nearest and mip = linear */
  97890. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  97891. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97892. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  97893. /** Trilinear is mag = linear and min = linear and mip = linear */
  97894. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  97895. /** nearest is mag = nearest and min = nearest and mip = linear */
  97896. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  97897. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97898. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  97899. /** Trilinear is mag = linear and min = linear and mip = linear */
  97900. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  97901. /** mag = nearest and min = nearest and mip = nearest */
  97902. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  97903. /** mag = nearest and min = linear and mip = nearest */
  97904. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  97905. /** mag = nearest and min = linear and mip = linear */
  97906. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  97907. /** mag = nearest and min = linear and mip = none */
  97908. static readonly TEXTURE_NEAREST_LINEAR: number;
  97909. /** mag = nearest and min = nearest and mip = none */
  97910. static readonly TEXTURE_NEAREST_NEAREST: number;
  97911. /** mag = linear and min = nearest and mip = nearest */
  97912. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  97913. /** mag = linear and min = nearest and mip = linear */
  97914. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  97915. /** mag = linear and min = linear and mip = none */
  97916. static readonly TEXTURE_LINEAR_LINEAR: number;
  97917. /** mag = linear and min = nearest and mip = none */
  97918. static readonly TEXTURE_LINEAR_NEAREST: number;
  97919. /** Explicit coordinates mode */
  97920. static readonly TEXTURE_EXPLICIT_MODE: number;
  97921. /** Spherical coordinates mode */
  97922. static readonly TEXTURE_SPHERICAL_MODE: number;
  97923. /** Planar coordinates mode */
  97924. static readonly TEXTURE_PLANAR_MODE: number;
  97925. /** Cubic coordinates mode */
  97926. static readonly TEXTURE_CUBIC_MODE: number;
  97927. /** Projection coordinates mode */
  97928. static readonly TEXTURE_PROJECTION_MODE: number;
  97929. /** Skybox coordinates mode */
  97930. static readonly TEXTURE_SKYBOX_MODE: number;
  97931. /** Inverse Cubic coordinates mode */
  97932. static readonly TEXTURE_INVCUBIC_MODE: number;
  97933. /** Equirectangular coordinates mode */
  97934. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  97935. /** Equirectangular Fixed coordinates mode */
  97936. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  97937. /** Equirectangular Fixed Mirrored coordinates mode */
  97938. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  97939. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  97940. static readonly SCALEMODE_FLOOR: number;
  97941. /** Defines that texture rescaling will look for the nearest power of 2 size */
  97942. static readonly SCALEMODE_NEAREST: number;
  97943. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  97944. static readonly SCALEMODE_CEILING: number;
  97945. /**
  97946. * Returns the current npm package of the sdk
  97947. */
  97948. static readonly NpmPackage: string;
  97949. /**
  97950. * Returns the current version of the framework
  97951. */
  97952. static readonly Version: string;
  97953. /** Gets the list of created engines */
  97954. static readonly Instances: Engine[];
  97955. /**
  97956. * Gets the latest created engine
  97957. */
  97958. static readonly LastCreatedEngine: Nullable<Engine>;
  97959. /**
  97960. * Gets the latest created scene
  97961. */
  97962. static readonly LastCreatedScene: Nullable<Scene>;
  97963. /**
  97964. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  97965. * @param flag defines which part of the materials must be marked as dirty
  97966. * @param predicate defines a predicate used to filter which materials should be affected
  97967. */
  97968. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  97969. /**
  97970. * Method called to create the default loading screen.
  97971. * This can be overriden in your own app.
  97972. * @param canvas The rendering canvas element
  97973. * @returns The loading screen
  97974. */
  97975. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  97976. /**
  97977. * Method called to create the default rescale post process on each engine.
  97978. */
  97979. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  97980. /**
  97981. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  97982. **/
  97983. enableOfflineSupport: boolean;
  97984. /**
  97985. * 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)
  97986. **/
  97987. disableManifestCheck: boolean;
  97988. /**
  97989. * Gets the list of created scenes
  97990. */
  97991. scenes: Scene[];
  97992. /**
  97993. * Event raised when a new scene is created
  97994. */
  97995. onNewSceneAddedObservable: Observable<Scene>;
  97996. /**
  97997. * Gets the list of created postprocesses
  97998. */
  97999. postProcesses: PostProcess[];
  98000. /**
  98001. * Gets a boolean indicating if the pointer is currently locked
  98002. */
  98003. isPointerLock: boolean;
  98004. /**
  98005. * Observable event triggered each time the rendering canvas is resized
  98006. */
  98007. onResizeObservable: Observable<Engine>;
  98008. /**
  98009. * Observable event triggered each time the canvas loses focus
  98010. */
  98011. onCanvasBlurObservable: Observable<Engine>;
  98012. /**
  98013. * Observable event triggered each time the canvas gains focus
  98014. */
  98015. onCanvasFocusObservable: Observable<Engine>;
  98016. /**
  98017. * Observable event triggered each time the canvas receives pointerout event
  98018. */
  98019. onCanvasPointerOutObservable: Observable<PointerEvent>;
  98020. /**
  98021. * Observable raised when the engine begins a new frame
  98022. */
  98023. onBeginFrameObservable: Observable<Engine>;
  98024. /**
  98025. * If set, will be used to request the next animation frame for the render loop
  98026. */
  98027. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  98028. /**
  98029. * Observable raised when the engine ends the current frame
  98030. */
  98031. onEndFrameObservable: Observable<Engine>;
  98032. /**
  98033. * Observable raised when the engine is about to compile a shader
  98034. */
  98035. onBeforeShaderCompilationObservable: Observable<Engine>;
  98036. /**
  98037. * Observable raised when the engine has jsut compiled a shader
  98038. */
  98039. onAfterShaderCompilationObservable: Observable<Engine>;
  98040. /**
  98041. * Gets the audio engine
  98042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98043. * @ignorenaming
  98044. */
  98045. static audioEngine: IAudioEngine;
  98046. /**
  98047. * Default AudioEngine factory responsible of creating the Audio Engine.
  98048. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98049. */
  98050. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98051. /**
  98052. * Default offline support factory responsible of creating a tool used to store data locally.
  98053. * By default, this will create a Database object if the workload has been embedded.
  98054. */
  98055. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98056. private _loadingScreen;
  98057. private _pointerLockRequested;
  98058. private _dummyFramebuffer;
  98059. private _rescalePostProcess;
  98060. /** @hidden */
  98061. protected _alphaMode: number;
  98062. /** @hidden */
  98063. protected _alphaEquation: number;
  98064. private _deterministicLockstep;
  98065. private _lockstepMaxSteps;
  98066. protected readonly _supportsHardwareTextureRescaling: boolean;
  98067. private _fps;
  98068. private _deltaTime;
  98069. /** @hidden */
  98070. _drawCalls: PerfCounter;
  98071. /**
  98072. * Turn this value on if you want to pause FPS computation when in background
  98073. */
  98074. disablePerformanceMonitorInBackground: boolean;
  98075. private _performanceMonitor;
  98076. /**
  98077. * Gets the performance monitor attached to this engine
  98078. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  98079. */
  98080. readonly performanceMonitor: PerformanceMonitor;
  98081. private _onFocus;
  98082. private _onBlur;
  98083. private _onCanvasPointerOut;
  98084. private _onCanvasBlur;
  98085. private _onCanvasFocus;
  98086. private _onFullscreenChange;
  98087. private _onPointerLockChange;
  98088. /**
  98089. * Creates a new engine
  98090. * @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
  98091. * @param antialias defines enable antialiasing (default: false)
  98092. * @param options defines further options to be sent to the getContext() function
  98093. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98094. */
  98095. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98096. /**
  98097. * Gets current aspect ratio
  98098. * @param viewportOwner defines the camera to use to get the aspect ratio
  98099. * @param useScreen defines if screen size must be used (or the current render target if any)
  98100. * @returns a number defining the aspect ratio
  98101. */
  98102. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  98103. /**
  98104. * Gets current screen aspect ratio
  98105. * @returns a number defining the aspect ratio
  98106. */
  98107. getScreenAspectRatio(): number;
  98108. /**
  98109. * Gets host document
  98110. * @returns the host document object
  98111. */
  98112. getHostDocument(): Document;
  98113. /**
  98114. * Gets the client rect of the HTML canvas attached with the current webGL context
  98115. * @returns a client rectanglee
  98116. */
  98117. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98118. /**
  98119. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98120. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98121. * @returns true if engine is in deterministic lock step mode
  98122. */
  98123. isDeterministicLockStep(): boolean;
  98124. /**
  98125. * Gets the max steps when engine is running in deterministic lock step
  98126. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98127. * @returns the max steps
  98128. */
  98129. getLockstepMaxSteps(): number;
  98130. /**
  98131. * Force the mipmap generation for the given render target texture
  98132. * @param texture defines the render target texture to use
  98133. */
  98134. generateMipMapsForCubemap(texture: InternalTexture): void;
  98135. /** States */
  98136. /**
  98137. * Set various states to the webGL context
  98138. * @param culling defines backface culling state
  98139. * @param zOffset defines the value to apply to zOffset (0 by default)
  98140. * @param force defines if states must be applied even if cache is up to date
  98141. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98142. */
  98143. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98144. /**
  98145. * Set the z offset to apply to current rendering
  98146. * @param value defines the offset to apply
  98147. */
  98148. setZOffset(value: number): void;
  98149. /**
  98150. * Gets the current value of the zOffset
  98151. * @returns the current zOffset state
  98152. */
  98153. getZOffset(): number;
  98154. /**
  98155. * Enable or disable depth buffering
  98156. * @param enable defines the state to set
  98157. */
  98158. setDepthBuffer(enable: boolean): void;
  98159. /**
  98160. * Gets a boolean indicating if depth writing is enabled
  98161. * @returns the current depth writing state
  98162. */
  98163. getDepthWrite(): boolean;
  98164. /**
  98165. * Enable or disable depth writing
  98166. * @param enable defines the state to set
  98167. */
  98168. setDepthWrite(enable: boolean): void;
  98169. /**
  98170. * Enable or disable color writing
  98171. * @param enable defines the state to set
  98172. */
  98173. setColorWrite(enable: boolean): void;
  98174. /**
  98175. * Gets a boolean indicating if color writing is enabled
  98176. * @returns the current color writing state
  98177. */
  98178. getColorWrite(): boolean;
  98179. /**
  98180. * Sets alpha constants used by some alpha blending modes
  98181. * @param r defines the red component
  98182. * @param g defines the green component
  98183. * @param b defines the blue component
  98184. * @param a defines the alpha component
  98185. */
  98186. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98187. /**
  98188. * Sets the current alpha mode
  98189. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98190. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98191. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98192. */
  98193. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98194. /**
  98195. * Gets the current alpha mode
  98196. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98197. * @returns the current alpha mode
  98198. */
  98199. getAlphaMode(): number;
  98200. /**
  98201. * Sets the current alpha equation
  98202. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98203. */
  98204. setAlphaEquation(equation: number): void;
  98205. /**
  98206. * Gets the current alpha equation.
  98207. * @returns the current alpha equation
  98208. */
  98209. getAlphaEquation(): number;
  98210. /**
  98211. * Gets a boolean indicating if stencil buffer is enabled
  98212. * @returns the current stencil buffer state
  98213. */
  98214. getStencilBuffer(): boolean;
  98215. /**
  98216. * Enable or disable the stencil buffer
  98217. * @param enable defines if the stencil buffer must be enabled or disabled
  98218. */
  98219. setStencilBuffer(enable: boolean): void;
  98220. /**
  98221. * Gets the current stencil mask
  98222. * @returns a number defining the new stencil mask to use
  98223. */
  98224. getStencilMask(): number;
  98225. /**
  98226. * Sets the current stencil mask
  98227. * @param mask defines the new stencil mask to use
  98228. */
  98229. setStencilMask(mask: number): void;
  98230. /**
  98231. * Gets the current stencil function
  98232. * @returns a number defining the stencil function to use
  98233. */
  98234. getStencilFunction(): number;
  98235. /**
  98236. * Gets the current stencil reference value
  98237. * @returns a number defining the stencil reference value to use
  98238. */
  98239. getStencilFunctionReference(): number;
  98240. /**
  98241. * Gets the current stencil mask
  98242. * @returns a number defining the stencil mask to use
  98243. */
  98244. getStencilFunctionMask(): number;
  98245. /**
  98246. * Sets the current stencil function
  98247. * @param stencilFunc defines the new stencil function to use
  98248. */
  98249. setStencilFunction(stencilFunc: number): void;
  98250. /**
  98251. * Sets the current stencil reference
  98252. * @param reference defines the new stencil reference to use
  98253. */
  98254. setStencilFunctionReference(reference: number): void;
  98255. /**
  98256. * Sets the current stencil mask
  98257. * @param mask defines the new stencil mask to use
  98258. */
  98259. setStencilFunctionMask(mask: number): void;
  98260. /**
  98261. * Gets the current stencil operation when stencil fails
  98262. * @returns a number defining stencil operation to use when stencil fails
  98263. */
  98264. getStencilOperationFail(): number;
  98265. /**
  98266. * Gets the current stencil operation when depth fails
  98267. * @returns a number defining stencil operation to use when depth fails
  98268. */
  98269. getStencilOperationDepthFail(): number;
  98270. /**
  98271. * Gets the current stencil operation when stencil passes
  98272. * @returns a number defining stencil operation to use when stencil passes
  98273. */
  98274. getStencilOperationPass(): number;
  98275. /**
  98276. * Sets the stencil operation to use when stencil fails
  98277. * @param operation defines the stencil operation to use when stencil fails
  98278. */
  98279. setStencilOperationFail(operation: number): void;
  98280. /**
  98281. * Sets the stencil operation to use when depth fails
  98282. * @param operation defines the stencil operation to use when depth fails
  98283. */
  98284. setStencilOperationDepthFail(operation: number): void;
  98285. /**
  98286. * Sets the stencil operation to use when stencil passes
  98287. * @param operation defines the stencil operation to use when stencil passes
  98288. */
  98289. setStencilOperationPass(operation: number): void;
  98290. /**
  98291. * Sets a boolean indicating if the dithering state is enabled or disabled
  98292. * @param value defines the dithering state
  98293. */
  98294. setDitheringState(value: boolean): void;
  98295. /**
  98296. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  98297. * @param value defines the rasterizer state
  98298. */
  98299. setRasterizerState(value: boolean): void;
  98300. /**
  98301. * Gets the current depth function
  98302. * @returns a number defining the depth function
  98303. */
  98304. getDepthFunction(): Nullable<number>;
  98305. /**
  98306. * Sets the current depth function
  98307. * @param depthFunc defines the function to use
  98308. */
  98309. setDepthFunction(depthFunc: number): void;
  98310. /**
  98311. * Sets the current depth function to GREATER
  98312. */
  98313. setDepthFunctionToGreater(): void;
  98314. /**
  98315. * Sets the current depth function to GEQUAL
  98316. */
  98317. setDepthFunctionToGreaterOrEqual(): void;
  98318. /**
  98319. * Sets the current depth function to LESS
  98320. */
  98321. setDepthFunctionToLess(): void;
  98322. /**
  98323. * Sets the current depth function to LEQUAL
  98324. */
  98325. setDepthFunctionToLessOrEqual(): void;
  98326. private _cachedStencilBuffer;
  98327. private _cachedStencilFunction;
  98328. private _cachedStencilMask;
  98329. private _cachedStencilOperationPass;
  98330. private _cachedStencilOperationFail;
  98331. private _cachedStencilOperationDepthFail;
  98332. private _cachedStencilReference;
  98333. /**
  98334. * Caches the the state of the stencil buffer
  98335. */
  98336. cacheStencilState(): void;
  98337. /**
  98338. * Restores the state of the stencil buffer
  98339. */
  98340. restoreStencilState(): void;
  98341. /**
  98342. * Directly set the WebGL Viewport
  98343. * @param x defines the x coordinate of the viewport (in screen space)
  98344. * @param y defines the y coordinate of the viewport (in screen space)
  98345. * @param width defines the width of the viewport (in screen space)
  98346. * @param height defines the height of the viewport (in screen space)
  98347. * @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
  98348. */
  98349. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  98350. /**
  98351. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  98352. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98353. * @param y defines the y-coordinate of the corner of the clear rectangle
  98354. * @param width defines the width of the clear rectangle
  98355. * @param height defines the height of the clear rectangle
  98356. * @param clearColor defines the clear color
  98357. */
  98358. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  98359. /**
  98360. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  98361. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98362. * @param y defines the y-coordinate of the corner of the clear rectangle
  98363. * @param width defines the width of the clear rectangle
  98364. * @param height defines the height of the clear rectangle
  98365. */
  98366. enableScissor(x: number, y: number, width: number, height: number): void;
  98367. /**
  98368. * Disable previously set scissor test rectangle
  98369. */
  98370. disableScissor(): void;
  98371. protected _reportDrawCall(): void;
  98372. /**
  98373. * Initializes a webVR display and starts listening to display change events
  98374. * The onVRDisplayChangedObservable will be notified upon these changes
  98375. * @returns The onVRDisplayChangedObservable
  98376. */
  98377. initWebVR(): Observable<IDisplayChangedEventArgs>;
  98378. /** @hidden */
  98379. _prepareVRComponent(): void;
  98380. /** @hidden */
  98381. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  98382. /** @hidden */
  98383. _submitVRFrame(): void;
  98384. /**
  98385. * Call this function to leave webVR mode
  98386. * Will do nothing if webVR is not supported or if there is no webVR device
  98387. * @see http://doc.babylonjs.com/how_to/webvr_camera
  98388. */
  98389. disableVR(): void;
  98390. /**
  98391. * Gets a boolean indicating that the system is in VR mode and is presenting
  98392. * @returns true if VR mode is engaged
  98393. */
  98394. isVRPresenting(): boolean;
  98395. /** @hidden */
  98396. _requestVRFrame(): void;
  98397. /** @hidden */
  98398. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98399. /**
  98400. * Gets the source code of the vertex shader associated with a specific webGL program
  98401. * @param program defines the program to use
  98402. * @returns a string containing the source code of the vertex shader associated with the program
  98403. */
  98404. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  98405. /**
  98406. * Gets the source code of the fragment shader associated with a specific webGL program
  98407. * @param program defines the program to use
  98408. * @returns a string containing the source code of the fragment shader associated with the program
  98409. */
  98410. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  98411. /**
  98412. * Reads pixels from the current frame buffer. Please note that this function can be slow
  98413. * @param x defines the x coordinate of the rectangle where pixels must be read
  98414. * @param y defines the y coordinate of the rectangle where pixels must be read
  98415. * @param width defines the width of the rectangle where pixels must be read
  98416. * @param height defines the height of the rectangle where pixels must be read
  98417. * @returns a Uint8Array containing RGBA colors
  98418. */
  98419. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  98420. /**
  98421. * Sets a depth stencil texture from a render target to the according uniform.
  98422. * @param channel The texture channel
  98423. * @param uniform The uniform to set
  98424. * @param texture The render target texture containing the depth stencil texture to apply
  98425. */
  98426. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  98427. /**
  98428. * Sets a texture to the webGL context from a postprocess
  98429. * @param channel defines the channel to use
  98430. * @param postProcess defines the source postprocess
  98431. */
  98432. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  98433. /**
  98434. * Binds the output of the passed in post process to the texture channel specified
  98435. * @param channel The channel the texture should be bound to
  98436. * @param postProcess The post process which's output should be bound
  98437. */
  98438. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  98439. /** @hidden */
  98440. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  98441. protected _rebuildBuffers(): void;
  98442. _renderLoop(): void;
  98443. /**
  98444. * Toggle full screen mode
  98445. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98446. */
  98447. switchFullscreen(requestPointerLock: boolean): void;
  98448. /**
  98449. * Enters full screen mode
  98450. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98451. */
  98452. enterFullscreen(requestPointerLock: boolean): void;
  98453. /**
  98454. * Exits full screen mode
  98455. */
  98456. exitFullscreen(): void;
  98457. /**
  98458. * Enters Pointerlock mode
  98459. */
  98460. enterPointerlock(): void;
  98461. /**
  98462. * Exits Pointerlock mode
  98463. */
  98464. exitPointerlock(): void;
  98465. /**
  98466. * Begin a new frame
  98467. */
  98468. beginFrame(): void;
  98469. /**
  98470. * Enf the current frame
  98471. */
  98472. endFrame(): void;
  98473. resize(): void;
  98474. /**
  98475. * Set the compressed texture format to use, based on the formats you have, and the formats
  98476. * supported by the hardware / browser.
  98477. *
  98478. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  98479. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  98480. * to API arguments needed to compressed textures. This puts the burden on the container
  98481. * generator to house the arcane code for determining these for current & future formats.
  98482. *
  98483. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  98484. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  98485. *
  98486. * Note: The result of this call is not taken into account when a texture is base64.
  98487. *
  98488. * @param formatsAvailable defines the list of those format families you have created
  98489. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  98490. *
  98491. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  98492. * @returns The extension selected.
  98493. */
  98494. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  98495. /**
  98496. * Force a specific size of the canvas
  98497. * @param width defines the new canvas' width
  98498. * @param height defines the new canvas' height
  98499. */
  98500. setSize(width: number, height: number): void;
  98501. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98502. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98503. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98504. _releaseTexture(texture: InternalTexture): void;
  98505. /**
  98506. * @hidden
  98507. * Rescales a texture
  98508. * @param source input texutre
  98509. * @param destination destination texture
  98510. * @param scene scene to use to render the resize
  98511. * @param internalFormat format to use when resizing
  98512. * @param onComplete callback to be called when resize has completed
  98513. */
  98514. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98515. /**
  98516. * Gets the current framerate
  98517. * @returns a number representing the framerate
  98518. */
  98519. getFps(): number;
  98520. /**
  98521. * Gets the time spent between current and previous frame
  98522. * @returns a number representing the delta time in ms
  98523. */
  98524. getDeltaTime(): number;
  98525. private _measureFps;
  98526. /**
  98527. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  98528. * @param renderTarget The render target to set the frame buffer for
  98529. */
  98530. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  98531. /**
  98532. * Update a dynamic index buffer
  98533. * @param indexBuffer defines the target index buffer
  98534. * @param indices defines the data to update
  98535. * @param offset defines the offset in the target index buffer where update should start
  98536. */
  98537. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  98538. /**
  98539. * Updates the sample count of a render target texture
  98540. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  98541. * @param texture defines the texture to update
  98542. * @param samples defines the sample count to set
  98543. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  98544. */
  98545. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  98546. /** @hidden */
  98547. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  98548. dispose(): void;
  98549. private _disableTouchAction;
  98550. /**
  98551. * Display the loading screen
  98552. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98553. */
  98554. displayLoadingUI(): void;
  98555. /**
  98556. * Hide the loading screen
  98557. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98558. */
  98559. hideLoadingUI(): void;
  98560. /**
  98561. * Gets the current loading screen object
  98562. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98563. */
  98564. /**
  98565. * Sets the current loading screen object
  98566. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98567. */
  98568. loadingScreen: ILoadingScreen;
  98569. /**
  98570. * Sets the current loading screen text
  98571. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98572. */
  98573. loadingUIText: string;
  98574. /**
  98575. * Sets the current loading screen background color
  98576. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98577. */
  98578. loadingUIBackgroundColor: string;
  98579. /** Pointerlock and fullscreen */
  98580. /**
  98581. * Ask the browser to promote the current element to pointerlock mode
  98582. * @param element defines the DOM element to promote
  98583. */
  98584. static _RequestPointerlock(element: HTMLElement): void;
  98585. /**
  98586. * Asks the browser to exit pointerlock mode
  98587. */
  98588. static _ExitPointerlock(): void;
  98589. /**
  98590. * Ask the browser to promote the current element to fullscreen rendering mode
  98591. * @param element defines the DOM element to promote
  98592. */
  98593. static _RequestFullscreen(element: HTMLElement): void;
  98594. /**
  98595. * Asks the browser to exit fullscreen mode
  98596. */
  98597. static _ExitFullscreen(): void;
  98598. }
  98599. }
  98600. declare module BABYLON {
  98601. /**
  98602. * The engine store class is responsible to hold all the instances of Engine and Scene created
  98603. * during the life time of the application.
  98604. */
  98605. export class EngineStore {
  98606. /** Gets the list of created engines */
  98607. static Instances: Engine[];
  98608. /** @hidden */
  98609. static _LastCreatedScene: Nullable<Scene>;
  98610. /**
  98611. * Gets the latest created engine
  98612. */
  98613. static readonly LastCreatedEngine: Nullable<Engine>;
  98614. /**
  98615. * Gets the latest created scene
  98616. */
  98617. static readonly LastCreatedScene: Nullable<Scene>;
  98618. /**
  98619. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98620. * @ignorenaming
  98621. */
  98622. static UseFallbackTexture: boolean;
  98623. /**
  98624. * Texture content used if a texture cannot loaded
  98625. * @ignorenaming
  98626. */
  98627. static FallbackTexture: string;
  98628. }
  98629. }
  98630. declare module BABYLON {
  98631. /**
  98632. * Helper class that provides a small promise polyfill
  98633. */
  98634. export class PromisePolyfill {
  98635. /**
  98636. * Static function used to check if the polyfill is required
  98637. * If this is the case then the function will inject the polyfill to window.Promise
  98638. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  98639. */
  98640. static Apply(force?: boolean): void;
  98641. }
  98642. }
  98643. declare module BABYLON {
  98644. /**
  98645. * Interface for screenshot methods with describe argument called `size` as object with options
  98646. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  98647. */
  98648. export interface IScreenshotSize {
  98649. /**
  98650. * number in pixels for canvas height
  98651. */
  98652. height?: number;
  98653. /**
  98654. * multiplier allowing render at a higher or lower resolution
  98655. * If value is defined then height and width will be ignored and taken from camera
  98656. */
  98657. precision?: number;
  98658. /**
  98659. * number in pixels for canvas width
  98660. */
  98661. width?: number;
  98662. }
  98663. }
  98664. declare module BABYLON {
  98665. interface IColor4Like {
  98666. r: float;
  98667. g: float;
  98668. b: float;
  98669. a: float;
  98670. }
  98671. /**
  98672. * Class containing a set of static utilities functions
  98673. */
  98674. export class Tools {
  98675. /**
  98676. * Gets or sets the base URL to use to load assets
  98677. */
  98678. static BaseUrl: string;
  98679. /**
  98680. * Enable/Disable Custom HTTP Request Headers globally.
  98681. * default = false
  98682. * @see CustomRequestHeaders
  98683. */
  98684. static UseCustomRequestHeaders: boolean;
  98685. /**
  98686. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  98687. * i.e. when loading files, where the server/service expects an Authorization header
  98688. */
  98689. static CustomRequestHeaders: {
  98690. [key: string]: string;
  98691. };
  98692. /**
  98693. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  98694. */
  98695. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  98696. /**
  98697. * Default behaviour for cors in the application.
  98698. * It can be a string if the expected behavior is identical in the entire app.
  98699. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  98700. */
  98701. static CorsBehavior: string | ((url: string | string[]) => string);
  98702. /**
  98703. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98704. * @ignorenaming
  98705. */
  98706. static UseFallbackTexture: boolean;
  98707. /**
  98708. * Use this object to register external classes like custom textures or material
  98709. * to allow the laoders to instantiate them
  98710. */
  98711. static RegisteredExternalClasses: {
  98712. [key: string]: Object;
  98713. };
  98714. /**
  98715. * Texture content used if a texture cannot loaded
  98716. * @ignorenaming
  98717. */
  98718. static fallbackTexture: string;
  98719. /**
  98720. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98721. * @param u defines the coordinate on X axis
  98722. * @param v defines the coordinate on Y axis
  98723. * @param width defines the width of the source data
  98724. * @param height defines the height of the source data
  98725. * @param pixels defines the source byte array
  98726. * @param color defines the output color
  98727. */
  98728. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  98729. /**
  98730. * Interpolates between a and b via alpha
  98731. * @param a The lower value (returned when alpha = 0)
  98732. * @param b The upper value (returned when alpha = 1)
  98733. * @param alpha The interpolation-factor
  98734. * @return The mixed value
  98735. */
  98736. static Mix(a: number, b: number, alpha: number): number;
  98737. /**
  98738. * Tries to instantiate a new object from a given class name
  98739. * @param className defines the class name to instantiate
  98740. * @returns the new object or null if the system was not able to do the instantiation
  98741. */
  98742. static Instantiate(className: string): any;
  98743. /**
  98744. * Provides a slice function that will work even on IE
  98745. * @param data defines the array to slice
  98746. * @param start defines the start of the data (optional)
  98747. * @param end defines the end of the data (optional)
  98748. * @returns the new sliced array
  98749. */
  98750. static Slice<T>(data: T, start?: number, end?: number): T;
  98751. /**
  98752. * Polyfill for setImmediate
  98753. * @param action defines the action to execute after the current execution block
  98754. */
  98755. static SetImmediate(action: () => void): void;
  98756. /**
  98757. * Function indicating if a number is an exponent of 2
  98758. * @param value defines the value to test
  98759. * @returns true if the value is an exponent of 2
  98760. */
  98761. static IsExponentOfTwo(value: number): boolean;
  98762. private static _tmpFloatArray;
  98763. /**
  98764. * Returns the nearest 32-bit single precision float representation of a Number
  98765. * @param value A Number. If the parameter is of a different type, it will get converted
  98766. * to a number or to NaN if it cannot be converted
  98767. * @returns number
  98768. */
  98769. static FloatRound(value: number): number;
  98770. /**
  98771. * Extracts the filename from a path
  98772. * @param path defines the path to use
  98773. * @returns the filename
  98774. */
  98775. static GetFilename(path: string): string;
  98776. /**
  98777. * Extracts the "folder" part of a path (everything before the filename).
  98778. * @param uri The URI to extract the info from
  98779. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98780. * @returns The "folder" part of the path
  98781. */
  98782. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  98783. /**
  98784. * Extracts text content from a DOM element hierarchy
  98785. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  98786. */
  98787. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  98788. /**
  98789. * Convert an angle in radians to degrees
  98790. * @param angle defines the angle to convert
  98791. * @returns the angle in degrees
  98792. */
  98793. static ToDegrees(angle: number): number;
  98794. /**
  98795. * Convert an angle in degrees to radians
  98796. * @param angle defines the angle to convert
  98797. * @returns the angle in radians
  98798. */
  98799. static ToRadians(angle: number): number;
  98800. /**
  98801. * Encode a buffer to a base64 string
  98802. * @param buffer defines the buffer to encode
  98803. * @returns the encoded string
  98804. */
  98805. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  98806. /**
  98807. * Returns an array if obj is not an array
  98808. * @param obj defines the object to evaluate as an array
  98809. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98810. * @returns either obj directly if obj is an array or a new array containing obj
  98811. */
  98812. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  98813. /**
  98814. * Gets the pointer prefix to use
  98815. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98816. */
  98817. static GetPointerPrefix(): string;
  98818. /**
  98819. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98820. * @param url define the url we are trying
  98821. * @param element define the dom element where to configure the cors policy
  98822. */
  98823. static SetCorsBehavior(url: string | string[], element: {
  98824. crossOrigin: string | null;
  98825. }): void;
  98826. /**
  98827. * Removes unwanted characters from an url
  98828. * @param url defines the url to clean
  98829. * @returns the cleaned url
  98830. */
  98831. static CleanUrl(url: string): string;
  98832. /**
  98833. * Gets or sets a function used to pre-process url before using them to load assets
  98834. */
  98835. static PreprocessUrl: (url: string) => string;
  98836. /**
  98837. * Loads an image as an HTMLImageElement.
  98838. * @param input url string, ArrayBuffer, or Blob to load
  98839. * @param onLoad callback called when the image successfully loads
  98840. * @param onError callback called when the image fails to load
  98841. * @param offlineProvider offline provider for caching
  98842. * @returns the HTMLImageElement of the loaded image
  98843. */
  98844. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  98845. /**
  98846. * Loads a file
  98847. * @param url url string, ArrayBuffer, or Blob to load
  98848. * @param onSuccess callback called when the file successfully loads
  98849. * @param onProgress callback called while file is loading (if the server supports this mode)
  98850. * @param offlineProvider defines the offline provider for caching
  98851. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98852. * @param onError callback called when the file fails to load
  98853. * @returns a file request object
  98854. */
  98855. 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;
  98856. /**
  98857. * Loads a file from a url
  98858. * @param url the file url to load
  98859. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  98860. */
  98861. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  98862. /**
  98863. * Load a script (identified by an url). When the url returns, the
  98864. * content of this file is added into a new script element, attached to the DOM (body element)
  98865. * @param scriptUrl defines the url of the script to laod
  98866. * @param onSuccess defines the callback called when the script is loaded
  98867. * @param onError defines the callback to call if an error occurs
  98868. * @param scriptId defines the id of the script element
  98869. */
  98870. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  98871. /**
  98872. * Load an asynchronous script (identified by an url). When the url returns, the
  98873. * content of this file is added into a new script element, attached to the DOM (body element)
  98874. * @param scriptUrl defines the url of the script to laod
  98875. * @param scriptId defines the id of the script element
  98876. * @returns a promise request object
  98877. */
  98878. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  98879. /**
  98880. * Loads a file from a blob
  98881. * @param fileToLoad defines the blob to use
  98882. * @param callback defines the callback to call when data is loaded
  98883. * @param progressCallback defines the callback to call during loading process
  98884. * @returns a file request object
  98885. */
  98886. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  98887. /**
  98888. * Loads a file
  98889. * @param fileToLoad defines the file to load
  98890. * @param callback defines the callback to call when data is loaded
  98891. * @param progressCallBack defines the callback to call during loading process
  98892. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  98893. * @returns a file request object
  98894. */
  98895. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  98896. /**
  98897. * Creates a data url from a given string content
  98898. * @param content defines the content to convert
  98899. * @returns the new data url link
  98900. */
  98901. static FileAsURL(content: string): string;
  98902. /**
  98903. * Format the given number to a specific decimal format
  98904. * @param value defines the number to format
  98905. * @param decimals defines the number of decimals to use
  98906. * @returns the formatted string
  98907. */
  98908. static Format(value: number, decimals?: number): string;
  98909. /**
  98910. * Tries to copy an object by duplicating every property
  98911. * @param source defines the source object
  98912. * @param destination defines the target object
  98913. * @param doNotCopyList defines a list of properties to avoid
  98914. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98915. */
  98916. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  98917. /**
  98918. * Gets a boolean indicating if the given object has no own property
  98919. * @param obj defines the object to test
  98920. * @returns true if object has no own property
  98921. */
  98922. static IsEmpty(obj: any): boolean;
  98923. /**
  98924. * Function used to register events at window level
  98925. * @param windowElement defines the Window object to use
  98926. * @param events defines the events to register
  98927. */
  98928. static RegisterTopRootEvents(windowElement: Window, events: {
  98929. name: string;
  98930. handler: Nullable<(e: FocusEvent) => any>;
  98931. }[]): void;
  98932. /**
  98933. * Function used to unregister events from window level
  98934. * @param windowElement defines the Window object to use
  98935. * @param events defines the events to unregister
  98936. */
  98937. static UnregisterTopRootEvents(windowElement: Window, events: {
  98938. name: string;
  98939. handler: Nullable<(e: FocusEvent) => any>;
  98940. }[]): void;
  98941. /**
  98942. * @ignore
  98943. */
  98944. static _ScreenshotCanvas: HTMLCanvasElement;
  98945. /**
  98946. * Dumps the current bound framebuffer
  98947. * @param width defines the rendering width
  98948. * @param height defines the rendering height
  98949. * @param engine defines the hosting engine
  98950. * @param successCallback defines the callback triggered once the data are available
  98951. * @param mimeType defines the mime type of the result
  98952. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98953. */
  98954. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98955. /**
  98956. * Converts the canvas data to blob.
  98957. * This acts as a polyfill for browsers not supporting the to blob function.
  98958. * @param canvas Defines the canvas to extract the data from
  98959. * @param successCallback Defines the callback triggered once the data are available
  98960. * @param mimeType Defines the mime type of the result
  98961. */
  98962. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  98963. /**
  98964. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98965. * @param successCallback defines the callback triggered once the data are available
  98966. * @param mimeType defines the mime type of the result
  98967. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98968. */
  98969. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98970. /**
  98971. * Downloads a blob in the browser
  98972. * @param blob defines the blob to download
  98973. * @param fileName defines the name of the downloaded file
  98974. */
  98975. static Download(blob: Blob, fileName: string): void;
  98976. /**
  98977. * Captures a screenshot of the current rendering
  98978. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98979. * @param engine defines the rendering engine
  98980. * @param camera defines the source camera
  98981. * @param size This parameter can be set to a single number or to an object with the
  98982. * following (optional) properties: precision, width, height. If a single number is passed,
  98983. * it will be used for both width and height. If an object is passed, the screenshot size
  98984. * will be derived from the parameters. The precision property is a multiplier allowing
  98985. * rendering at a higher or lower resolution
  98986. * @param successCallback defines the callback receives a single parameter which contains the
  98987. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98988. * src parameter of an <img> to display it
  98989. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98990. * Check your browser for supported MIME types
  98991. */
  98992. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  98993. /**
  98994. * Captures a screenshot of the current rendering
  98995. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98996. * @param engine defines the rendering engine
  98997. * @param camera defines the source camera
  98998. * @param size This parameter can be set to a single number or to an object with the
  98999. * following (optional) properties: precision, width, height. If a single number is passed,
  99000. * it will be used for both width and height. If an object is passed, the screenshot size
  99001. * will be derived from the parameters. The precision property is a multiplier allowing
  99002. * rendering at a higher or lower resolution
  99003. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99004. * Check your browser for supported MIME types
  99005. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99006. * to the src parameter of an <img> to display it
  99007. */
  99008. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  99009. /**
  99010. * Generates an image screenshot from the specified camera.
  99011. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99012. * @param engine The engine to use for rendering
  99013. * @param camera The camera to use for rendering
  99014. * @param size This parameter can be set to a single number or to an object with the
  99015. * following (optional) properties: precision, width, height. If a single number is passed,
  99016. * it will be used for both width and height. If an object is passed, the screenshot size
  99017. * will be derived from the parameters. The precision property is a multiplier allowing
  99018. * rendering at a higher or lower resolution
  99019. * @param successCallback The callback receives a single parameter which contains the
  99020. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99021. * src parameter of an <img> to display it
  99022. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99023. * Check your browser for supported MIME types
  99024. * @param samples Texture samples (default: 1)
  99025. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99026. * @param fileName A name for for the downloaded file.
  99027. */
  99028. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  99029. /**
  99030. * Generates an image screenshot from the specified camera.
  99031. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99032. * @param engine The engine to use for rendering
  99033. * @param camera The camera to use for rendering
  99034. * @param size This parameter can be set to a single number or to an object with the
  99035. * following (optional) properties: precision, width, height. If a single number is passed,
  99036. * it will be used for both width and height. If an object is passed, the screenshot size
  99037. * will be derived from the parameters. The precision property is a multiplier allowing
  99038. * rendering at a higher or lower resolution
  99039. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99040. * Check your browser for supported MIME types
  99041. * @param samples Texture samples (default: 1)
  99042. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99043. * @param fileName A name for for the downloaded file.
  99044. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99045. * to the src parameter of an <img> to display it
  99046. */
  99047. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  99048. /**
  99049. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99050. * Be aware Math.random() could cause collisions, but:
  99051. * "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"
  99052. * @returns a pseudo random id
  99053. */
  99054. static RandomId(): string;
  99055. /**
  99056. * Test if the given uri is a base64 string
  99057. * @param uri The uri to test
  99058. * @return True if the uri is a base64 string or false otherwise
  99059. */
  99060. static IsBase64(uri: string): boolean;
  99061. /**
  99062. * Decode the given base64 uri.
  99063. * @param uri The uri to decode
  99064. * @return The decoded base64 data.
  99065. */
  99066. static DecodeBase64(uri: string): ArrayBuffer;
  99067. /**
  99068. * Gets the absolute url.
  99069. * @param url the input url
  99070. * @return the absolute url
  99071. */
  99072. static GetAbsoluteUrl(url: string): string;
  99073. /**
  99074. * No log
  99075. */
  99076. static readonly NoneLogLevel: number;
  99077. /**
  99078. * Only message logs
  99079. */
  99080. static readonly MessageLogLevel: number;
  99081. /**
  99082. * Only warning logs
  99083. */
  99084. static readonly WarningLogLevel: number;
  99085. /**
  99086. * Only error logs
  99087. */
  99088. static readonly ErrorLogLevel: number;
  99089. /**
  99090. * All logs
  99091. */
  99092. static readonly AllLogLevel: number;
  99093. /**
  99094. * Gets a value indicating the number of loading errors
  99095. * @ignorenaming
  99096. */
  99097. static readonly errorsCount: number;
  99098. /**
  99099. * Callback called when a new log is added
  99100. */
  99101. static OnNewCacheEntry: (entry: string) => void;
  99102. /**
  99103. * Log a message to the console
  99104. * @param message defines the message to log
  99105. */
  99106. static Log(message: string): void;
  99107. /**
  99108. * Write a warning message to the console
  99109. * @param message defines the message to log
  99110. */
  99111. static Warn(message: string): void;
  99112. /**
  99113. * Write an error message to the console
  99114. * @param message defines the message to log
  99115. */
  99116. static Error(message: string): void;
  99117. /**
  99118. * Gets current log cache (list of logs)
  99119. */
  99120. static readonly LogCache: string;
  99121. /**
  99122. * Clears the log cache
  99123. */
  99124. static ClearLogCache(): void;
  99125. /**
  99126. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99127. */
  99128. static LogLevels: number;
  99129. /**
  99130. * Checks if the window object exists
  99131. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99132. */
  99133. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99134. /**
  99135. * No performance log
  99136. */
  99137. static readonly PerformanceNoneLogLevel: number;
  99138. /**
  99139. * Use user marks to log performance
  99140. */
  99141. static readonly PerformanceUserMarkLogLevel: number;
  99142. /**
  99143. * Log performance to the console
  99144. */
  99145. static readonly PerformanceConsoleLogLevel: number;
  99146. private static _performance;
  99147. /**
  99148. * Sets the current performance log level
  99149. */
  99150. static PerformanceLogLevel: number;
  99151. private static _StartPerformanceCounterDisabled;
  99152. private static _EndPerformanceCounterDisabled;
  99153. private static _StartUserMark;
  99154. private static _EndUserMark;
  99155. private static _StartPerformanceConsole;
  99156. private static _EndPerformanceConsole;
  99157. /**
  99158. * Starts a performance counter
  99159. */
  99160. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99161. /**
  99162. * Ends a specific performance coutner
  99163. */
  99164. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99165. /**
  99166. * Gets either window.performance.now() if supported or Date.now() else
  99167. */
  99168. static readonly Now: number;
  99169. /**
  99170. * This method will return the name of the class used to create the instance of the given object.
  99171. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99172. * @param object the object to get the class name from
  99173. * @param isType defines if the object is actually a type
  99174. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99175. */
  99176. static GetClassName(object: any, isType?: boolean): string;
  99177. /**
  99178. * Gets the first element of an array satisfying a given predicate
  99179. * @param array defines the array to browse
  99180. * @param predicate defines the predicate to use
  99181. * @returns null if not found or the element
  99182. */
  99183. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99184. /**
  99185. * This method will return the name of the full name of the class, including its owning module (if any).
  99186. * 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).
  99187. * @param object the object to get the class name from
  99188. * @param isType defines if the object is actually a type
  99189. * @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.
  99190. * @ignorenaming
  99191. */
  99192. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99193. /**
  99194. * Returns a promise that resolves after the given amount of time.
  99195. * @param delay Number of milliseconds to delay
  99196. * @returns Promise that resolves after the given amount of time
  99197. */
  99198. static DelayAsync(delay: number): Promise<void>;
  99199. }
  99200. /**
  99201. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99202. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99203. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99204. * @param name The name of the class, case should be preserved
  99205. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99206. */
  99207. export function className(name: string, module?: string): (target: Object) => void;
  99208. /**
  99209. * An implementation of a loop for asynchronous functions.
  99210. */
  99211. export class AsyncLoop {
  99212. /**
  99213. * Defines the number of iterations for the loop
  99214. */
  99215. iterations: number;
  99216. /**
  99217. * Defines the current index of the loop.
  99218. */
  99219. index: number;
  99220. private _done;
  99221. private _fn;
  99222. private _successCallback;
  99223. /**
  99224. * Constructor.
  99225. * @param iterations the number of iterations.
  99226. * @param func the function to run each iteration
  99227. * @param successCallback the callback that will be called upon succesful execution
  99228. * @param offset starting offset.
  99229. */
  99230. constructor(
  99231. /**
  99232. * Defines the number of iterations for the loop
  99233. */
  99234. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99235. /**
  99236. * Execute the next iteration. Must be called after the last iteration was finished.
  99237. */
  99238. executeNext(): void;
  99239. /**
  99240. * Break the loop and run the success callback.
  99241. */
  99242. breakLoop(): void;
  99243. /**
  99244. * Create and run an async loop.
  99245. * @param iterations the number of iterations.
  99246. * @param fn the function to run each iteration
  99247. * @param successCallback the callback that will be called upon succesful execution
  99248. * @param offset starting offset.
  99249. * @returns the created async loop object
  99250. */
  99251. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99252. /**
  99253. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99254. * @param iterations total number of iterations
  99255. * @param syncedIterations number of synchronous iterations in each async iteration.
  99256. * @param fn the function to call each iteration.
  99257. * @param callback a success call back that will be called when iterating stops.
  99258. * @param breakFunction a break condition (optional)
  99259. * @param timeout timeout settings for the setTimeout function. default - 0.
  99260. * @returns the created async loop object
  99261. */
  99262. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99263. }
  99264. }
  99265. declare module BABYLON {
  99266. /**
  99267. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99268. * The underlying implementation relies on an associative array to ensure the best performances.
  99269. * The value can be anything including 'null' but except 'undefined'
  99270. */
  99271. export class StringDictionary<T> {
  99272. /**
  99273. * This will clear this dictionary and copy the content from the 'source' one.
  99274. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99275. * @param source the dictionary to take the content from and copy to this dictionary
  99276. */
  99277. copyFrom(source: StringDictionary<T>): void;
  99278. /**
  99279. * Get a value based from its key
  99280. * @param key the given key to get the matching value from
  99281. * @return the value if found, otherwise undefined is returned
  99282. */
  99283. get(key: string): T | undefined;
  99284. /**
  99285. * Get a value from its key or add it if it doesn't exist.
  99286. * This method will ensure you that a given key/data will be present in the dictionary.
  99287. * @param key the given key to get the matching value from
  99288. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99289. * The factory will only be invoked if there's no data for the given key.
  99290. * @return the value corresponding to the key.
  99291. */
  99292. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  99293. /**
  99294. * Get a value from its key if present in the dictionary otherwise add it
  99295. * @param key the key to get the value from
  99296. * @param val if there's no such key/value pair in the dictionary add it with this value
  99297. * @return the value corresponding to the key
  99298. */
  99299. getOrAdd(key: string, val: T): T;
  99300. /**
  99301. * Check if there's a given key in the dictionary
  99302. * @param key the key to check for
  99303. * @return true if the key is present, false otherwise
  99304. */
  99305. contains(key: string): boolean;
  99306. /**
  99307. * Add a new key and its corresponding value
  99308. * @param key the key to add
  99309. * @param value the value corresponding to the key
  99310. * @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
  99311. */
  99312. add(key: string, value: T): boolean;
  99313. /**
  99314. * Update a specific value associated to a key
  99315. * @param key defines the key to use
  99316. * @param value defines the value to store
  99317. * @returns true if the value was updated (or false if the key was not found)
  99318. */
  99319. set(key: string, value: T): boolean;
  99320. /**
  99321. * Get the element of the given key and remove it from the dictionary
  99322. * @param key defines the key to search
  99323. * @returns the value associated with the key or null if not found
  99324. */
  99325. getAndRemove(key: string): Nullable<T>;
  99326. /**
  99327. * Remove a key/value from the dictionary.
  99328. * @param key the key to remove
  99329. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  99330. */
  99331. remove(key: string): boolean;
  99332. /**
  99333. * Clear the whole content of the dictionary
  99334. */
  99335. clear(): void;
  99336. /**
  99337. * Gets the current count
  99338. */
  99339. readonly count: number;
  99340. /**
  99341. * Execute a callback on each key/val of the dictionary.
  99342. * Note that you can remove any element in this dictionary in the callback implementation
  99343. * @param callback the callback to execute on a given key/value pair
  99344. */
  99345. forEach(callback: (key: string, val: T) => void): void;
  99346. /**
  99347. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  99348. * If the callback returns null or undefined the method will iterate to the next key/value pair
  99349. * Note that you can remove any element in this dictionary in the callback implementation
  99350. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  99351. * @returns the first item
  99352. */
  99353. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  99354. private _count;
  99355. private _data;
  99356. }
  99357. }
  99358. declare module BABYLON {
  99359. /** @hidden */
  99360. export interface ICollisionCoordinator {
  99361. createCollider(): Collider;
  99362. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99363. init(scene: Scene): void;
  99364. }
  99365. /** @hidden */
  99366. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  99367. private _scene;
  99368. private _scaledPosition;
  99369. private _scaledVelocity;
  99370. private _finalPosition;
  99371. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99372. createCollider(): Collider;
  99373. init(scene: Scene): void;
  99374. private _collideWithWorld;
  99375. }
  99376. }
  99377. declare module BABYLON {
  99378. /**
  99379. * Class used to manage all inputs for the scene.
  99380. */
  99381. export class InputManager {
  99382. /** The distance in pixel that you have to move to prevent some events */
  99383. static DragMovementThreshold: number;
  99384. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  99385. static LongPressDelay: number;
  99386. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  99387. static DoubleClickDelay: number;
  99388. /** If you need to check double click without raising a single click at first click, enable this flag */
  99389. static ExclusiveDoubleClickMode: boolean;
  99390. private _wheelEventName;
  99391. private _onPointerMove;
  99392. private _onPointerDown;
  99393. private _onPointerUp;
  99394. private _initClickEvent;
  99395. private _initActionManager;
  99396. private _delayedSimpleClick;
  99397. private _delayedSimpleClickTimeout;
  99398. private _previousDelayedSimpleClickTimeout;
  99399. private _meshPickProceed;
  99400. private _previousButtonPressed;
  99401. private _currentPickResult;
  99402. private _previousPickResult;
  99403. private _totalPointersPressed;
  99404. private _doubleClickOccured;
  99405. private _pointerOverMesh;
  99406. private _pickedDownMesh;
  99407. private _pickedUpMesh;
  99408. private _pointerX;
  99409. private _pointerY;
  99410. private _unTranslatedPointerX;
  99411. private _unTranslatedPointerY;
  99412. private _startingPointerPosition;
  99413. private _previousStartingPointerPosition;
  99414. private _startingPointerTime;
  99415. private _previousStartingPointerTime;
  99416. private _pointerCaptures;
  99417. private _onKeyDown;
  99418. private _onKeyUp;
  99419. private _onCanvasFocusObserver;
  99420. private _onCanvasBlurObserver;
  99421. private _scene;
  99422. /**
  99423. * Creates a new InputManager
  99424. * @param scene defines the hosting scene
  99425. */
  99426. constructor(scene: Scene);
  99427. /**
  99428. * Gets the mesh that is currently under the pointer
  99429. */
  99430. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99431. /**
  99432. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  99433. */
  99434. readonly unTranslatedPointer: Vector2;
  99435. /**
  99436. * Gets or sets the current on-screen X position of the pointer
  99437. */
  99438. pointerX: number;
  99439. /**
  99440. * Gets or sets the current on-screen Y position of the pointer
  99441. */
  99442. pointerY: number;
  99443. private _updatePointerPosition;
  99444. private _processPointerMove;
  99445. private _setRayOnPointerInfo;
  99446. private _checkPrePointerObservable;
  99447. /**
  99448. * Use this method to simulate a pointer move on a mesh
  99449. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99450. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99451. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99452. */
  99453. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99454. /**
  99455. * Use this method to simulate a pointer down on a mesh
  99456. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99457. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99458. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99459. */
  99460. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99461. private _processPointerDown;
  99462. /** @hidden */
  99463. _isPointerSwiping(): boolean;
  99464. /**
  99465. * Use this method to simulate a pointer up on a mesh
  99466. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99467. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99468. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99469. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99470. */
  99471. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  99472. private _processPointerUp;
  99473. /**
  99474. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99475. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99476. * @returns true if the pointer was captured
  99477. */
  99478. isPointerCaptured(pointerId?: number): boolean;
  99479. /**
  99480. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99481. * @param attachUp defines if you want to attach events to pointerup
  99482. * @param attachDown defines if you want to attach events to pointerdown
  99483. * @param attachMove defines if you want to attach events to pointermove
  99484. */
  99485. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99486. /**
  99487. * Detaches all event handlers
  99488. */
  99489. detachControl(): void;
  99490. /**
  99491. * Force the value of meshUnderPointer
  99492. * @param mesh defines the mesh to use
  99493. */
  99494. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99495. /**
  99496. * Gets the mesh under the pointer
  99497. * @returns a Mesh or null if no mesh is under the pointer
  99498. */
  99499. getPointerOverMesh(): Nullable<AbstractMesh>;
  99500. }
  99501. }
  99502. declare module BABYLON {
  99503. /**
  99504. * Helper class used to generate session unique ID
  99505. */
  99506. export class UniqueIdGenerator {
  99507. private static _UniqueIdCounter;
  99508. /**
  99509. * Gets an unique (relatively to the current scene) Id
  99510. */
  99511. static readonly UniqueId: number;
  99512. }
  99513. }
  99514. declare module BABYLON {
  99515. /**
  99516. * This class defines the direct association between an animation and a target
  99517. */
  99518. export class TargetedAnimation {
  99519. /**
  99520. * Animation to perform
  99521. */
  99522. animation: Animation;
  99523. /**
  99524. * Target to animate
  99525. */
  99526. target: any;
  99527. /**
  99528. * Serialize the object
  99529. * @returns the JSON object representing the current entity
  99530. */
  99531. serialize(): any;
  99532. }
  99533. /**
  99534. * Use this class to create coordinated animations on multiple targets
  99535. */
  99536. export class AnimationGroup implements IDisposable {
  99537. /** The name of the animation group */
  99538. name: string;
  99539. private _scene;
  99540. private _targetedAnimations;
  99541. private _animatables;
  99542. private _from;
  99543. private _to;
  99544. private _isStarted;
  99545. private _isPaused;
  99546. private _speedRatio;
  99547. private _loopAnimation;
  99548. /**
  99549. * Gets or sets the unique id of the node
  99550. */
  99551. uniqueId: number;
  99552. /**
  99553. * This observable will notify when one animation have ended
  99554. */
  99555. onAnimationEndObservable: Observable<TargetedAnimation>;
  99556. /**
  99557. * Observer raised when one animation loops
  99558. */
  99559. onAnimationLoopObservable: Observable<TargetedAnimation>;
  99560. /**
  99561. * This observable will notify when all animations have ended.
  99562. */
  99563. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  99564. /**
  99565. * This observable will notify when all animations have paused.
  99566. */
  99567. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  99568. /**
  99569. * This observable will notify when all animations are playing.
  99570. */
  99571. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  99572. /**
  99573. * Gets the first frame
  99574. */
  99575. readonly from: number;
  99576. /**
  99577. * Gets the last frame
  99578. */
  99579. readonly to: number;
  99580. /**
  99581. * Define if the animations are started
  99582. */
  99583. readonly isStarted: boolean;
  99584. /**
  99585. * Gets a value indicating that the current group is playing
  99586. */
  99587. readonly isPlaying: boolean;
  99588. /**
  99589. * Gets or sets the speed ratio to use for all animations
  99590. */
  99591. /**
  99592. * Gets or sets the speed ratio to use for all animations
  99593. */
  99594. speedRatio: number;
  99595. /**
  99596. * Gets or sets if all animations should loop or not
  99597. */
  99598. loopAnimation: boolean;
  99599. /**
  99600. * Gets the targeted animations for this animation group
  99601. */
  99602. readonly targetedAnimations: Array<TargetedAnimation>;
  99603. /**
  99604. * returning the list of animatables controlled by this animation group.
  99605. */
  99606. readonly animatables: Array<Animatable>;
  99607. /**
  99608. * Instantiates a new Animation Group.
  99609. * This helps managing several animations at once.
  99610. * @see http://doc.babylonjs.com/how_to/group
  99611. * @param name Defines the name of the group
  99612. * @param scene Defines the scene the group belongs to
  99613. */
  99614. constructor(
  99615. /** The name of the animation group */
  99616. name: string, scene?: Nullable<Scene>);
  99617. /**
  99618. * Add an animation (with its target) in the group
  99619. * @param animation defines the animation we want to add
  99620. * @param target defines the target of the animation
  99621. * @returns the TargetedAnimation object
  99622. */
  99623. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  99624. /**
  99625. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  99626. * It can add constant keys at begin or end
  99627. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  99628. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  99629. * @returns the animation group
  99630. */
  99631. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  99632. /**
  99633. * Start all animations on given targets
  99634. * @param loop defines if animations must loop
  99635. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  99636. * @param from defines the from key (optional)
  99637. * @param to defines the to key (optional)
  99638. * @returns the current animation group
  99639. */
  99640. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  99641. /**
  99642. * Pause all animations
  99643. * @returns the animation group
  99644. */
  99645. pause(): AnimationGroup;
  99646. /**
  99647. * Play all animations to initial state
  99648. * This function will start() the animations if they were not started or will restart() them if they were paused
  99649. * @param loop defines if animations must loop
  99650. * @returns the animation group
  99651. */
  99652. play(loop?: boolean): AnimationGroup;
  99653. /**
  99654. * Reset all animations to initial state
  99655. * @returns the animation group
  99656. */
  99657. reset(): AnimationGroup;
  99658. /**
  99659. * Restart animations from key 0
  99660. * @returns the animation group
  99661. */
  99662. restart(): AnimationGroup;
  99663. /**
  99664. * Stop all animations
  99665. * @returns the animation group
  99666. */
  99667. stop(): AnimationGroup;
  99668. /**
  99669. * Set animation weight for all animatables
  99670. * @param weight defines the weight to use
  99671. * @return the animationGroup
  99672. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99673. */
  99674. setWeightForAllAnimatables(weight: number): AnimationGroup;
  99675. /**
  99676. * Synchronize and normalize all animatables with a source animatable
  99677. * @param root defines the root animatable to synchronize with
  99678. * @return the animationGroup
  99679. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99680. */
  99681. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  99682. /**
  99683. * Goes to a specific frame in this animation group
  99684. * @param frame the frame number to go to
  99685. * @return the animationGroup
  99686. */
  99687. goToFrame(frame: number): AnimationGroup;
  99688. /**
  99689. * Dispose all associated resources
  99690. */
  99691. dispose(): void;
  99692. private _checkAnimationGroupEnded;
  99693. /**
  99694. * Clone the current animation group and returns a copy
  99695. * @param newName defines the name of the new group
  99696. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  99697. * @returns the new aniamtion group
  99698. */
  99699. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  99700. /**
  99701. * Serializes the animationGroup to an object
  99702. * @returns Serialized object
  99703. */
  99704. serialize(): any;
  99705. /**
  99706. * Returns a new AnimationGroup object parsed from the source provided.
  99707. * @param parsedAnimationGroup defines the source
  99708. * @param scene defines the scene that will receive the animationGroup
  99709. * @returns a new AnimationGroup
  99710. */
  99711. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  99712. /**
  99713. * Returns the string "AnimationGroup"
  99714. * @returns "AnimationGroup"
  99715. */
  99716. getClassName(): string;
  99717. /**
  99718. * Creates a detailled string about the object
  99719. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  99720. * @returns a string representing the object
  99721. */
  99722. toString(fullDetails?: boolean): string;
  99723. }
  99724. }
  99725. declare module BABYLON {
  99726. /**
  99727. * Define an interface for all classes that will hold resources
  99728. */
  99729. export interface IDisposable {
  99730. /**
  99731. * Releases all held resources
  99732. */
  99733. dispose(): void;
  99734. }
  99735. /** Interface defining initialization parameters for Scene class */
  99736. export interface SceneOptions {
  99737. /**
  99738. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  99739. * It will improve performance when the number of geometries becomes important.
  99740. */
  99741. useGeometryUniqueIdsMap?: boolean;
  99742. /**
  99743. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  99744. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99745. */
  99746. useMaterialMeshMap?: boolean;
  99747. /**
  99748. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  99749. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99750. */
  99751. useClonedMeshhMap?: boolean;
  99752. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  99753. virtual?: boolean;
  99754. }
  99755. /**
  99756. * Represents a scene to be rendered by the engine.
  99757. * @see http://doc.babylonjs.com/features/scene
  99758. */
  99759. export class Scene extends AbstractScene implements IAnimatable {
  99760. /** The fog is deactivated */
  99761. static readonly FOGMODE_NONE: number;
  99762. /** The fog density is following an exponential function */
  99763. static readonly FOGMODE_EXP: number;
  99764. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  99765. static readonly FOGMODE_EXP2: number;
  99766. /** The fog density is following a linear function. */
  99767. static readonly FOGMODE_LINEAR: number;
  99768. /**
  99769. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  99770. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99771. */
  99772. static MinDeltaTime: number;
  99773. /**
  99774. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  99775. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99776. */
  99777. static MaxDeltaTime: number;
  99778. /**
  99779. * Factory used to create the default material.
  99780. * @param name The name of the material to create
  99781. * @param scene The scene to create the material for
  99782. * @returns The default material
  99783. */
  99784. static DefaultMaterialFactory(scene: Scene): Material;
  99785. /**
  99786. * Factory used to create the a collision coordinator.
  99787. * @returns The collision coordinator
  99788. */
  99789. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  99790. /** @hidden */
  99791. _inputManager: InputManager;
  99792. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  99793. cameraToUseForPointers: Nullable<Camera>;
  99794. /** @hidden */
  99795. readonly _isScene: boolean;
  99796. /**
  99797. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  99798. */
  99799. autoClear: boolean;
  99800. /**
  99801. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  99802. */
  99803. autoClearDepthAndStencil: boolean;
  99804. /**
  99805. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  99806. */
  99807. clearColor: Color4;
  99808. /**
  99809. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  99810. */
  99811. ambientColor: Color3;
  99812. /**
  99813. * This is use to store the default BRDF lookup for PBR materials in your scene.
  99814. * It should only be one of the following (if not the default embedded one):
  99815. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  99816. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  99817. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  99818. * The material properties need to be setup according to the type of texture in use.
  99819. */
  99820. environmentBRDFTexture: BaseTexture;
  99821. /** @hidden */
  99822. protected _environmentTexture: Nullable<BaseTexture>;
  99823. /**
  99824. * Texture used in all pbr material as the reflection texture.
  99825. * As in the majority of the scene they are the same (exception for multi room and so on),
  99826. * this is easier to reference from here than from all the materials.
  99827. */
  99828. /**
  99829. * Texture used in all pbr material as the reflection texture.
  99830. * As in the majority of the scene they are the same (exception for multi room and so on),
  99831. * this is easier to set here than in all the materials.
  99832. */
  99833. environmentTexture: Nullable<BaseTexture>;
  99834. /** @hidden */
  99835. protected _environmentIntensity: number;
  99836. /**
  99837. * Intensity of the environment in all pbr material.
  99838. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99839. * As in the majority of the scene they are the same (exception for multi room and so on),
  99840. * this is easier to reference from here than from all the materials.
  99841. */
  99842. /**
  99843. * Intensity of the environment in all pbr material.
  99844. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99845. * As in the majority of the scene they are the same (exception for multi room and so on),
  99846. * this is easier to set here than in all the materials.
  99847. */
  99848. environmentIntensity: number;
  99849. /** @hidden */
  99850. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99851. /**
  99852. * Default image processing configuration used either in the rendering
  99853. * Forward main pass or through the imageProcessingPostProcess if present.
  99854. * As in the majority of the scene they are the same (exception for multi camera),
  99855. * this is easier to reference from here than from all the materials and post process.
  99856. *
  99857. * No setter as we it is a shared configuration, you can set the values instead.
  99858. */
  99859. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  99860. private _forceWireframe;
  99861. /**
  99862. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  99863. */
  99864. forceWireframe: boolean;
  99865. private _forcePointsCloud;
  99866. /**
  99867. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  99868. */
  99869. forcePointsCloud: boolean;
  99870. /**
  99871. * Gets or sets the active clipplane 1
  99872. */
  99873. clipPlane: Nullable<Plane>;
  99874. /**
  99875. * Gets or sets the active clipplane 2
  99876. */
  99877. clipPlane2: Nullable<Plane>;
  99878. /**
  99879. * Gets or sets the active clipplane 3
  99880. */
  99881. clipPlane3: Nullable<Plane>;
  99882. /**
  99883. * Gets or sets the active clipplane 4
  99884. */
  99885. clipPlane4: Nullable<Plane>;
  99886. /**
  99887. * Gets or sets a boolean indicating if animations are enabled
  99888. */
  99889. animationsEnabled: boolean;
  99890. private _animationPropertiesOverride;
  99891. /**
  99892. * Gets or sets the animation properties override
  99893. */
  99894. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  99895. /**
  99896. * Gets or sets a boolean indicating if a constant deltatime has to be used
  99897. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  99898. */
  99899. useConstantAnimationDeltaTime: boolean;
  99900. /**
  99901. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  99902. * Please note that it requires to run a ray cast through the scene on every frame
  99903. */
  99904. constantlyUpdateMeshUnderPointer: boolean;
  99905. /**
  99906. * Defines the HTML cursor to use when hovering over interactive elements
  99907. */
  99908. hoverCursor: string;
  99909. /**
  99910. * Defines the HTML default cursor to use (empty by default)
  99911. */
  99912. defaultCursor: string;
  99913. /**
  99914. * This is used to call preventDefault() on pointer down
  99915. * in order to block unwanted artifacts like system double clicks
  99916. */
  99917. preventDefaultOnPointerDown: boolean;
  99918. /**
  99919. * This is used to call preventDefault() on pointer up
  99920. * in order to block unwanted artifacts like system double clicks
  99921. */
  99922. preventDefaultOnPointerUp: boolean;
  99923. /**
  99924. * Gets or sets user defined metadata
  99925. */
  99926. metadata: any;
  99927. /**
  99928. * For internal use only. Please do not use.
  99929. */
  99930. reservedDataStore: any;
  99931. /**
  99932. * Gets the name of the plugin used to load this scene (null by default)
  99933. */
  99934. loadingPluginName: string;
  99935. /**
  99936. * Use this array to add regular expressions used to disable offline support for specific urls
  99937. */
  99938. disableOfflineSupportExceptionRules: RegExp[];
  99939. /**
  99940. * An event triggered when the scene is disposed.
  99941. */
  99942. onDisposeObservable: Observable<Scene>;
  99943. private _onDisposeObserver;
  99944. /** Sets a function to be executed when this scene is disposed. */
  99945. onDispose: () => void;
  99946. /**
  99947. * An event triggered before rendering the scene (right after animations and physics)
  99948. */
  99949. onBeforeRenderObservable: Observable<Scene>;
  99950. private _onBeforeRenderObserver;
  99951. /** Sets a function to be executed before rendering this scene */
  99952. beforeRender: Nullable<() => void>;
  99953. /**
  99954. * An event triggered after rendering the scene
  99955. */
  99956. onAfterRenderObservable: Observable<Scene>;
  99957. /**
  99958. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  99959. */
  99960. onAfterRenderCameraObservable: Observable<Camera>;
  99961. private _onAfterRenderObserver;
  99962. /** Sets a function to be executed after rendering this scene */
  99963. afterRender: Nullable<() => void>;
  99964. /**
  99965. * An event triggered before animating the scene
  99966. */
  99967. onBeforeAnimationsObservable: Observable<Scene>;
  99968. /**
  99969. * An event triggered after animations processing
  99970. */
  99971. onAfterAnimationsObservable: Observable<Scene>;
  99972. /**
  99973. * An event triggered before draw calls are ready to be sent
  99974. */
  99975. onBeforeDrawPhaseObservable: Observable<Scene>;
  99976. /**
  99977. * An event triggered after draw calls have been sent
  99978. */
  99979. onAfterDrawPhaseObservable: Observable<Scene>;
  99980. /**
  99981. * An event triggered when the scene is ready
  99982. */
  99983. onReadyObservable: Observable<Scene>;
  99984. /**
  99985. * An event triggered before rendering a camera
  99986. */
  99987. onBeforeCameraRenderObservable: Observable<Camera>;
  99988. private _onBeforeCameraRenderObserver;
  99989. /** Sets a function to be executed before rendering a camera*/
  99990. beforeCameraRender: () => void;
  99991. /**
  99992. * An event triggered after rendering a camera
  99993. */
  99994. onAfterCameraRenderObservable: Observable<Camera>;
  99995. private _onAfterCameraRenderObserver;
  99996. /** Sets a function to be executed after rendering a camera*/
  99997. afterCameraRender: () => void;
  99998. /**
  99999. * An event triggered when active meshes evaluation is about to start
  100000. */
  100001. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  100002. /**
  100003. * An event triggered when active meshes evaluation is done
  100004. */
  100005. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  100006. /**
  100007. * An event triggered when particles rendering is about to start
  100008. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100009. */
  100010. onBeforeParticlesRenderingObservable: Observable<Scene>;
  100011. /**
  100012. * An event triggered when particles rendering is done
  100013. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100014. */
  100015. onAfterParticlesRenderingObservable: Observable<Scene>;
  100016. /**
  100017. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  100018. */
  100019. onDataLoadedObservable: Observable<Scene>;
  100020. /**
  100021. * An event triggered when a camera is created
  100022. */
  100023. onNewCameraAddedObservable: Observable<Camera>;
  100024. /**
  100025. * An event triggered when a camera is removed
  100026. */
  100027. onCameraRemovedObservable: Observable<Camera>;
  100028. /**
  100029. * An event triggered when a light is created
  100030. */
  100031. onNewLightAddedObservable: Observable<Light>;
  100032. /**
  100033. * An event triggered when a light is removed
  100034. */
  100035. onLightRemovedObservable: Observable<Light>;
  100036. /**
  100037. * An event triggered when a geometry is created
  100038. */
  100039. onNewGeometryAddedObservable: Observable<Geometry>;
  100040. /**
  100041. * An event triggered when a geometry is removed
  100042. */
  100043. onGeometryRemovedObservable: Observable<Geometry>;
  100044. /**
  100045. * An event triggered when a transform node is created
  100046. */
  100047. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  100048. /**
  100049. * An event triggered when a transform node is removed
  100050. */
  100051. onTransformNodeRemovedObservable: Observable<TransformNode>;
  100052. /**
  100053. * An event triggered when a mesh is created
  100054. */
  100055. onNewMeshAddedObservable: Observable<AbstractMesh>;
  100056. /**
  100057. * An event triggered when a mesh is removed
  100058. */
  100059. onMeshRemovedObservable: Observable<AbstractMesh>;
  100060. /**
  100061. * An event triggered when a skeleton is created
  100062. */
  100063. onNewSkeletonAddedObservable: Observable<Skeleton>;
  100064. /**
  100065. * An event triggered when a skeleton is removed
  100066. */
  100067. onSkeletonRemovedObservable: Observable<Skeleton>;
  100068. /**
  100069. * An event triggered when a material is created
  100070. */
  100071. onNewMaterialAddedObservable: Observable<Material>;
  100072. /**
  100073. * An event triggered when a material is removed
  100074. */
  100075. onMaterialRemovedObservable: Observable<Material>;
  100076. /**
  100077. * An event triggered when a texture is created
  100078. */
  100079. onNewTextureAddedObservable: Observable<BaseTexture>;
  100080. /**
  100081. * An event triggered when a texture is removed
  100082. */
  100083. onTextureRemovedObservable: Observable<BaseTexture>;
  100084. /**
  100085. * An event triggered when render targets are about to be rendered
  100086. * Can happen multiple times per frame.
  100087. */
  100088. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  100089. /**
  100090. * An event triggered when render targets were rendered.
  100091. * Can happen multiple times per frame.
  100092. */
  100093. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  100094. /**
  100095. * An event triggered before calculating deterministic simulation step
  100096. */
  100097. onBeforeStepObservable: Observable<Scene>;
  100098. /**
  100099. * An event triggered after calculating deterministic simulation step
  100100. */
  100101. onAfterStepObservable: Observable<Scene>;
  100102. /**
  100103. * An event triggered when the activeCamera property is updated
  100104. */
  100105. onActiveCameraChanged: Observable<Scene>;
  100106. /**
  100107. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  100108. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100109. * 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)
  100110. */
  100111. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100112. /**
  100113. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  100114. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100115. * 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)
  100116. */
  100117. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100118. /**
  100119. * This Observable will when a mesh has been imported into the scene.
  100120. */
  100121. onMeshImportedObservable: Observable<AbstractMesh>;
  100122. /**
  100123. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100124. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100125. */
  100126. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100127. /** @hidden */
  100128. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100129. /**
  100130. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100131. */
  100132. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100133. /**
  100134. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100135. */
  100136. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100137. /**
  100138. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100139. */
  100140. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100141. /** Callback called when a pointer move is detected */
  100142. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100143. /** Callback called when a pointer down is detected */
  100144. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100145. /** Callback called when a pointer up is detected */
  100146. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100147. /** Callback called when a pointer pick is detected */
  100148. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100149. /**
  100150. * 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).
  100151. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100152. */
  100153. onPrePointerObservable: Observable<PointerInfoPre>;
  100154. /**
  100155. * Observable event triggered each time an input event is received from the rendering canvas
  100156. */
  100157. onPointerObservable: Observable<PointerInfo>;
  100158. /**
  100159. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100160. */
  100161. readonly unTranslatedPointer: Vector2;
  100162. /**
  100163. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100164. */
  100165. static DragMovementThreshold: number;
  100166. /**
  100167. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100168. */
  100169. static LongPressDelay: number;
  100170. /**
  100171. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100172. */
  100173. static DoubleClickDelay: number;
  100174. /** If you need to check double click without raising a single click at first click, enable this flag */
  100175. static ExclusiveDoubleClickMode: boolean;
  100176. /** @hidden */
  100177. _mirroredCameraPosition: Nullable<Vector3>;
  100178. /**
  100179. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100180. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100181. */
  100182. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100183. /**
  100184. * Observable event triggered each time an keyboard event is received from the hosting window
  100185. */
  100186. onKeyboardObservable: Observable<KeyboardInfo>;
  100187. private _useRightHandedSystem;
  100188. /**
  100189. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100190. */
  100191. useRightHandedSystem: boolean;
  100192. private _timeAccumulator;
  100193. private _currentStepId;
  100194. private _currentInternalStep;
  100195. /**
  100196. * Sets the step Id used by deterministic lock step
  100197. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100198. * @param newStepId defines the step Id
  100199. */
  100200. setStepId(newStepId: number): void;
  100201. /**
  100202. * Gets the step Id used by deterministic lock step
  100203. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100204. * @returns the step Id
  100205. */
  100206. getStepId(): number;
  100207. /**
  100208. * Gets the internal step used by deterministic lock step
  100209. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100210. * @returns the internal step
  100211. */
  100212. getInternalStep(): number;
  100213. private _fogEnabled;
  100214. /**
  100215. * Gets or sets a boolean indicating if fog is enabled on this scene
  100216. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100217. * (Default is true)
  100218. */
  100219. fogEnabled: boolean;
  100220. private _fogMode;
  100221. /**
  100222. * Gets or sets the fog mode to use
  100223. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100224. * | mode | value |
  100225. * | --- | --- |
  100226. * | FOGMODE_NONE | 0 |
  100227. * | FOGMODE_EXP | 1 |
  100228. * | FOGMODE_EXP2 | 2 |
  100229. * | FOGMODE_LINEAR | 3 |
  100230. */
  100231. fogMode: number;
  100232. /**
  100233. * Gets or sets the fog color to use
  100234. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100235. * (Default is Color3(0.2, 0.2, 0.3))
  100236. */
  100237. fogColor: Color3;
  100238. /**
  100239. * Gets or sets the fog density to use
  100240. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100241. * (Default is 0.1)
  100242. */
  100243. fogDensity: number;
  100244. /**
  100245. * Gets or sets the fog start distance to use
  100246. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100247. * (Default is 0)
  100248. */
  100249. fogStart: number;
  100250. /**
  100251. * Gets or sets the fog end distance to use
  100252. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100253. * (Default is 1000)
  100254. */
  100255. fogEnd: number;
  100256. private _shadowsEnabled;
  100257. /**
  100258. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100259. */
  100260. shadowsEnabled: boolean;
  100261. private _lightsEnabled;
  100262. /**
  100263. * Gets or sets a boolean indicating if lights are enabled on this scene
  100264. */
  100265. lightsEnabled: boolean;
  100266. /** All of the active cameras added to this scene. */
  100267. activeCameras: Camera[];
  100268. /** @hidden */
  100269. _activeCamera: Nullable<Camera>;
  100270. /** Gets or sets the current active camera */
  100271. activeCamera: Nullable<Camera>;
  100272. private _defaultMaterial;
  100273. /** The default material used on meshes when no material is affected */
  100274. /** The default material used on meshes when no material is affected */
  100275. defaultMaterial: Material;
  100276. private _texturesEnabled;
  100277. /**
  100278. * Gets or sets a boolean indicating if textures are enabled on this scene
  100279. */
  100280. texturesEnabled: boolean;
  100281. /**
  100282. * Gets or sets a boolean indicating if particles are enabled on this scene
  100283. */
  100284. particlesEnabled: boolean;
  100285. /**
  100286. * Gets or sets a boolean indicating if sprites are enabled on this scene
  100287. */
  100288. spritesEnabled: boolean;
  100289. private _skeletonsEnabled;
  100290. /**
  100291. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  100292. */
  100293. skeletonsEnabled: boolean;
  100294. /**
  100295. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  100296. */
  100297. lensFlaresEnabled: boolean;
  100298. /**
  100299. * Gets or sets a boolean indicating if collisions are enabled on this scene
  100300. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100301. */
  100302. collisionsEnabled: boolean;
  100303. private _collisionCoordinator;
  100304. /** @hidden */
  100305. readonly collisionCoordinator: ICollisionCoordinator;
  100306. /**
  100307. * Defines the gravity applied to this scene (used only for collisions)
  100308. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100309. */
  100310. gravity: Vector3;
  100311. /**
  100312. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  100313. */
  100314. postProcessesEnabled: boolean;
  100315. /**
  100316. * The list of postprocesses added to the scene
  100317. */
  100318. postProcesses: PostProcess[];
  100319. /**
  100320. * Gets the current postprocess manager
  100321. */
  100322. postProcessManager: PostProcessManager;
  100323. /**
  100324. * Gets or sets a boolean indicating if render targets are enabled on this scene
  100325. */
  100326. renderTargetsEnabled: boolean;
  100327. /**
  100328. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  100329. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  100330. */
  100331. dumpNextRenderTargets: boolean;
  100332. /**
  100333. * The list of user defined render targets added to the scene
  100334. */
  100335. customRenderTargets: RenderTargetTexture[];
  100336. /**
  100337. * Defines if texture loading must be delayed
  100338. * If true, textures will only be loaded when they need to be rendered
  100339. */
  100340. useDelayedTextureLoading: boolean;
  100341. /**
  100342. * Gets the list of meshes imported to the scene through SceneLoader
  100343. */
  100344. importedMeshesFiles: String[];
  100345. /**
  100346. * Gets or sets a boolean indicating if probes are enabled on this scene
  100347. */
  100348. probesEnabled: boolean;
  100349. /**
  100350. * Gets or sets the current offline provider to use to store scene data
  100351. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100352. */
  100353. offlineProvider: IOfflineProvider;
  100354. /**
  100355. * Gets or sets the action manager associated with the scene
  100356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100357. */
  100358. actionManager: AbstractActionManager;
  100359. private _meshesForIntersections;
  100360. /**
  100361. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  100362. */
  100363. proceduralTexturesEnabled: boolean;
  100364. private _engine;
  100365. private _totalVertices;
  100366. /** @hidden */
  100367. _activeIndices: PerfCounter;
  100368. /** @hidden */
  100369. _activeParticles: PerfCounter;
  100370. /** @hidden */
  100371. _activeBones: PerfCounter;
  100372. private _animationRatio;
  100373. /** @hidden */
  100374. _animationTimeLast: number;
  100375. /** @hidden */
  100376. _animationTime: number;
  100377. /**
  100378. * Gets or sets a general scale for animation speed
  100379. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  100380. */
  100381. animationTimeScale: number;
  100382. /** @hidden */
  100383. _cachedMaterial: Nullable<Material>;
  100384. /** @hidden */
  100385. _cachedEffect: Nullable<Effect>;
  100386. /** @hidden */
  100387. _cachedVisibility: Nullable<number>;
  100388. private _renderId;
  100389. private _frameId;
  100390. private _executeWhenReadyTimeoutId;
  100391. private _intermediateRendering;
  100392. private _viewUpdateFlag;
  100393. private _projectionUpdateFlag;
  100394. /** @hidden */
  100395. _toBeDisposed: Nullable<IDisposable>[];
  100396. private _activeRequests;
  100397. /** @hidden */
  100398. _pendingData: any[];
  100399. private _isDisposed;
  100400. /**
  100401. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  100402. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  100403. */
  100404. dispatchAllSubMeshesOfActiveMeshes: boolean;
  100405. private _activeMeshes;
  100406. private _processedMaterials;
  100407. private _renderTargets;
  100408. /** @hidden */
  100409. _activeParticleSystems: SmartArray<IParticleSystem>;
  100410. private _activeSkeletons;
  100411. private _softwareSkinnedMeshes;
  100412. private _renderingManager;
  100413. /** @hidden */
  100414. _activeAnimatables: Animatable[];
  100415. private _transformMatrix;
  100416. private _sceneUbo;
  100417. /** @hidden */
  100418. _viewMatrix: Matrix;
  100419. private _projectionMatrix;
  100420. /** @hidden */
  100421. _forcedViewPosition: Nullable<Vector3>;
  100422. /** @hidden */
  100423. _frustumPlanes: Plane[];
  100424. /**
  100425. * Gets the list of frustum planes (built from the active camera)
  100426. */
  100427. readonly frustumPlanes: Plane[];
  100428. /**
  100429. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  100430. * This is useful if there are more lights that the maximum simulteanous authorized
  100431. */
  100432. requireLightSorting: boolean;
  100433. /** @hidden */
  100434. readonly useMaterialMeshMap: boolean;
  100435. /** @hidden */
  100436. readonly useClonedMeshhMap: boolean;
  100437. private _externalData;
  100438. private _uid;
  100439. /**
  100440. * @hidden
  100441. * Backing store of defined scene components.
  100442. */
  100443. _components: ISceneComponent[];
  100444. /**
  100445. * @hidden
  100446. * Backing store of defined scene components.
  100447. */
  100448. _serializableComponents: ISceneSerializableComponent[];
  100449. /**
  100450. * List of components to register on the next registration step.
  100451. */
  100452. private _transientComponents;
  100453. /**
  100454. * Registers the transient components if needed.
  100455. */
  100456. private _registerTransientComponents;
  100457. /**
  100458. * @hidden
  100459. * Add a component to the scene.
  100460. * Note that the ccomponent could be registered on th next frame if this is called after
  100461. * the register component stage.
  100462. * @param component Defines the component to add to the scene
  100463. */
  100464. _addComponent(component: ISceneComponent): void;
  100465. /**
  100466. * @hidden
  100467. * Gets a component from the scene.
  100468. * @param name defines the name of the component to retrieve
  100469. * @returns the component or null if not present
  100470. */
  100471. _getComponent(name: string): Nullable<ISceneComponent>;
  100472. /**
  100473. * @hidden
  100474. * Defines the actions happening before camera updates.
  100475. */
  100476. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  100477. /**
  100478. * @hidden
  100479. * Defines the actions happening before clear the canvas.
  100480. */
  100481. _beforeClearStage: Stage<SimpleStageAction>;
  100482. /**
  100483. * @hidden
  100484. * Defines the actions when collecting render targets for the frame.
  100485. */
  100486. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100487. /**
  100488. * @hidden
  100489. * Defines the actions happening for one camera in the frame.
  100490. */
  100491. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100492. /**
  100493. * @hidden
  100494. * Defines the actions happening during the per mesh ready checks.
  100495. */
  100496. _isReadyForMeshStage: Stage<MeshStageAction>;
  100497. /**
  100498. * @hidden
  100499. * Defines the actions happening before evaluate active mesh checks.
  100500. */
  100501. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  100502. /**
  100503. * @hidden
  100504. * Defines the actions happening during the evaluate sub mesh checks.
  100505. */
  100506. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  100507. /**
  100508. * @hidden
  100509. * Defines the actions happening during the active mesh stage.
  100510. */
  100511. _activeMeshStage: Stage<ActiveMeshStageAction>;
  100512. /**
  100513. * @hidden
  100514. * Defines the actions happening during the per camera render target step.
  100515. */
  100516. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  100517. /**
  100518. * @hidden
  100519. * Defines the actions happening just before the active camera is drawing.
  100520. */
  100521. _beforeCameraDrawStage: Stage<CameraStageAction>;
  100522. /**
  100523. * @hidden
  100524. * Defines the actions happening just before a render target is drawing.
  100525. */
  100526. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100527. /**
  100528. * @hidden
  100529. * Defines the actions happening just before a rendering group is drawing.
  100530. */
  100531. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100532. /**
  100533. * @hidden
  100534. * Defines the actions happening just before a mesh is drawing.
  100535. */
  100536. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100537. /**
  100538. * @hidden
  100539. * Defines the actions happening just after a mesh has been drawn.
  100540. */
  100541. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100542. /**
  100543. * @hidden
  100544. * Defines the actions happening just after a rendering group has been drawn.
  100545. */
  100546. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100547. /**
  100548. * @hidden
  100549. * Defines the actions happening just after the active camera has been drawn.
  100550. */
  100551. _afterCameraDrawStage: Stage<CameraStageAction>;
  100552. /**
  100553. * @hidden
  100554. * Defines the actions happening just after a render target has been drawn.
  100555. */
  100556. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100557. /**
  100558. * @hidden
  100559. * Defines the actions happening just after rendering all cameras and computing intersections.
  100560. */
  100561. _afterRenderStage: Stage<SimpleStageAction>;
  100562. /**
  100563. * @hidden
  100564. * Defines the actions happening when a pointer move event happens.
  100565. */
  100566. _pointerMoveStage: Stage<PointerMoveStageAction>;
  100567. /**
  100568. * @hidden
  100569. * Defines the actions happening when a pointer down event happens.
  100570. */
  100571. _pointerDownStage: Stage<PointerUpDownStageAction>;
  100572. /**
  100573. * @hidden
  100574. * Defines the actions happening when a pointer up event happens.
  100575. */
  100576. _pointerUpStage: Stage<PointerUpDownStageAction>;
  100577. /**
  100578. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  100579. */
  100580. private geometriesByUniqueId;
  100581. /**
  100582. * Creates a new Scene
  100583. * @param engine defines the engine to use to render this scene
  100584. * @param options defines the scene options
  100585. */
  100586. constructor(engine: Engine, options?: SceneOptions);
  100587. /**
  100588. * Gets a string idenfifying the name of the class
  100589. * @returns "Scene" string
  100590. */
  100591. getClassName(): string;
  100592. private _defaultMeshCandidates;
  100593. /**
  100594. * @hidden
  100595. */
  100596. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100597. private _defaultSubMeshCandidates;
  100598. /**
  100599. * @hidden
  100600. */
  100601. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100602. /**
  100603. * Sets the default candidate providers for the scene.
  100604. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  100605. * and getCollidingSubMeshCandidates to their default function
  100606. */
  100607. setDefaultCandidateProviders(): void;
  100608. /**
  100609. * Gets the mesh that is currently under the pointer
  100610. */
  100611. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100612. /**
  100613. * Gets or sets the current on-screen X position of the pointer
  100614. */
  100615. pointerX: number;
  100616. /**
  100617. * Gets or sets the current on-screen Y position of the pointer
  100618. */
  100619. pointerY: number;
  100620. /**
  100621. * Gets the cached material (ie. the latest rendered one)
  100622. * @returns the cached material
  100623. */
  100624. getCachedMaterial(): Nullable<Material>;
  100625. /**
  100626. * Gets the cached effect (ie. the latest rendered one)
  100627. * @returns the cached effect
  100628. */
  100629. getCachedEffect(): Nullable<Effect>;
  100630. /**
  100631. * Gets the cached visibility state (ie. the latest rendered one)
  100632. * @returns the cached visibility state
  100633. */
  100634. getCachedVisibility(): Nullable<number>;
  100635. /**
  100636. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  100637. * @param material defines the current material
  100638. * @param effect defines the current effect
  100639. * @param visibility defines the current visibility state
  100640. * @returns true if one parameter is not cached
  100641. */
  100642. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  100643. /**
  100644. * Gets the engine associated with the scene
  100645. * @returns an Engine
  100646. */
  100647. getEngine(): Engine;
  100648. /**
  100649. * Gets the total number of vertices rendered per frame
  100650. * @returns the total number of vertices rendered per frame
  100651. */
  100652. getTotalVertices(): number;
  100653. /**
  100654. * Gets the performance counter for total vertices
  100655. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100656. */
  100657. readonly totalVerticesPerfCounter: PerfCounter;
  100658. /**
  100659. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  100660. * @returns the total number of active indices rendered per frame
  100661. */
  100662. getActiveIndices(): number;
  100663. /**
  100664. * Gets the performance counter for active indices
  100665. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100666. */
  100667. readonly totalActiveIndicesPerfCounter: PerfCounter;
  100668. /**
  100669. * Gets the total number of active particles rendered per frame
  100670. * @returns the total number of active particles rendered per frame
  100671. */
  100672. getActiveParticles(): number;
  100673. /**
  100674. * Gets the performance counter for active particles
  100675. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100676. */
  100677. readonly activeParticlesPerfCounter: PerfCounter;
  100678. /**
  100679. * Gets the total number of active bones rendered per frame
  100680. * @returns the total number of active bones rendered per frame
  100681. */
  100682. getActiveBones(): number;
  100683. /**
  100684. * Gets the performance counter for active bones
  100685. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100686. */
  100687. readonly activeBonesPerfCounter: PerfCounter;
  100688. /**
  100689. * Gets the array of active meshes
  100690. * @returns an array of AbstractMesh
  100691. */
  100692. getActiveMeshes(): SmartArray<AbstractMesh>;
  100693. /**
  100694. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  100695. * @returns a number
  100696. */
  100697. getAnimationRatio(): number;
  100698. /**
  100699. * Gets an unique Id for the current render phase
  100700. * @returns a number
  100701. */
  100702. getRenderId(): number;
  100703. /**
  100704. * Gets an unique Id for the current frame
  100705. * @returns a number
  100706. */
  100707. getFrameId(): number;
  100708. /** Call this function if you want to manually increment the render Id*/
  100709. incrementRenderId(): void;
  100710. private _createUbo;
  100711. /**
  100712. * Use this method to simulate a pointer move on a mesh
  100713. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100714. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100715. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100716. * @returns the current scene
  100717. */
  100718. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100719. /**
  100720. * Use this method to simulate a pointer down on a mesh
  100721. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100722. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100723. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100724. * @returns the current scene
  100725. */
  100726. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100727. /**
  100728. * Use this method to simulate a pointer up on a mesh
  100729. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100730. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100731. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100732. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100733. * @returns the current scene
  100734. */
  100735. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  100736. /**
  100737. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100738. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100739. * @returns true if the pointer was captured
  100740. */
  100741. isPointerCaptured(pointerId?: number): boolean;
  100742. /**
  100743. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100744. * @param attachUp defines if you want to attach events to pointerup
  100745. * @param attachDown defines if you want to attach events to pointerdown
  100746. * @param attachMove defines if you want to attach events to pointermove
  100747. */
  100748. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100749. /** Detaches all event handlers*/
  100750. detachControl(): void;
  100751. /**
  100752. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  100753. * Delay loaded resources are not taking in account
  100754. * @return true if all required resources are ready
  100755. */
  100756. isReady(): boolean;
  100757. /** Resets all cached information relative to material (including effect and visibility) */
  100758. resetCachedMaterial(): void;
  100759. /**
  100760. * Registers a function to be called before every frame render
  100761. * @param func defines the function to register
  100762. */
  100763. registerBeforeRender(func: () => void): void;
  100764. /**
  100765. * Unregisters a function called before every frame render
  100766. * @param func defines the function to unregister
  100767. */
  100768. unregisterBeforeRender(func: () => void): void;
  100769. /**
  100770. * Registers a function to be called after every frame render
  100771. * @param func defines the function to register
  100772. */
  100773. registerAfterRender(func: () => void): void;
  100774. /**
  100775. * Unregisters a function called after every frame render
  100776. * @param func defines the function to unregister
  100777. */
  100778. unregisterAfterRender(func: () => void): void;
  100779. private _executeOnceBeforeRender;
  100780. /**
  100781. * The provided function will run before render once and will be disposed afterwards.
  100782. * A timeout delay can be provided so that the function will be executed in N ms.
  100783. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  100784. * @param func The function to be executed.
  100785. * @param timeout optional delay in ms
  100786. */
  100787. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  100788. /** @hidden */
  100789. _addPendingData(data: any): void;
  100790. /** @hidden */
  100791. _removePendingData(data: any): void;
  100792. /**
  100793. * Returns the number of items waiting to be loaded
  100794. * @returns the number of items waiting to be loaded
  100795. */
  100796. getWaitingItemsCount(): number;
  100797. /**
  100798. * Returns a boolean indicating if the scene is still loading data
  100799. */
  100800. readonly isLoading: boolean;
  100801. /**
  100802. * Registers a function to be executed when the scene is ready
  100803. * @param {Function} func - the function to be executed
  100804. */
  100805. executeWhenReady(func: () => void): void;
  100806. /**
  100807. * Returns a promise that resolves when the scene is ready
  100808. * @returns A promise that resolves when the scene is ready
  100809. */
  100810. whenReadyAsync(): Promise<void>;
  100811. /** @hidden */
  100812. _checkIsReady(): void;
  100813. /**
  100814. * Gets all animatable attached to the scene
  100815. */
  100816. readonly animatables: Animatable[];
  100817. /**
  100818. * Resets the last animation time frame.
  100819. * Useful to override when animations start running when loading a scene for the first time.
  100820. */
  100821. resetLastAnimationTimeFrame(): void;
  100822. /**
  100823. * Gets the current view matrix
  100824. * @returns a Matrix
  100825. */
  100826. getViewMatrix(): Matrix;
  100827. /**
  100828. * Gets the current projection matrix
  100829. * @returns a Matrix
  100830. */
  100831. getProjectionMatrix(): Matrix;
  100832. /**
  100833. * Gets the current transform matrix
  100834. * @returns a Matrix made of View * Projection
  100835. */
  100836. getTransformMatrix(): Matrix;
  100837. /**
  100838. * Sets the current transform matrix
  100839. * @param viewL defines the View matrix to use
  100840. * @param projectionL defines the Projection matrix to use
  100841. * @param viewR defines the right View matrix to use (if provided)
  100842. * @param projectionR defines the right Projection matrix to use (if provided)
  100843. */
  100844. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  100845. /**
  100846. * Gets the uniform buffer used to store scene data
  100847. * @returns a UniformBuffer
  100848. */
  100849. getSceneUniformBuffer(): UniformBuffer;
  100850. /**
  100851. * Gets an unique (relatively to the current scene) Id
  100852. * @returns an unique number for the scene
  100853. */
  100854. getUniqueId(): number;
  100855. /**
  100856. * Add a mesh to the list of scene's meshes
  100857. * @param newMesh defines the mesh to add
  100858. * @param recursive if all child meshes should also be added to the scene
  100859. */
  100860. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  100861. /**
  100862. * Remove a mesh for the list of scene's meshes
  100863. * @param toRemove defines the mesh to remove
  100864. * @param recursive if all child meshes should also be removed from the scene
  100865. * @returns the index where the mesh was in the mesh list
  100866. */
  100867. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  100868. /**
  100869. * Add a transform node to the list of scene's transform nodes
  100870. * @param newTransformNode defines the transform node to add
  100871. */
  100872. addTransformNode(newTransformNode: TransformNode): void;
  100873. /**
  100874. * Remove a transform node for the list of scene's transform nodes
  100875. * @param toRemove defines the transform node to remove
  100876. * @returns the index where the transform node was in the transform node list
  100877. */
  100878. removeTransformNode(toRemove: TransformNode): number;
  100879. /**
  100880. * Remove a skeleton for the list of scene's skeletons
  100881. * @param toRemove defines the skeleton to remove
  100882. * @returns the index where the skeleton was in the skeleton list
  100883. */
  100884. removeSkeleton(toRemove: Skeleton): number;
  100885. /**
  100886. * Remove a morph target for the list of scene's morph targets
  100887. * @param toRemove defines the morph target to remove
  100888. * @returns the index where the morph target was in the morph target list
  100889. */
  100890. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  100891. /**
  100892. * Remove a light for the list of scene's lights
  100893. * @param toRemove defines the light to remove
  100894. * @returns the index where the light was in the light list
  100895. */
  100896. removeLight(toRemove: Light): number;
  100897. /**
  100898. * Remove a camera for the list of scene's cameras
  100899. * @param toRemove defines the camera to remove
  100900. * @returns the index where the camera was in the camera list
  100901. */
  100902. removeCamera(toRemove: Camera): number;
  100903. /**
  100904. * Remove a particle system for the list of scene's particle systems
  100905. * @param toRemove defines the particle system to remove
  100906. * @returns the index where the particle system was in the particle system list
  100907. */
  100908. removeParticleSystem(toRemove: IParticleSystem): number;
  100909. /**
  100910. * Remove a animation for the list of scene's animations
  100911. * @param toRemove defines the animation to remove
  100912. * @returns the index where the animation was in the animation list
  100913. */
  100914. removeAnimation(toRemove: Animation): number;
  100915. /**
  100916. * Will stop the animation of the given target
  100917. * @param target - the target
  100918. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  100919. * @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)
  100920. */
  100921. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  100922. /**
  100923. * Removes the given animation group from this scene.
  100924. * @param toRemove The animation group to remove
  100925. * @returns The index of the removed animation group
  100926. */
  100927. removeAnimationGroup(toRemove: AnimationGroup): number;
  100928. /**
  100929. * Removes the given multi-material from this scene.
  100930. * @param toRemove The multi-material to remove
  100931. * @returns The index of the removed multi-material
  100932. */
  100933. removeMultiMaterial(toRemove: MultiMaterial): number;
  100934. /**
  100935. * Removes the given material from this scene.
  100936. * @param toRemove The material to remove
  100937. * @returns The index of the removed material
  100938. */
  100939. removeMaterial(toRemove: Material): number;
  100940. /**
  100941. * Removes the given action manager from this scene.
  100942. * @param toRemove The action manager to remove
  100943. * @returns The index of the removed action manager
  100944. */
  100945. removeActionManager(toRemove: AbstractActionManager): number;
  100946. /**
  100947. * Removes the given texture from this scene.
  100948. * @param toRemove The texture to remove
  100949. * @returns The index of the removed texture
  100950. */
  100951. removeTexture(toRemove: BaseTexture): number;
  100952. /**
  100953. * Adds the given light to this scene
  100954. * @param newLight The light to add
  100955. */
  100956. addLight(newLight: Light): void;
  100957. /**
  100958. * Sorts the list list based on light priorities
  100959. */
  100960. sortLightsByPriority(): void;
  100961. /**
  100962. * Adds the given camera to this scene
  100963. * @param newCamera The camera to add
  100964. */
  100965. addCamera(newCamera: Camera): void;
  100966. /**
  100967. * Adds the given skeleton to this scene
  100968. * @param newSkeleton The skeleton to add
  100969. */
  100970. addSkeleton(newSkeleton: Skeleton): void;
  100971. /**
  100972. * Adds the given particle system to this scene
  100973. * @param newParticleSystem The particle system to add
  100974. */
  100975. addParticleSystem(newParticleSystem: IParticleSystem): void;
  100976. /**
  100977. * Adds the given animation to this scene
  100978. * @param newAnimation The animation to add
  100979. */
  100980. addAnimation(newAnimation: Animation): void;
  100981. /**
  100982. * Adds the given animation group to this scene.
  100983. * @param newAnimationGroup The animation group to add
  100984. */
  100985. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  100986. /**
  100987. * Adds the given multi-material to this scene
  100988. * @param newMultiMaterial The multi-material to add
  100989. */
  100990. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  100991. /**
  100992. * Adds the given material to this scene
  100993. * @param newMaterial The material to add
  100994. */
  100995. addMaterial(newMaterial: Material): void;
  100996. /**
  100997. * Adds the given morph target to this scene
  100998. * @param newMorphTargetManager The morph target to add
  100999. */
  101000. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  101001. /**
  101002. * Adds the given geometry to this scene
  101003. * @param newGeometry The geometry to add
  101004. */
  101005. addGeometry(newGeometry: Geometry): void;
  101006. /**
  101007. * Adds the given action manager to this scene
  101008. * @param newActionManager The action manager to add
  101009. */
  101010. addActionManager(newActionManager: AbstractActionManager): void;
  101011. /**
  101012. * Adds the given texture to this scene.
  101013. * @param newTexture The texture to add
  101014. */
  101015. addTexture(newTexture: BaseTexture): void;
  101016. /**
  101017. * Switch active camera
  101018. * @param newCamera defines the new active camera
  101019. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  101020. */
  101021. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  101022. /**
  101023. * sets the active camera of the scene using its ID
  101024. * @param id defines the camera's ID
  101025. * @return the new active camera or null if none found.
  101026. */
  101027. setActiveCameraByID(id: string): Nullable<Camera>;
  101028. /**
  101029. * sets the active camera of the scene using its name
  101030. * @param name defines the camera's name
  101031. * @returns the new active camera or null if none found.
  101032. */
  101033. setActiveCameraByName(name: string): Nullable<Camera>;
  101034. /**
  101035. * get an animation group using its name
  101036. * @param name defines the material's name
  101037. * @return the animation group or null if none found.
  101038. */
  101039. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  101040. /**
  101041. * Get a material using its unique id
  101042. * @param uniqueId defines the material's unique id
  101043. * @return the material or null if none found.
  101044. */
  101045. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  101046. /**
  101047. * get a material using its id
  101048. * @param id defines the material's ID
  101049. * @return the material or null if none found.
  101050. */
  101051. getMaterialByID(id: string): Nullable<Material>;
  101052. /**
  101053. * Gets a the last added material using a given id
  101054. * @param id defines the material's ID
  101055. * @return the last material with the given id or null if none found.
  101056. */
  101057. getLastMaterialByID(id: string): Nullable<Material>;
  101058. /**
  101059. * Gets a material using its name
  101060. * @param name defines the material's name
  101061. * @return the material or null if none found.
  101062. */
  101063. getMaterialByName(name: string): Nullable<Material>;
  101064. /**
  101065. * Get a texture using its unique id
  101066. * @param uniqueId defines the texture's unique id
  101067. * @return the texture or null if none found.
  101068. */
  101069. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  101070. /**
  101071. * Gets a camera using its id
  101072. * @param id defines the id to look for
  101073. * @returns the camera or null if not found
  101074. */
  101075. getCameraByID(id: string): Nullable<Camera>;
  101076. /**
  101077. * Gets a camera using its unique id
  101078. * @param uniqueId defines the unique id to look for
  101079. * @returns the camera or null if not found
  101080. */
  101081. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  101082. /**
  101083. * Gets a camera using its name
  101084. * @param name defines the camera's name
  101085. * @return the camera or null if none found.
  101086. */
  101087. getCameraByName(name: string): Nullable<Camera>;
  101088. /**
  101089. * Gets a bone using its id
  101090. * @param id defines the bone's id
  101091. * @return the bone or null if not found
  101092. */
  101093. getBoneByID(id: string): Nullable<Bone>;
  101094. /**
  101095. * Gets a bone using its id
  101096. * @param name defines the bone's name
  101097. * @return the bone or null if not found
  101098. */
  101099. getBoneByName(name: string): Nullable<Bone>;
  101100. /**
  101101. * Gets a light node using its name
  101102. * @param name defines the the light's name
  101103. * @return the light or null if none found.
  101104. */
  101105. getLightByName(name: string): Nullable<Light>;
  101106. /**
  101107. * Gets a light node using its id
  101108. * @param id defines the light's id
  101109. * @return the light or null if none found.
  101110. */
  101111. getLightByID(id: string): Nullable<Light>;
  101112. /**
  101113. * Gets a light node using its scene-generated unique ID
  101114. * @param uniqueId defines the light's unique id
  101115. * @return the light or null if none found.
  101116. */
  101117. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  101118. /**
  101119. * Gets a particle system by id
  101120. * @param id defines the particle system id
  101121. * @return the corresponding system or null if none found
  101122. */
  101123. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101124. /**
  101125. * Gets a geometry using its ID
  101126. * @param id defines the geometry's id
  101127. * @return the geometry or null if none found.
  101128. */
  101129. getGeometryByID(id: string): Nullable<Geometry>;
  101130. private _getGeometryByUniqueID;
  101131. /**
  101132. * Add a new geometry to this scene
  101133. * @param geometry defines the geometry to be added to the scene.
  101134. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101135. * @return a boolean defining if the geometry was added or not
  101136. */
  101137. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101138. /**
  101139. * Removes an existing geometry
  101140. * @param geometry defines the geometry to be removed from the scene
  101141. * @return a boolean defining if the geometry was removed or not
  101142. */
  101143. removeGeometry(geometry: Geometry): boolean;
  101144. /**
  101145. * Gets the list of geometries attached to the scene
  101146. * @returns an array of Geometry
  101147. */
  101148. getGeometries(): Geometry[];
  101149. /**
  101150. * Gets the first added mesh found of a given ID
  101151. * @param id defines the id to search for
  101152. * @return the mesh found or null if not found at all
  101153. */
  101154. getMeshByID(id: string): Nullable<AbstractMesh>;
  101155. /**
  101156. * Gets a list of meshes using their id
  101157. * @param id defines the id to search for
  101158. * @returns a list of meshes
  101159. */
  101160. getMeshesByID(id: string): Array<AbstractMesh>;
  101161. /**
  101162. * Gets the first added transform node found of a given ID
  101163. * @param id defines the id to search for
  101164. * @return the found transform node or null if not found at all.
  101165. */
  101166. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101167. /**
  101168. * Gets a transform node with its auto-generated unique id
  101169. * @param uniqueId efines the unique id to search for
  101170. * @return the found transform node or null if not found at all.
  101171. */
  101172. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101173. /**
  101174. * Gets a list of transform nodes using their id
  101175. * @param id defines the id to search for
  101176. * @returns a list of transform nodes
  101177. */
  101178. getTransformNodesByID(id: string): Array<TransformNode>;
  101179. /**
  101180. * Gets a mesh with its auto-generated unique id
  101181. * @param uniqueId defines the unique id to search for
  101182. * @return the found mesh or null if not found at all.
  101183. */
  101184. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101185. /**
  101186. * Gets a the last added mesh using a given id
  101187. * @param id defines the id to search for
  101188. * @return the found mesh or null if not found at all.
  101189. */
  101190. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101191. /**
  101192. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101193. * @param id defines the id to search for
  101194. * @return the found node or null if not found at all
  101195. */
  101196. getLastEntryByID(id: string): Nullable<Node>;
  101197. /**
  101198. * Gets a node (Mesh, Camera, Light) using a given id
  101199. * @param id defines the id to search for
  101200. * @return the found node or null if not found at all
  101201. */
  101202. getNodeByID(id: string): Nullable<Node>;
  101203. /**
  101204. * Gets a node (Mesh, Camera, Light) using a given name
  101205. * @param name defines the name to search for
  101206. * @return the found node or null if not found at all.
  101207. */
  101208. getNodeByName(name: string): Nullable<Node>;
  101209. /**
  101210. * Gets a mesh using a given name
  101211. * @param name defines the name to search for
  101212. * @return the found mesh or null if not found at all.
  101213. */
  101214. getMeshByName(name: string): Nullable<AbstractMesh>;
  101215. /**
  101216. * Gets a transform node using a given name
  101217. * @param name defines the name to search for
  101218. * @return the found transform node or null if not found at all.
  101219. */
  101220. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101221. /**
  101222. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101223. * @param id defines the id to search for
  101224. * @return the found skeleton or null if not found at all.
  101225. */
  101226. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101227. /**
  101228. * Gets a skeleton using a given auto generated unique id
  101229. * @param uniqueId defines the unique id to search for
  101230. * @return the found skeleton or null if not found at all.
  101231. */
  101232. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101233. /**
  101234. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101235. * @param id defines the id to search for
  101236. * @return the found skeleton or null if not found at all.
  101237. */
  101238. getSkeletonById(id: string): Nullable<Skeleton>;
  101239. /**
  101240. * Gets a skeleton using a given name
  101241. * @param name defines the name to search for
  101242. * @return the found skeleton or null if not found at all.
  101243. */
  101244. getSkeletonByName(name: string): Nullable<Skeleton>;
  101245. /**
  101246. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  101247. * @param id defines the id to search for
  101248. * @return the found morph target manager or null if not found at all.
  101249. */
  101250. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101251. /**
  101252. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101253. * @param id defines the id to search for
  101254. * @return the found morph target or null if not found at all.
  101255. */
  101256. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101257. /**
  101258. * Gets a boolean indicating if the given mesh is active
  101259. * @param mesh defines the mesh to look for
  101260. * @returns true if the mesh is in the active list
  101261. */
  101262. isActiveMesh(mesh: AbstractMesh): boolean;
  101263. /**
  101264. * Return a unique id as a string which can serve as an identifier for the scene
  101265. */
  101266. readonly uid: string;
  101267. /**
  101268. * Add an externaly attached data from its key.
  101269. * This method call will fail and return false, if such key already exists.
  101270. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  101271. * @param key the unique key that identifies the data
  101272. * @param data the data object to associate to the key for this Engine instance
  101273. * @return true if no such key were already present and the data was added successfully, false otherwise
  101274. */
  101275. addExternalData<T>(key: string, data: T): boolean;
  101276. /**
  101277. * Get an externaly attached data from its key
  101278. * @param key the unique key that identifies the data
  101279. * @return the associated data, if present (can be null), or undefined if not present
  101280. */
  101281. getExternalData<T>(key: string): Nullable<T>;
  101282. /**
  101283. * Get an externaly attached data from its key, create it using a factory if it's not already present
  101284. * @param key the unique key that identifies the data
  101285. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  101286. * @return the associated data, can be null if the factory returned null.
  101287. */
  101288. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  101289. /**
  101290. * Remove an externaly attached data from the Engine instance
  101291. * @param key the unique key that identifies the data
  101292. * @return true if the data was successfully removed, false if it doesn't exist
  101293. */
  101294. removeExternalData(key: string): boolean;
  101295. private _evaluateSubMesh;
  101296. /**
  101297. * Clear the processed materials smart array preventing retention point in material dispose.
  101298. */
  101299. freeProcessedMaterials(): void;
  101300. private _preventFreeActiveMeshesAndRenderingGroups;
  101301. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  101302. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  101303. * when disposing several meshes in a row or a hierarchy of meshes.
  101304. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  101305. */
  101306. blockfreeActiveMeshesAndRenderingGroups: boolean;
  101307. /**
  101308. * Clear the active meshes smart array preventing retention point in mesh dispose.
  101309. */
  101310. freeActiveMeshes(): void;
  101311. /**
  101312. * Clear the info related to rendering groups preventing retention points during dispose.
  101313. */
  101314. freeRenderingGroups(): void;
  101315. /** @hidden */
  101316. _isInIntermediateRendering(): boolean;
  101317. /**
  101318. * Lambda returning the list of potentially active meshes.
  101319. */
  101320. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  101321. /**
  101322. * Lambda returning the list of potentially active sub meshes.
  101323. */
  101324. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  101325. /**
  101326. * Lambda returning the list of potentially intersecting sub meshes.
  101327. */
  101328. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  101329. /**
  101330. * Lambda returning the list of potentially colliding sub meshes.
  101331. */
  101332. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  101333. private _activeMeshesFrozen;
  101334. /**
  101335. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  101336. * @returns the current scene
  101337. */
  101338. freezeActiveMeshes(): Scene;
  101339. /**
  101340. * Use this function to restart evaluating active meshes on every frame
  101341. * @returns the current scene
  101342. */
  101343. unfreezeActiveMeshes(): Scene;
  101344. private _evaluateActiveMeshes;
  101345. private _activeMesh;
  101346. /**
  101347. * Update the transform matrix to update from the current active camera
  101348. * @param force defines a boolean used to force the update even if cache is up to date
  101349. */
  101350. updateTransformMatrix(force?: boolean): void;
  101351. private _bindFrameBuffer;
  101352. /** @hidden */
  101353. _allowPostProcessClearColor: boolean;
  101354. /** @hidden */
  101355. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  101356. private _processSubCameras;
  101357. private _checkIntersections;
  101358. /** @hidden */
  101359. _advancePhysicsEngineStep(step: number): void;
  101360. /**
  101361. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  101362. */
  101363. getDeterministicFrameTime: () => number;
  101364. /** @hidden */
  101365. _animate(): void;
  101366. /** Execute all animations (for a frame) */
  101367. animate(): void;
  101368. /**
  101369. * Render the scene
  101370. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  101371. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  101372. */
  101373. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  101374. /**
  101375. * Freeze all materials
  101376. * A frozen material will not be updatable but should be faster to render
  101377. */
  101378. freezeMaterials(): void;
  101379. /**
  101380. * Unfreeze all materials
  101381. * A frozen material will not be updatable but should be faster to render
  101382. */
  101383. unfreezeMaterials(): void;
  101384. /**
  101385. * Releases all held ressources
  101386. */
  101387. dispose(): void;
  101388. /**
  101389. * Gets if the scene is already disposed
  101390. */
  101391. readonly isDisposed: boolean;
  101392. /**
  101393. * Call this function to reduce memory footprint of the scene.
  101394. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  101395. */
  101396. clearCachedVertexData(): void;
  101397. /**
  101398. * This function will remove the local cached buffer data from texture.
  101399. * It will save memory but will prevent the texture from being rebuilt
  101400. */
  101401. cleanCachedTextureBuffer(): void;
  101402. /**
  101403. * Get the world extend vectors with an optional filter
  101404. *
  101405. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  101406. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  101407. */
  101408. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  101409. min: Vector3;
  101410. max: Vector3;
  101411. };
  101412. /**
  101413. * Creates a ray that can be used to pick in the scene
  101414. * @param x defines the x coordinate of the origin (on-screen)
  101415. * @param y defines the y coordinate of the origin (on-screen)
  101416. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101417. * @param camera defines the camera to use for the picking
  101418. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101419. * @returns a Ray
  101420. */
  101421. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  101422. /**
  101423. * Creates a ray that can be used to pick in the scene
  101424. * @param x defines the x coordinate of the origin (on-screen)
  101425. * @param y defines the y coordinate of the origin (on-screen)
  101426. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101427. * @param result defines the ray where to store the picking ray
  101428. * @param camera defines the camera to use for the picking
  101429. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101430. * @returns the current scene
  101431. */
  101432. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  101433. /**
  101434. * Creates a ray that can be used to pick in the scene
  101435. * @param x defines the x coordinate of the origin (on-screen)
  101436. * @param y defines the y coordinate of the origin (on-screen)
  101437. * @param camera defines the camera to use for the picking
  101438. * @returns a Ray
  101439. */
  101440. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  101441. /**
  101442. * Creates a ray that can be used to pick in the scene
  101443. * @param x defines the x coordinate of the origin (on-screen)
  101444. * @param y defines the y coordinate of the origin (on-screen)
  101445. * @param result defines the ray where to store the picking ray
  101446. * @param camera defines the camera to use for the picking
  101447. * @returns the current scene
  101448. */
  101449. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  101450. /** Launch a ray to try to pick a mesh in the scene
  101451. * @param x position on screen
  101452. * @param y position on screen
  101453. * @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
  101454. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  101455. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101456. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101457. * @returns a PickingInfo
  101458. */
  101459. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101460. /** Use the given ray to pick a mesh in the scene
  101461. * @param ray The ray to use to pick meshes
  101462. * @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
  101463. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  101464. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101465. * @returns a PickingInfo
  101466. */
  101467. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101468. /**
  101469. * Launch a ray to try to pick a mesh in the scene
  101470. * @param x X position on screen
  101471. * @param y Y position on screen
  101472. * @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
  101473. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101474. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101475. * @returns an array of PickingInfo
  101476. */
  101477. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101478. /**
  101479. * Launch a ray to try to pick a mesh in the scene
  101480. * @param ray Ray to use
  101481. * @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
  101482. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101483. * @returns an array of PickingInfo
  101484. */
  101485. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101486. /**
  101487. * Force the value of meshUnderPointer
  101488. * @param mesh defines the mesh to use
  101489. */
  101490. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101491. /**
  101492. * Gets the mesh under the pointer
  101493. * @returns a Mesh or null if no mesh is under the pointer
  101494. */
  101495. getPointerOverMesh(): Nullable<AbstractMesh>;
  101496. /** @hidden */
  101497. _rebuildGeometries(): void;
  101498. /** @hidden */
  101499. _rebuildTextures(): void;
  101500. private _getByTags;
  101501. /**
  101502. * Get a list of meshes by tags
  101503. * @param tagsQuery defines the tags query to use
  101504. * @param forEach defines a predicate used to filter results
  101505. * @returns an array of Mesh
  101506. */
  101507. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  101508. /**
  101509. * Get a list of cameras by tags
  101510. * @param tagsQuery defines the tags query to use
  101511. * @param forEach defines a predicate used to filter results
  101512. * @returns an array of Camera
  101513. */
  101514. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  101515. /**
  101516. * Get a list of lights by tags
  101517. * @param tagsQuery defines the tags query to use
  101518. * @param forEach defines a predicate used to filter results
  101519. * @returns an array of Light
  101520. */
  101521. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  101522. /**
  101523. * Get a list of materials by tags
  101524. * @param tagsQuery defines the tags query to use
  101525. * @param forEach defines a predicate used to filter results
  101526. * @returns an array of Material
  101527. */
  101528. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  101529. /**
  101530. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101531. * This allowed control for front to back rendering or reversly depending of the special needs.
  101532. *
  101533. * @param renderingGroupId The rendering group id corresponding to its index
  101534. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101535. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101536. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101537. */
  101538. 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;
  101539. /**
  101540. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101541. *
  101542. * @param renderingGroupId The rendering group id corresponding to its index
  101543. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101544. * @param depth Automatically clears depth between groups if true and autoClear is true.
  101545. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  101546. */
  101547. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  101548. /**
  101549. * Gets the current auto clear configuration for one rendering group of the rendering
  101550. * manager.
  101551. * @param index the rendering group index to get the information for
  101552. * @returns The auto clear setup for the requested rendering group
  101553. */
  101554. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  101555. private _blockMaterialDirtyMechanism;
  101556. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  101557. blockMaterialDirtyMechanism: boolean;
  101558. /**
  101559. * Will flag all materials as dirty to trigger new shader compilation
  101560. * @param flag defines the flag used to specify which material part must be marked as dirty
  101561. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  101562. */
  101563. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101564. /** @hidden */
  101565. _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;
  101566. /** @hidden */
  101567. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101568. }
  101569. }
  101570. declare module BABYLON {
  101571. /**
  101572. * Set of assets to keep when moving a scene into an asset container.
  101573. */
  101574. export class KeepAssets extends AbstractScene {
  101575. }
  101576. /**
  101577. * Container with a set of assets that can be added or removed from a scene.
  101578. */
  101579. export class AssetContainer extends AbstractScene {
  101580. /**
  101581. * The scene the AssetContainer belongs to.
  101582. */
  101583. scene: Scene;
  101584. /**
  101585. * Instantiates an AssetContainer.
  101586. * @param scene The scene the AssetContainer belongs to.
  101587. */
  101588. constructor(scene: Scene);
  101589. /**
  101590. * Adds all the assets from the container to the scene.
  101591. */
  101592. addAllToScene(): void;
  101593. /**
  101594. * Removes all the assets in the container from the scene
  101595. */
  101596. removeAllFromScene(): void;
  101597. /**
  101598. * Disposes all the assets in the container
  101599. */
  101600. dispose(): void;
  101601. private _moveAssets;
  101602. /**
  101603. * Removes all the assets contained in the scene and adds them to the container.
  101604. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  101605. */
  101606. moveAllFromScene(keepAssets?: KeepAssets): void;
  101607. /**
  101608. * 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.
  101609. * @returns the root mesh
  101610. */
  101611. createRootMesh(): Mesh;
  101612. }
  101613. }
  101614. declare module BABYLON {
  101615. /**
  101616. * Defines how the parser contract is defined.
  101617. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  101618. */
  101619. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  101620. /**
  101621. * Defines how the individual parser contract is defined.
  101622. * These parser can parse an individual asset
  101623. */
  101624. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  101625. /**
  101626. * Base class of the scene acting as a container for the different elements composing a scene.
  101627. * This class is dynamically extended by the different components of the scene increasing
  101628. * flexibility and reducing coupling
  101629. */
  101630. export abstract class AbstractScene {
  101631. /**
  101632. * Stores the list of available parsers in the application.
  101633. */
  101634. private static _BabylonFileParsers;
  101635. /**
  101636. * Stores the list of available individual parsers in the application.
  101637. */
  101638. private static _IndividualBabylonFileParsers;
  101639. /**
  101640. * Adds a parser in the list of available ones
  101641. * @param name Defines the name of the parser
  101642. * @param parser Defines the parser to add
  101643. */
  101644. static AddParser(name: string, parser: BabylonFileParser): void;
  101645. /**
  101646. * Gets a general parser from the list of avaialble ones
  101647. * @param name Defines the name of the parser
  101648. * @returns the requested parser or null
  101649. */
  101650. static GetParser(name: string): Nullable<BabylonFileParser>;
  101651. /**
  101652. * Adds n individual parser in the list of available ones
  101653. * @param name Defines the name of the parser
  101654. * @param parser Defines the parser to add
  101655. */
  101656. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  101657. /**
  101658. * Gets an individual parser from the list of avaialble ones
  101659. * @param name Defines the name of the parser
  101660. * @returns the requested parser or null
  101661. */
  101662. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  101663. /**
  101664. * Parser json data and populate both a scene and its associated container object
  101665. * @param jsonData Defines the data to parse
  101666. * @param scene Defines the scene to parse the data for
  101667. * @param container Defines the container attached to the parsing sequence
  101668. * @param rootUrl Defines the root url of the data
  101669. */
  101670. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  101671. /**
  101672. * Gets the list of root nodes (ie. nodes with no parent)
  101673. */
  101674. rootNodes: Node[];
  101675. /** All of the cameras added to this scene
  101676. * @see http://doc.babylonjs.com/babylon101/cameras
  101677. */
  101678. cameras: Camera[];
  101679. /**
  101680. * All of the lights added to this scene
  101681. * @see http://doc.babylonjs.com/babylon101/lights
  101682. */
  101683. lights: Light[];
  101684. /**
  101685. * All of the (abstract) meshes added to this scene
  101686. */
  101687. meshes: AbstractMesh[];
  101688. /**
  101689. * The list of skeletons added to the scene
  101690. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101691. */
  101692. skeletons: Skeleton[];
  101693. /**
  101694. * All of the particle systems added to this scene
  101695. * @see http://doc.babylonjs.com/babylon101/particles
  101696. */
  101697. particleSystems: IParticleSystem[];
  101698. /**
  101699. * Gets a list of Animations associated with the scene
  101700. */
  101701. animations: Animation[];
  101702. /**
  101703. * All of the animation groups added to this scene
  101704. * @see http://doc.babylonjs.com/how_to/group
  101705. */
  101706. animationGroups: AnimationGroup[];
  101707. /**
  101708. * All of the multi-materials added to this scene
  101709. * @see http://doc.babylonjs.com/how_to/multi_materials
  101710. */
  101711. multiMaterials: MultiMaterial[];
  101712. /**
  101713. * All of the materials added to this scene
  101714. * In the context of a Scene, it is not supposed to be modified manually.
  101715. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  101716. * Note also that the order of the Material wihin the array is not significant and might change.
  101717. * @see http://doc.babylonjs.com/babylon101/materials
  101718. */
  101719. materials: Material[];
  101720. /**
  101721. * The list of morph target managers added to the scene
  101722. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  101723. */
  101724. morphTargetManagers: MorphTargetManager[];
  101725. /**
  101726. * The list of geometries used in the scene.
  101727. */
  101728. geometries: Geometry[];
  101729. /**
  101730. * All of the tranform nodes added to this scene
  101731. * In the context of a Scene, it is not supposed to be modified manually.
  101732. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  101733. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  101734. * @see http://doc.babylonjs.com/how_to/transformnode
  101735. */
  101736. transformNodes: TransformNode[];
  101737. /**
  101738. * ActionManagers available on the scene.
  101739. */
  101740. actionManagers: AbstractActionManager[];
  101741. /**
  101742. * Textures to keep.
  101743. */
  101744. textures: BaseTexture[];
  101745. /**
  101746. * Environment texture for the scene
  101747. */
  101748. environmentTexture: Nullable<BaseTexture>;
  101749. }
  101750. }
  101751. declare module BABYLON {
  101752. /**
  101753. * Interface used to define options for Sound class
  101754. */
  101755. export interface ISoundOptions {
  101756. /**
  101757. * Does the sound autoplay once loaded.
  101758. */
  101759. autoplay?: boolean;
  101760. /**
  101761. * Does the sound loop after it finishes playing once.
  101762. */
  101763. loop?: boolean;
  101764. /**
  101765. * Sound's volume
  101766. */
  101767. volume?: number;
  101768. /**
  101769. * Is it a spatial sound?
  101770. */
  101771. spatialSound?: boolean;
  101772. /**
  101773. * Maximum distance to hear that sound
  101774. */
  101775. maxDistance?: number;
  101776. /**
  101777. * Uses user defined attenuation function
  101778. */
  101779. useCustomAttenuation?: boolean;
  101780. /**
  101781. * Define the roll off factor of spatial sounds.
  101782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101783. */
  101784. rolloffFactor?: number;
  101785. /**
  101786. * Define the reference distance the sound should be heard perfectly.
  101787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101788. */
  101789. refDistance?: number;
  101790. /**
  101791. * Define the distance attenuation model the sound will follow.
  101792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101793. */
  101794. distanceModel?: string;
  101795. /**
  101796. * Defines the playback speed (1 by default)
  101797. */
  101798. playbackRate?: number;
  101799. /**
  101800. * Defines if the sound is from a streaming source
  101801. */
  101802. streaming?: boolean;
  101803. /**
  101804. * Defines an optional length (in seconds) inside the sound file
  101805. */
  101806. length?: number;
  101807. /**
  101808. * Defines an optional offset (in seconds) inside the sound file
  101809. */
  101810. offset?: number;
  101811. /**
  101812. * If true, URLs will not be required to state the audio file codec to use.
  101813. */
  101814. skipCodecCheck?: boolean;
  101815. }
  101816. /**
  101817. * Defines a sound that can be played in the application.
  101818. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  101819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101820. */
  101821. export class Sound {
  101822. /**
  101823. * The name of the sound in the scene.
  101824. */
  101825. name: string;
  101826. /**
  101827. * Does the sound autoplay once loaded.
  101828. */
  101829. autoplay: boolean;
  101830. /**
  101831. * Does the sound loop after it finishes playing once.
  101832. */
  101833. loop: boolean;
  101834. /**
  101835. * Does the sound use a custom attenuation curve to simulate the falloff
  101836. * happening when the source gets further away from the camera.
  101837. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101838. */
  101839. useCustomAttenuation: boolean;
  101840. /**
  101841. * The sound track id this sound belongs to.
  101842. */
  101843. soundTrackId: number;
  101844. /**
  101845. * Is this sound currently played.
  101846. */
  101847. isPlaying: boolean;
  101848. /**
  101849. * Is this sound currently paused.
  101850. */
  101851. isPaused: boolean;
  101852. /**
  101853. * Does this sound enables spatial sound.
  101854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101855. */
  101856. spatialSound: boolean;
  101857. /**
  101858. * Define the reference distance the sound should be heard perfectly.
  101859. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101860. */
  101861. refDistance: number;
  101862. /**
  101863. * Define the roll off factor of spatial sounds.
  101864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101865. */
  101866. rolloffFactor: number;
  101867. /**
  101868. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  101869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101870. */
  101871. maxDistance: number;
  101872. /**
  101873. * Define the distance attenuation model the sound will follow.
  101874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101875. */
  101876. distanceModel: string;
  101877. /**
  101878. * @hidden
  101879. * Back Compat
  101880. **/
  101881. onended: () => any;
  101882. /**
  101883. * Observable event when the current playing sound finishes.
  101884. */
  101885. onEndedObservable: Observable<Sound>;
  101886. private _panningModel;
  101887. private _playbackRate;
  101888. private _streaming;
  101889. private _startTime;
  101890. private _startOffset;
  101891. private _position;
  101892. /** @hidden */
  101893. _positionInEmitterSpace: boolean;
  101894. private _localDirection;
  101895. private _volume;
  101896. private _isReadyToPlay;
  101897. private _isDirectional;
  101898. private _readyToPlayCallback;
  101899. private _audioBuffer;
  101900. private _soundSource;
  101901. private _streamingSource;
  101902. private _soundPanner;
  101903. private _soundGain;
  101904. private _inputAudioNode;
  101905. private _outputAudioNode;
  101906. private _coneInnerAngle;
  101907. private _coneOuterAngle;
  101908. private _coneOuterGain;
  101909. private _scene;
  101910. private _connectedTransformNode;
  101911. private _customAttenuationFunction;
  101912. private _registerFunc;
  101913. private _isOutputConnected;
  101914. private _htmlAudioElement;
  101915. private _urlType;
  101916. private _length?;
  101917. private _offset?;
  101918. /** @hidden */
  101919. static _SceneComponentInitialization: (scene: Scene) => void;
  101920. /**
  101921. * Create a sound and attach it to a scene
  101922. * @param name Name of your sound
  101923. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  101924. * @param scene defines the scene the sound belongs to
  101925. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  101926. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  101927. */
  101928. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  101929. /**
  101930. * Release the sound and its associated resources
  101931. */
  101932. dispose(): void;
  101933. /**
  101934. * Gets if the sounds is ready to be played or not.
  101935. * @returns true if ready, otherwise false
  101936. */
  101937. isReady(): boolean;
  101938. private _soundLoaded;
  101939. /**
  101940. * Sets the data of the sound from an audiobuffer
  101941. * @param audioBuffer The audioBuffer containing the data
  101942. */
  101943. setAudioBuffer(audioBuffer: AudioBuffer): void;
  101944. /**
  101945. * Updates the current sounds options such as maxdistance, loop...
  101946. * @param options A JSON object containing values named as the object properties
  101947. */
  101948. updateOptions(options: ISoundOptions): void;
  101949. private _createSpatialParameters;
  101950. private _updateSpatialParameters;
  101951. /**
  101952. * Switch the panning model to HRTF:
  101953. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101955. */
  101956. switchPanningModelToHRTF(): void;
  101957. /**
  101958. * Switch the panning model to Equal Power:
  101959. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101961. */
  101962. switchPanningModelToEqualPower(): void;
  101963. private _switchPanningModel;
  101964. /**
  101965. * Connect this sound to a sound track audio node like gain...
  101966. * @param soundTrackAudioNode the sound track audio node to connect to
  101967. */
  101968. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  101969. /**
  101970. * Transform this sound into a directional source
  101971. * @param coneInnerAngle Size of the inner cone in degree
  101972. * @param coneOuterAngle Size of the outer cone in degree
  101973. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  101974. */
  101975. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  101976. /**
  101977. * Gets or sets the inner angle for the directional cone.
  101978. */
  101979. /**
  101980. * Gets or sets the inner angle for the directional cone.
  101981. */
  101982. directionalConeInnerAngle: number;
  101983. /**
  101984. * Gets or sets the outer angle for the directional cone.
  101985. */
  101986. /**
  101987. * Gets or sets the outer angle for the directional cone.
  101988. */
  101989. directionalConeOuterAngle: number;
  101990. /**
  101991. * Sets the position of the emitter if spatial sound is enabled
  101992. * @param newPosition Defines the new posisiton
  101993. */
  101994. setPosition(newPosition: Vector3): void;
  101995. /**
  101996. * Sets the local direction of the emitter if spatial sound is enabled
  101997. * @param newLocalDirection Defines the new local direction
  101998. */
  101999. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  102000. private _updateDirection;
  102001. /** @hidden */
  102002. updateDistanceFromListener(): void;
  102003. /**
  102004. * Sets a new custom attenuation function for the sound.
  102005. * @param callback Defines the function used for the attenuation
  102006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102007. */
  102008. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  102009. /**
  102010. * Play the sound
  102011. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  102012. * @param offset (optional) Start the sound at a specific time in seconds
  102013. * @param length (optional) Sound duration (in seconds)
  102014. */
  102015. play(time?: number, offset?: number, length?: number): void;
  102016. private _onended;
  102017. /**
  102018. * Stop the sound
  102019. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  102020. */
  102021. stop(time?: number): void;
  102022. /**
  102023. * Put the sound in pause
  102024. */
  102025. pause(): void;
  102026. /**
  102027. * Sets a dedicated volume for this sounds
  102028. * @param newVolume Define the new volume of the sound
  102029. * @param time Define time for gradual change to new volume
  102030. */
  102031. setVolume(newVolume: number, time?: number): void;
  102032. /**
  102033. * Set the sound play back rate
  102034. * @param newPlaybackRate Define the playback rate the sound should be played at
  102035. */
  102036. setPlaybackRate(newPlaybackRate: number): void;
  102037. /**
  102038. * Gets the volume of the sound.
  102039. * @returns the volume of the sound
  102040. */
  102041. getVolume(): number;
  102042. /**
  102043. * Attach the sound to a dedicated mesh
  102044. * @param transformNode The transform node to connect the sound with
  102045. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102046. */
  102047. attachToMesh(transformNode: TransformNode): void;
  102048. /**
  102049. * Detach the sound from the previously attached mesh
  102050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102051. */
  102052. detachFromMesh(): void;
  102053. private _onRegisterAfterWorldMatrixUpdate;
  102054. /**
  102055. * Clone the current sound in the scene.
  102056. * @returns the new sound clone
  102057. */
  102058. clone(): Nullable<Sound>;
  102059. /**
  102060. * Gets the current underlying audio buffer containing the data
  102061. * @returns the audio buffer
  102062. */
  102063. getAudioBuffer(): Nullable<AudioBuffer>;
  102064. /**
  102065. * Serializes the Sound in a JSON representation
  102066. * @returns the JSON representation of the sound
  102067. */
  102068. serialize(): any;
  102069. /**
  102070. * Parse a JSON representation of a sound to innstantiate in a given scene
  102071. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  102072. * @param scene Define the scene the new parsed sound should be created in
  102073. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  102074. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  102075. * @returns the newly parsed sound
  102076. */
  102077. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  102078. }
  102079. }
  102080. declare module BABYLON {
  102081. /**
  102082. * This defines an action helpful to play a defined sound on a triggered action.
  102083. */
  102084. export class PlaySoundAction extends Action {
  102085. private _sound;
  102086. /**
  102087. * Instantiate the action
  102088. * @param triggerOptions defines the trigger options
  102089. * @param sound defines the sound to play
  102090. * @param condition defines the trigger related conditions
  102091. */
  102092. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102093. /** @hidden */
  102094. _prepare(): void;
  102095. /**
  102096. * Execute the action and play the sound.
  102097. */
  102098. execute(): void;
  102099. /**
  102100. * Serializes the actions and its related information.
  102101. * @param parent defines the object to serialize in
  102102. * @returns the serialized object
  102103. */
  102104. serialize(parent: any): any;
  102105. }
  102106. /**
  102107. * This defines an action helpful to stop a defined sound on a triggered action.
  102108. */
  102109. export class StopSoundAction extends Action {
  102110. private _sound;
  102111. /**
  102112. * Instantiate the action
  102113. * @param triggerOptions defines the trigger options
  102114. * @param sound defines the sound to stop
  102115. * @param condition defines the trigger related conditions
  102116. */
  102117. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102118. /** @hidden */
  102119. _prepare(): void;
  102120. /**
  102121. * Execute the action and stop the sound.
  102122. */
  102123. execute(): void;
  102124. /**
  102125. * Serializes the actions and its related information.
  102126. * @param parent defines the object to serialize in
  102127. * @returns the serialized object
  102128. */
  102129. serialize(parent: any): any;
  102130. }
  102131. }
  102132. declare module BABYLON {
  102133. /**
  102134. * This defines an action responsible to change the value of a property
  102135. * by interpolating between its current value and the newly set one once triggered.
  102136. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102137. */
  102138. export class InterpolateValueAction extends Action {
  102139. /**
  102140. * Defines the path of the property where the value should be interpolated
  102141. */
  102142. propertyPath: string;
  102143. /**
  102144. * Defines the target value at the end of the interpolation.
  102145. */
  102146. value: any;
  102147. /**
  102148. * Defines the time it will take for the property to interpolate to the value.
  102149. */
  102150. duration: number;
  102151. /**
  102152. * Defines if the other scene animations should be stopped when the action has been triggered
  102153. */
  102154. stopOtherAnimations?: boolean;
  102155. /**
  102156. * Defines a callback raised once the interpolation animation has been done.
  102157. */
  102158. onInterpolationDone?: () => void;
  102159. /**
  102160. * Observable triggered once the interpolation animation has been done.
  102161. */
  102162. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102163. private _target;
  102164. private _effectiveTarget;
  102165. private _property;
  102166. /**
  102167. * Instantiate the action
  102168. * @param triggerOptions defines the trigger options
  102169. * @param target defines the object containing the value to interpolate
  102170. * @param propertyPath defines the path to the property in the target object
  102171. * @param value defines the target value at the end of the interpolation
  102172. * @param duration deines the time it will take for the property to interpolate to the value.
  102173. * @param condition defines the trigger related conditions
  102174. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102175. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102176. */
  102177. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102178. /** @hidden */
  102179. _prepare(): void;
  102180. /**
  102181. * Execute the action starts the value interpolation.
  102182. */
  102183. execute(): void;
  102184. /**
  102185. * Serializes the actions and its related information.
  102186. * @param parent defines the object to serialize in
  102187. * @returns the serialized object
  102188. */
  102189. serialize(parent: any): any;
  102190. }
  102191. }
  102192. declare module BABYLON {
  102193. /**
  102194. * Options allowed during the creation of a sound track.
  102195. */
  102196. export interface ISoundTrackOptions {
  102197. /**
  102198. * The volume the sound track should take during creation
  102199. */
  102200. volume?: number;
  102201. /**
  102202. * Define if the sound track is the main sound track of the scene
  102203. */
  102204. mainTrack?: boolean;
  102205. }
  102206. /**
  102207. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102208. * It will be also used in a future release to apply effects on a specific track.
  102209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102210. */
  102211. export class SoundTrack {
  102212. /**
  102213. * The unique identifier of the sound track in the scene.
  102214. */
  102215. id: number;
  102216. /**
  102217. * The list of sounds included in the sound track.
  102218. */
  102219. soundCollection: Array<Sound>;
  102220. private _outputAudioNode;
  102221. private _scene;
  102222. private _isMainTrack;
  102223. private _connectedAnalyser;
  102224. private _options;
  102225. private _isInitialized;
  102226. /**
  102227. * Creates a new sound track.
  102228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102229. * @param scene Define the scene the sound track belongs to
  102230. * @param options
  102231. */
  102232. constructor(scene: Scene, options?: ISoundTrackOptions);
  102233. private _initializeSoundTrackAudioGraph;
  102234. /**
  102235. * Release the sound track and its associated resources
  102236. */
  102237. dispose(): void;
  102238. /**
  102239. * Adds a sound to this sound track
  102240. * @param sound define the cound to add
  102241. * @ignoreNaming
  102242. */
  102243. AddSound(sound: Sound): void;
  102244. /**
  102245. * Removes a sound to this sound track
  102246. * @param sound define the cound to remove
  102247. * @ignoreNaming
  102248. */
  102249. RemoveSound(sound: Sound): void;
  102250. /**
  102251. * Set a global volume for the full sound track.
  102252. * @param newVolume Define the new volume of the sound track
  102253. */
  102254. setVolume(newVolume: number): void;
  102255. /**
  102256. * Switch the panning model to HRTF:
  102257. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102259. */
  102260. switchPanningModelToHRTF(): void;
  102261. /**
  102262. * Switch the panning model to Equal Power:
  102263. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102265. */
  102266. switchPanningModelToEqualPower(): void;
  102267. /**
  102268. * Connect the sound track to an audio analyser allowing some amazing
  102269. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102271. * @param analyser The analyser to connect to the engine
  102272. */
  102273. connectToAnalyser(analyser: Analyser): void;
  102274. }
  102275. }
  102276. declare module BABYLON {
  102277. interface AbstractScene {
  102278. /**
  102279. * The list of sounds used in the scene.
  102280. */
  102281. sounds: Nullable<Array<Sound>>;
  102282. }
  102283. interface Scene {
  102284. /**
  102285. * @hidden
  102286. * Backing field
  102287. */
  102288. _mainSoundTrack: SoundTrack;
  102289. /**
  102290. * The main sound track played by the scene.
  102291. * It cotains your primary collection of sounds.
  102292. */
  102293. mainSoundTrack: SoundTrack;
  102294. /**
  102295. * The list of sound tracks added to the scene
  102296. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102297. */
  102298. soundTracks: Nullable<Array<SoundTrack>>;
  102299. /**
  102300. * Gets a sound using a given name
  102301. * @param name defines the name to search for
  102302. * @return the found sound or null if not found at all.
  102303. */
  102304. getSoundByName(name: string): Nullable<Sound>;
  102305. /**
  102306. * Gets or sets if audio support is enabled
  102307. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102308. */
  102309. audioEnabled: boolean;
  102310. /**
  102311. * Gets or sets if audio will be output to headphones
  102312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102313. */
  102314. headphone: boolean;
  102315. /**
  102316. * Gets or sets custom audio listener position provider
  102317. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102318. */
  102319. audioListenerPositionProvider: Nullable<() => Vector3>;
  102320. }
  102321. /**
  102322. * Defines the sound scene component responsible to manage any sounds
  102323. * in a given scene.
  102324. */
  102325. export class AudioSceneComponent implements ISceneSerializableComponent {
  102326. /**
  102327. * The component name helpfull to identify the component in the list of scene components.
  102328. */
  102329. readonly name: string;
  102330. /**
  102331. * The scene the component belongs to.
  102332. */
  102333. scene: Scene;
  102334. private _audioEnabled;
  102335. /**
  102336. * Gets whether audio is enabled or not.
  102337. * Please use related enable/disable method to switch state.
  102338. */
  102339. readonly audioEnabled: boolean;
  102340. private _headphone;
  102341. /**
  102342. * Gets whether audio is outputing to headphone or not.
  102343. * Please use the according Switch methods to change output.
  102344. */
  102345. readonly headphone: boolean;
  102346. private _audioListenerPositionProvider;
  102347. /**
  102348. * Gets the current audio listener position provider
  102349. */
  102350. /**
  102351. * Sets a custom listener position for all sounds in the scene
  102352. * By default, this is the position of the first active camera
  102353. */
  102354. audioListenerPositionProvider: Nullable<() => Vector3>;
  102355. /**
  102356. * Creates a new instance of the component for the given scene
  102357. * @param scene Defines the scene to register the component in
  102358. */
  102359. constructor(scene: Scene);
  102360. /**
  102361. * Registers the component in a given scene
  102362. */
  102363. register(): void;
  102364. /**
  102365. * Rebuilds the elements related to this component in case of
  102366. * context lost for instance.
  102367. */
  102368. rebuild(): void;
  102369. /**
  102370. * Serializes the component data to the specified json object
  102371. * @param serializationObject The object to serialize to
  102372. */
  102373. serialize(serializationObject: any): void;
  102374. /**
  102375. * Adds all the elements from the container to the scene
  102376. * @param container the container holding the elements
  102377. */
  102378. addFromContainer(container: AbstractScene): void;
  102379. /**
  102380. * Removes all the elements in the container from the scene
  102381. * @param container contains the elements to remove
  102382. * @param dispose if the removed element should be disposed (default: false)
  102383. */
  102384. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  102385. /**
  102386. * Disposes the component and the associated ressources.
  102387. */
  102388. dispose(): void;
  102389. /**
  102390. * Disables audio in the associated scene.
  102391. */
  102392. disableAudio(): void;
  102393. /**
  102394. * Enables audio in the associated scene.
  102395. */
  102396. enableAudio(): void;
  102397. /**
  102398. * Switch audio to headphone output.
  102399. */
  102400. switchAudioModeForHeadphones(): void;
  102401. /**
  102402. * Switch audio to normal speakers.
  102403. */
  102404. switchAudioModeForNormalSpeakers(): void;
  102405. private _afterRender;
  102406. }
  102407. }
  102408. declare module BABYLON {
  102409. /**
  102410. * Wraps one or more Sound objects and selects one with random weight for playback.
  102411. */
  102412. export class WeightedSound {
  102413. /** When true a Sound will be selected and played when the current playing Sound completes. */
  102414. loop: boolean;
  102415. private _coneInnerAngle;
  102416. private _coneOuterAngle;
  102417. private _volume;
  102418. /** A Sound is currently playing. */
  102419. isPlaying: boolean;
  102420. /** A Sound is currently paused. */
  102421. isPaused: boolean;
  102422. private _sounds;
  102423. private _weights;
  102424. private _currentIndex?;
  102425. /**
  102426. * Creates a new WeightedSound from the list of sounds given.
  102427. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  102428. * @param sounds Array of Sounds that will be selected from.
  102429. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  102430. */
  102431. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  102432. /**
  102433. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  102434. */
  102435. /**
  102436. * The size of cone in degress for a directional sound in which there will be no attenuation.
  102437. */
  102438. directionalConeInnerAngle: number;
  102439. /**
  102440. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102441. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102442. */
  102443. /**
  102444. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102445. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102446. */
  102447. directionalConeOuterAngle: number;
  102448. /**
  102449. * Playback volume.
  102450. */
  102451. /**
  102452. * Playback volume.
  102453. */
  102454. volume: number;
  102455. private _onended;
  102456. /**
  102457. * Suspend playback
  102458. */
  102459. pause(): void;
  102460. /**
  102461. * Stop playback
  102462. */
  102463. stop(): void;
  102464. /**
  102465. * Start playback.
  102466. * @param startOffset Position the clip head at a specific time in seconds.
  102467. */
  102468. play(startOffset?: number): void;
  102469. }
  102470. }
  102471. declare module BABYLON {
  102472. /**
  102473. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  102474. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102475. */
  102476. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  102477. /**
  102478. * Gets the name of the behavior.
  102479. */
  102480. readonly name: string;
  102481. /**
  102482. * The easing function used by animations
  102483. */
  102484. static EasingFunction: BackEase;
  102485. /**
  102486. * The easing mode used by animations
  102487. */
  102488. static EasingMode: number;
  102489. /**
  102490. * The duration of the animation, in milliseconds
  102491. */
  102492. transitionDuration: number;
  102493. /**
  102494. * Length of the distance animated by the transition when lower radius is reached
  102495. */
  102496. lowerRadiusTransitionRange: number;
  102497. /**
  102498. * Length of the distance animated by the transition when upper radius is reached
  102499. */
  102500. upperRadiusTransitionRange: number;
  102501. private _autoTransitionRange;
  102502. /**
  102503. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102504. */
  102505. /**
  102506. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102507. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  102508. */
  102509. autoTransitionRange: boolean;
  102510. private _attachedCamera;
  102511. private _onAfterCheckInputsObserver;
  102512. private _onMeshTargetChangedObserver;
  102513. /**
  102514. * Initializes the behavior.
  102515. */
  102516. init(): void;
  102517. /**
  102518. * Attaches the behavior to its arc rotate camera.
  102519. * @param camera Defines the camera to attach the behavior to
  102520. */
  102521. attach(camera: ArcRotateCamera): void;
  102522. /**
  102523. * Detaches the behavior from its current arc rotate camera.
  102524. */
  102525. detach(): void;
  102526. private _radiusIsAnimating;
  102527. private _radiusBounceTransition;
  102528. private _animatables;
  102529. private _cachedWheelPrecision;
  102530. /**
  102531. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  102532. * @param radiusLimit The limit to check against.
  102533. * @return Bool to indicate if at limit.
  102534. */
  102535. private _isRadiusAtLimit;
  102536. /**
  102537. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  102538. * @param radiusDelta The delta by which to animate to. Can be negative.
  102539. */
  102540. private _applyBoundRadiusAnimation;
  102541. /**
  102542. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  102543. */
  102544. protected _clearAnimationLocks(): void;
  102545. /**
  102546. * Stops and removes all animations that have been applied to the camera
  102547. */
  102548. stopAllAnimations(): void;
  102549. }
  102550. }
  102551. declare module BABYLON {
  102552. /**
  102553. * 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.
  102554. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102555. */
  102556. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  102557. /**
  102558. * Gets the name of the behavior.
  102559. */
  102560. readonly name: string;
  102561. private _mode;
  102562. private _radiusScale;
  102563. private _positionScale;
  102564. private _defaultElevation;
  102565. private _elevationReturnTime;
  102566. private _elevationReturnWaitTime;
  102567. private _zoomStopsAnimation;
  102568. private _framingTime;
  102569. /**
  102570. * The easing function used by animations
  102571. */
  102572. static EasingFunction: ExponentialEase;
  102573. /**
  102574. * The easing mode used by animations
  102575. */
  102576. static EasingMode: number;
  102577. /**
  102578. * Sets the current mode used by the behavior
  102579. */
  102580. /**
  102581. * Gets current mode used by the behavior.
  102582. */
  102583. mode: number;
  102584. /**
  102585. * Sets the scale applied to the radius (1 by default)
  102586. */
  102587. /**
  102588. * Gets the scale applied to the radius
  102589. */
  102590. radiusScale: number;
  102591. /**
  102592. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102593. */
  102594. /**
  102595. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102596. */
  102597. positionScale: number;
  102598. /**
  102599. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102600. * behaviour is triggered, in radians.
  102601. */
  102602. /**
  102603. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102604. * behaviour is triggered, in radians.
  102605. */
  102606. defaultElevation: number;
  102607. /**
  102608. * Sets the time (in milliseconds) taken to return to the default beta position.
  102609. * Negative value indicates camera should not return to default.
  102610. */
  102611. /**
  102612. * Gets the time (in milliseconds) taken to return to the default beta position.
  102613. * Negative value indicates camera should not return to default.
  102614. */
  102615. elevationReturnTime: number;
  102616. /**
  102617. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102618. */
  102619. /**
  102620. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102621. */
  102622. elevationReturnWaitTime: number;
  102623. /**
  102624. * Sets the flag that indicates if user zooming should stop animation.
  102625. */
  102626. /**
  102627. * Gets the flag that indicates if user zooming should stop animation.
  102628. */
  102629. zoomStopsAnimation: boolean;
  102630. /**
  102631. * Sets the transition time when framing the mesh, in milliseconds
  102632. */
  102633. /**
  102634. * Gets the transition time when framing the mesh, in milliseconds
  102635. */
  102636. framingTime: number;
  102637. /**
  102638. * Define if the behavior should automatically change the configured
  102639. * camera limits and sensibilities.
  102640. */
  102641. autoCorrectCameraLimitsAndSensibility: boolean;
  102642. private _onPrePointerObservableObserver;
  102643. private _onAfterCheckInputsObserver;
  102644. private _onMeshTargetChangedObserver;
  102645. private _attachedCamera;
  102646. private _isPointerDown;
  102647. private _lastInteractionTime;
  102648. /**
  102649. * Initializes the behavior.
  102650. */
  102651. init(): void;
  102652. /**
  102653. * Attaches the behavior to its arc rotate camera.
  102654. * @param camera Defines the camera to attach the behavior to
  102655. */
  102656. attach(camera: ArcRotateCamera): void;
  102657. /**
  102658. * Detaches the behavior from its current arc rotate camera.
  102659. */
  102660. detach(): void;
  102661. private _animatables;
  102662. private _betaIsAnimating;
  102663. private _betaTransition;
  102664. private _radiusTransition;
  102665. private _vectorTransition;
  102666. /**
  102667. * Targets the given mesh and updates zoom level accordingly.
  102668. * @param mesh The mesh to target.
  102669. * @param radius Optional. If a cached radius position already exists, overrides default.
  102670. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102671. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102672. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102673. */
  102674. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102675. /**
  102676. * Targets the given mesh with its children and updates zoom level accordingly.
  102677. * @param mesh The mesh to target.
  102678. * @param radius Optional. If a cached radius position already exists, overrides default.
  102679. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102680. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102681. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102682. */
  102683. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102684. /**
  102685. * Targets the given meshes with their children and updates zoom level accordingly.
  102686. * @param meshes The mesh to target.
  102687. * @param radius Optional. If a cached radius position already exists, overrides default.
  102688. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102689. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102690. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102691. */
  102692. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102693. /**
  102694. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  102695. * @param minimumWorld Determines the smaller position of the bounding box extend
  102696. * @param maximumWorld Determines the bigger position of the bounding box extend
  102697. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102698. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102699. */
  102700. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102701. /**
  102702. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  102703. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  102704. * frustum width.
  102705. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  102706. * to fully enclose the mesh in the viewing frustum.
  102707. */
  102708. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  102709. /**
  102710. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  102711. * is automatically returned to its default position (expected to be above ground plane).
  102712. */
  102713. private _maintainCameraAboveGround;
  102714. /**
  102715. * Returns the frustum slope based on the canvas ratio and camera FOV
  102716. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  102717. */
  102718. private _getFrustumSlope;
  102719. /**
  102720. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  102721. */
  102722. private _clearAnimationLocks;
  102723. /**
  102724. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102725. */
  102726. private _applyUserInteraction;
  102727. /**
  102728. * Stops and removes all animations that have been applied to the camera
  102729. */
  102730. stopAllAnimations(): void;
  102731. /**
  102732. * Gets a value indicating if the user is moving the camera
  102733. */
  102734. readonly isUserIsMoving: boolean;
  102735. /**
  102736. * The camera can move all the way towards the mesh.
  102737. */
  102738. static IgnoreBoundsSizeMode: number;
  102739. /**
  102740. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  102741. */
  102742. static FitFrustumSidesMode: number;
  102743. }
  102744. }
  102745. declare module BABYLON {
  102746. /**
  102747. * Base class for Camera Pointer Inputs.
  102748. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  102749. * for example usage.
  102750. */
  102751. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  102752. /**
  102753. * Defines the camera the input is attached to.
  102754. */
  102755. abstract camera: Camera;
  102756. /**
  102757. * Whether keyboard modifier keys are pressed at time of last mouse event.
  102758. */
  102759. protected _altKey: boolean;
  102760. protected _ctrlKey: boolean;
  102761. protected _metaKey: boolean;
  102762. protected _shiftKey: boolean;
  102763. /**
  102764. * Which mouse buttons were pressed at time of last mouse event.
  102765. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  102766. */
  102767. protected _buttonsPressed: number;
  102768. /**
  102769. * Defines the buttons associated with the input to handle camera move.
  102770. */
  102771. buttons: number[];
  102772. /**
  102773. * Attach the input controls to a specific dom element to get the input from.
  102774. * @param element Defines the element the controls should be listened from
  102775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102776. */
  102777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102778. /**
  102779. * Detach the current controls from the specified dom element.
  102780. * @param element Defines the element to stop listening the inputs from
  102781. */
  102782. detachControl(element: Nullable<HTMLElement>): void;
  102783. /**
  102784. * Gets the class name of the current input.
  102785. * @returns the class name
  102786. */
  102787. getClassName(): string;
  102788. /**
  102789. * Get the friendly name associated with the input class.
  102790. * @returns the input friendly name
  102791. */
  102792. getSimpleName(): string;
  102793. /**
  102794. * Called on pointer POINTERDOUBLETAP event.
  102795. * Override this method to provide functionality on POINTERDOUBLETAP event.
  102796. */
  102797. protected onDoubleTap(type: string): void;
  102798. /**
  102799. * Called on pointer POINTERMOVE event if only a single touch is active.
  102800. * Override this method to provide functionality.
  102801. */
  102802. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102803. /**
  102804. * Called on pointer POINTERMOVE event if multiple touches are active.
  102805. * Override this method to provide functionality.
  102806. */
  102807. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102808. /**
  102809. * Called on JS contextmenu event.
  102810. * Override this method to provide functionality.
  102811. */
  102812. protected onContextMenu(evt: PointerEvent): void;
  102813. /**
  102814. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102815. * press.
  102816. * Override this method to provide functionality.
  102817. */
  102818. protected onButtonDown(evt: PointerEvent): void;
  102819. /**
  102820. * Called each time a new POINTERUP event occurs. Ie, for each button
  102821. * release.
  102822. * Override this method to provide functionality.
  102823. */
  102824. protected onButtonUp(evt: PointerEvent): void;
  102825. /**
  102826. * Called when window becomes inactive.
  102827. * Override this method to provide functionality.
  102828. */
  102829. protected onLostFocus(): void;
  102830. private _pointerInput;
  102831. private _observer;
  102832. private _onLostFocus;
  102833. private pointA;
  102834. private pointB;
  102835. }
  102836. }
  102837. declare module BABYLON {
  102838. /**
  102839. * Manage the pointers inputs to control an arc rotate camera.
  102840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102841. */
  102842. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  102843. /**
  102844. * Defines the camera the input is attached to.
  102845. */
  102846. camera: ArcRotateCamera;
  102847. /**
  102848. * Gets the class name of the current input.
  102849. * @returns the class name
  102850. */
  102851. getClassName(): string;
  102852. /**
  102853. * Defines the buttons associated with the input to handle camera move.
  102854. */
  102855. buttons: number[];
  102856. /**
  102857. * Defines the pointer angular sensibility along the X axis or how fast is
  102858. * the camera rotating.
  102859. */
  102860. angularSensibilityX: number;
  102861. /**
  102862. * Defines the pointer angular sensibility along the Y axis or how fast is
  102863. * the camera rotating.
  102864. */
  102865. angularSensibilityY: number;
  102866. /**
  102867. * Defines the pointer pinch precision or how fast is the camera zooming.
  102868. */
  102869. pinchPrecision: number;
  102870. /**
  102871. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102872. * from 0.
  102873. * It defines the percentage of current camera.radius to use as delta when
  102874. * pinch zoom is used.
  102875. */
  102876. pinchDeltaPercentage: number;
  102877. /**
  102878. * Defines the pointer panning sensibility or how fast is the camera moving.
  102879. */
  102880. panningSensibility: number;
  102881. /**
  102882. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  102883. */
  102884. multiTouchPanning: boolean;
  102885. /**
  102886. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  102887. * zoom (pinch) through multitouch.
  102888. */
  102889. multiTouchPanAndZoom: boolean;
  102890. /**
  102891. * Revers pinch action direction.
  102892. */
  102893. pinchInwards: boolean;
  102894. private _isPanClick;
  102895. private _twoFingerActivityCount;
  102896. private _isPinching;
  102897. /**
  102898. * Called on pointer POINTERMOVE event if only a single touch is active.
  102899. */
  102900. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102901. /**
  102902. * Called on pointer POINTERDOUBLETAP event.
  102903. */
  102904. protected onDoubleTap(type: string): void;
  102905. /**
  102906. * Called on pointer POINTERMOVE event if multiple touches are active.
  102907. */
  102908. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102909. /**
  102910. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102911. * press.
  102912. */
  102913. protected onButtonDown(evt: PointerEvent): void;
  102914. /**
  102915. * Called each time a new POINTERUP event occurs. Ie, for each button
  102916. * release.
  102917. */
  102918. protected onButtonUp(evt: PointerEvent): void;
  102919. /**
  102920. * Called when window becomes inactive.
  102921. */
  102922. protected onLostFocus(): void;
  102923. }
  102924. }
  102925. declare module BABYLON {
  102926. /**
  102927. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  102928. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102929. */
  102930. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  102931. /**
  102932. * Defines the camera the input is attached to.
  102933. */
  102934. camera: ArcRotateCamera;
  102935. /**
  102936. * Defines the list of key codes associated with the up action (increase alpha)
  102937. */
  102938. keysUp: number[];
  102939. /**
  102940. * Defines the list of key codes associated with the down action (decrease alpha)
  102941. */
  102942. keysDown: number[];
  102943. /**
  102944. * Defines the list of key codes associated with the left action (increase beta)
  102945. */
  102946. keysLeft: number[];
  102947. /**
  102948. * Defines the list of key codes associated with the right action (decrease beta)
  102949. */
  102950. keysRight: number[];
  102951. /**
  102952. * Defines the list of key codes associated with the reset action.
  102953. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  102954. */
  102955. keysReset: number[];
  102956. /**
  102957. * Defines the panning sensibility of the inputs.
  102958. * (How fast is the camera paning)
  102959. */
  102960. panningSensibility: number;
  102961. /**
  102962. * Defines the zooming sensibility of the inputs.
  102963. * (How fast is the camera zooming)
  102964. */
  102965. zoomingSensibility: number;
  102966. /**
  102967. * Defines wether maintaining the alt key down switch the movement mode from
  102968. * orientation to zoom.
  102969. */
  102970. useAltToZoom: boolean;
  102971. /**
  102972. * Rotation speed of the camera
  102973. */
  102974. angularSpeed: number;
  102975. private _keys;
  102976. private _ctrlPressed;
  102977. private _altPressed;
  102978. private _onCanvasBlurObserver;
  102979. private _onKeyboardObserver;
  102980. private _engine;
  102981. private _scene;
  102982. /**
  102983. * Attach the input controls to a specific dom element to get the input from.
  102984. * @param element Defines the element the controls should be listened from
  102985. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102986. */
  102987. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102988. /**
  102989. * Detach the current controls from the specified dom element.
  102990. * @param element Defines the element to stop listening the inputs from
  102991. */
  102992. detachControl(element: Nullable<HTMLElement>): void;
  102993. /**
  102994. * Update the current camera state depending on the inputs that have been used this frame.
  102995. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102996. */
  102997. checkInputs(): void;
  102998. /**
  102999. * Gets the class name of the current intput.
  103000. * @returns the class name
  103001. */
  103002. getClassName(): string;
  103003. /**
  103004. * Get the friendly name associated with the input class.
  103005. * @returns the input friendly name
  103006. */
  103007. getSimpleName(): string;
  103008. }
  103009. }
  103010. declare module BABYLON {
  103011. /**
  103012. * Manage the mouse wheel inputs to control an arc rotate camera.
  103013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103014. */
  103015. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  103016. /**
  103017. * Defines the camera the input is attached to.
  103018. */
  103019. camera: ArcRotateCamera;
  103020. /**
  103021. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103022. */
  103023. wheelPrecision: number;
  103024. /**
  103025. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103026. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103027. */
  103028. wheelDeltaPercentage: number;
  103029. private _wheel;
  103030. private _observer;
  103031. private computeDeltaFromMouseWheelLegacyEvent;
  103032. /**
  103033. * Attach the input controls to a specific dom element to get the input from.
  103034. * @param element Defines the element the controls should be listened from
  103035. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103036. */
  103037. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103038. /**
  103039. * Detach the current controls from the specified dom element.
  103040. * @param element Defines the element to stop listening the inputs from
  103041. */
  103042. detachControl(element: Nullable<HTMLElement>): void;
  103043. /**
  103044. * Gets the class name of the current intput.
  103045. * @returns the class name
  103046. */
  103047. getClassName(): string;
  103048. /**
  103049. * Get the friendly name associated with the input class.
  103050. * @returns the input friendly name
  103051. */
  103052. getSimpleName(): string;
  103053. }
  103054. }
  103055. declare module BABYLON {
  103056. /**
  103057. * Default Inputs manager for the ArcRotateCamera.
  103058. * It groups all the default supported inputs for ease of use.
  103059. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103060. */
  103061. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  103062. /**
  103063. * Instantiates a new ArcRotateCameraInputsManager.
  103064. * @param camera Defines the camera the inputs belong to
  103065. */
  103066. constructor(camera: ArcRotateCamera);
  103067. /**
  103068. * Add mouse wheel input support to the input manager.
  103069. * @returns the current input manager
  103070. */
  103071. addMouseWheel(): ArcRotateCameraInputsManager;
  103072. /**
  103073. * Add pointers input support to the input manager.
  103074. * @returns the current input manager
  103075. */
  103076. addPointers(): ArcRotateCameraInputsManager;
  103077. /**
  103078. * Add keyboard input support to the input manager.
  103079. * @returns the current input manager
  103080. */
  103081. addKeyboard(): ArcRotateCameraInputsManager;
  103082. }
  103083. }
  103084. declare module BABYLON {
  103085. /**
  103086. * This represents an orbital type of camera.
  103087. *
  103088. * 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.
  103089. * 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.
  103090. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  103091. */
  103092. export class ArcRotateCamera extends TargetCamera {
  103093. /**
  103094. * Defines the rotation angle of the camera along the longitudinal axis.
  103095. */
  103096. alpha: number;
  103097. /**
  103098. * Defines the rotation angle of the camera along the latitudinal axis.
  103099. */
  103100. beta: number;
  103101. /**
  103102. * Defines the radius of the camera from it s target point.
  103103. */
  103104. radius: number;
  103105. protected _target: Vector3;
  103106. protected _targetHost: Nullable<AbstractMesh>;
  103107. /**
  103108. * Defines the target point of the camera.
  103109. * The camera looks towards it form the radius distance.
  103110. */
  103111. target: Vector3;
  103112. /**
  103113. * Define the current local position of the camera in the scene
  103114. */
  103115. position: Vector3;
  103116. protected _upVector: Vector3;
  103117. protected _upToYMatrix: Matrix;
  103118. protected _YToUpMatrix: Matrix;
  103119. /**
  103120. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103121. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103122. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103123. */
  103124. upVector: Vector3;
  103125. /**
  103126. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103127. */
  103128. setMatUp(): void;
  103129. /**
  103130. * Current inertia value on the longitudinal axis.
  103131. * The bigger this number the longer it will take for the camera to stop.
  103132. */
  103133. inertialAlphaOffset: number;
  103134. /**
  103135. * Current inertia value on the latitudinal axis.
  103136. * The bigger this number the longer it will take for the camera to stop.
  103137. */
  103138. inertialBetaOffset: number;
  103139. /**
  103140. * Current inertia value on the radius axis.
  103141. * The bigger this number the longer it will take for the camera to stop.
  103142. */
  103143. inertialRadiusOffset: number;
  103144. /**
  103145. * Minimum allowed angle on the longitudinal axis.
  103146. * This can help limiting how the Camera is able to move in the scene.
  103147. */
  103148. lowerAlphaLimit: Nullable<number>;
  103149. /**
  103150. * Maximum allowed angle on the longitudinal axis.
  103151. * This can help limiting how the Camera is able to move in the scene.
  103152. */
  103153. upperAlphaLimit: Nullable<number>;
  103154. /**
  103155. * Minimum allowed angle on the latitudinal axis.
  103156. * This can help limiting how the Camera is able to move in the scene.
  103157. */
  103158. lowerBetaLimit: number;
  103159. /**
  103160. * Maximum allowed angle on the latitudinal axis.
  103161. * This can help limiting how the Camera is able to move in the scene.
  103162. */
  103163. upperBetaLimit: number;
  103164. /**
  103165. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103166. * This can help limiting how the Camera is able to move in the scene.
  103167. */
  103168. lowerRadiusLimit: Nullable<number>;
  103169. /**
  103170. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103171. * This can help limiting how the Camera is able to move in the scene.
  103172. */
  103173. upperRadiusLimit: Nullable<number>;
  103174. /**
  103175. * Defines the current inertia value used during panning of the camera along the X axis.
  103176. */
  103177. inertialPanningX: number;
  103178. /**
  103179. * Defines the current inertia value used during panning of the camera along the Y axis.
  103180. */
  103181. inertialPanningY: number;
  103182. /**
  103183. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103184. * Basically if your fingers moves away from more than this distance you will be considered
  103185. * in pinch mode.
  103186. */
  103187. pinchToPanMaxDistance: number;
  103188. /**
  103189. * Defines the maximum distance the camera can pan.
  103190. * This could help keeping the cammera always in your scene.
  103191. */
  103192. panningDistanceLimit: Nullable<number>;
  103193. /**
  103194. * Defines the target of the camera before paning.
  103195. */
  103196. panningOriginTarget: Vector3;
  103197. /**
  103198. * Defines the value of the inertia used during panning.
  103199. * 0 would mean stop inertia and one would mean no decelleration at all.
  103200. */
  103201. panningInertia: number;
  103202. /**
  103203. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103204. */
  103205. angularSensibilityX: number;
  103206. /**
  103207. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103208. */
  103209. angularSensibilityY: number;
  103210. /**
  103211. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103212. */
  103213. pinchPrecision: number;
  103214. /**
  103215. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103216. * It will be used instead of pinchDeltaPrecision if different from 0.
  103217. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103218. */
  103219. pinchDeltaPercentage: number;
  103220. /**
  103221. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103222. */
  103223. panningSensibility: number;
  103224. /**
  103225. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103226. */
  103227. keysUp: number[];
  103228. /**
  103229. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103230. */
  103231. keysDown: number[];
  103232. /**
  103233. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103234. */
  103235. keysLeft: number[];
  103236. /**
  103237. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103238. */
  103239. keysRight: number[];
  103240. /**
  103241. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103242. */
  103243. wheelPrecision: number;
  103244. /**
  103245. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103246. * It will be used instead of pinchDeltaPrecision if different from 0.
  103247. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103248. */
  103249. wheelDeltaPercentage: number;
  103250. /**
  103251. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  103252. */
  103253. zoomOnFactor: number;
  103254. /**
  103255. * Defines a screen offset for the camera position.
  103256. */
  103257. targetScreenOffset: Vector2;
  103258. /**
  103259. * Allows the camera to be completely reversed.
  103260. * If false the camera can not arrive upside down.
  103261. */
  103262. allowUpsideDown: boolean;
  103263. /**
  103264. * Define if double tap/click is used to restore the previously saved state of the camera.
  103265. */
  103266. useInputToRestoreState: boolean;
  103267. /** @hidden */
  103268. _viewMatrix: Matrix;
  103269. /** @hidden */
  103270. _useCtrlForPanning: boolean;
  103271. /** @hidden */
  103272. _panningMouseButton: number;
  103273. /**
  103274. * Defines the input associated to the camera.
  103275. */
  103276. inputs: ArcRotateCameraInputsManager;
  103277. /** @hidden */
  103278. _reset: () => void;
  103279. /**
  103280. * Defines the allowed panning axis.
  103281. */
  103282. panningAxis: Vector3;
  103283. protected _localDirection: Vector3;
  103284. protected _transformedDirection: Vector3;
  103285. private _bouncingBehavior;
  103286. /**
  103287. * Gets the bouncing behavior of the camera if it has been enabled.
  103288. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103289. */
  103290. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  103291. /**
  103292. * Defines if the bouncing behavior of the camera is enabled on the camera.
  103293. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103294. */
  103295. useBouncingBehavior: boolean;
  103296. private _framingBehavior;
  103297. /**
  103298. * Gets the framing behavior of the camera if it has been enabled.
  103299. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103300. */
  103301. readonly framingBehavior: Nullable<FramingBehavior>;
  103302. /**
  103303. * Defines if the framing behavior of the camera is enabled on the camera.
  103304. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103305. */
  103306. useFramingBehavior: boolean;
  103307. private _autoRotationBehavior;
  103308. /**
  103309. * Gets the auto rotation behavior of the camera if it has been enabled.
  103310. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103311. */
  103312. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  103313. /**
  103314. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  103315. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103316. */
  103317. useAutoRotationBehavior: boolean;
  103318. /**
  103319. * Observable triggered when the mesh target has been changed on the camera.
  103320. */
  103321. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  103322. /**
  103323. * Event raised when the camera is colliding with a mesh.
  103324. */
  103325. onCollide: (collidedMesh: AbstractMesh) => void;
  103326. /**
  103327. * Defines whether the camera should check collision with the objects oh the scene.
  103328. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  103329. */
  103330. checkCollisions: boolean;
  103331. /**
  103332. * Defines the collision radius of the camera.
  103333. * This simulates a sphere around the camera.
  103334. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103335. */
  103336. collisionRadius: Vector3;
  103337. protected _collider: Collider;
  103338. protected _previousPosition: Vector3;
  103339. protected _collisionVelocity: Vector3;
  103340. protected _newPosition: Vector3;
  103341. protected _previousAlpha: number;
  103342. protected _previousBeta: number;
  103343. protected _previousRadius: number;
  103344. protected _collisionTriggered: boolean;
  103345. protected _targetBoundingCenter: Nullable<Vector3>;
  103346. private _computationVector;
  103347. /**
  103348. * Instantiates a new ArcRotateCamera in a given scene
  103349. * @param name Defines the name of the camera
  103350. * @param alpha Defines the camera rotation along the logitudinal axis
  103351. * @param beta Defines the camera rotation along the latitudinal axis
  103352. * @param radius Defines the camera distance from its target
  103353. * @param target Defines the camera target
  103354. * @param scene Defines the scene the camera belongs to
  103355. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  103356. */
  103357. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103358. /** @hidden */
  103359. _initCache(): void;
  103360. /** @hidden */
  103361. _updateCache(ignoreParentClass?: boolean): void;
  103362. protected _getTargetPosition(): Vector3;
  103363. private _storedAlpha;
  103364. private _storedBeta;
  103365. private _storedRadius;
  103366. private _storedTarget;
  103367. private _storedTargetScreenOffset;
  103368. /**
  103369. * Stores the current state of the camera (alpha, beta, radius and target)
  103370. * @returns the camera itself
  103371. */
  103372. storeState(): Camera;
  103373. /**
  103374. * @hidden
  103375. * Restored camera state. You must call storeState() first
  103376. */
  103377. _restoreStateValues(): boolean;
  103378. /** @hidden */
  103379. _isSynchronizedViewMatrix(): boolean;
  103380. /**
  103381. * Attached controls to the current camera.
  103382. * @param element Defines the element the controls should be listened from
  103383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103384. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  103385. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  103386. */
  103387. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  103388. /**
  103389. * Detach the current controls from the camera.
  103390. * The camera will stop reacting to inputs.
  103391. * @param element Defines the element to stop listening the inputs from
  103392. */
  103393. detachControl(element: HTMLElement): void;
  103394. /** @hidden */
  103395. _checkInputs(): void;
  103396. protected _checkLimits(): void;
  103397. /**
  103398. * Rebuilds angles (alpha, beta) and radius from the give position and target
  103399. */
  103400. rebuildAnglesAndRadius(): void;
  103401. /**
  103402. * Use a position to define the current camera related information like alpha, beta and radius
  103403. * @param position Defines the position to set the camera at
  103404. */
  103405. setPosition(position: Vector3): void;
  103406. /**
  103407. * Defines the target the camera should look at.
  103408. * This will automatically adapt alpha beta and radius to fit within the new target.
  103409. * @param target Defines the new target as a Vector or a mesh
  103410. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  103411. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  103412. */
  103413. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  103414. /** @hidden */
  103415. _getViewMatrix(): Matrix;
  103416. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  103417. /**
  103418. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  103419. * @param meshes Defines the mesh to zoom on
  103420. * @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)
  103421. */
  103422. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  103423. /**
  103424. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  103425. * The target will be changed but the radius
  103426. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  103427. * @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)
  103428. */
  103429. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  103430. min: Vector3;
  103431. max: Vector3;
  103432. distance: number;
  103433. }, doNotUpdateMaxZ?: boolean): void;
  103434. /**
  103435. * @override
  103436. * Override Camera.createRigCamera
  103437. */
  103438. createRigCamera(name: string, cameraIndex: number): Camera;
  103439. /**
  103440. * @hidden
  103441. * @override
  103442. * Override Camera._updateRigCameras
  103443. */
  103444. _updateRigCameras(): void;
  103445. /**
  103446. * Destroy the camera and release the current resources hold by it.
  103447. */
  103448. dispose(): void;
  103449. /**
  103450. * Gets the current object class name.
  103451. * @return the class name
  103452. */
  103453. getClassName(): string;
  103454. }
  103455. }
  103456. declare module BABYLON {
  103457. /**
  103458. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  103459. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103460. */
  103461. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  103462. /**
  103463. * Gets the name of the behavior.
  103464. */
  103465. readonly name: string;
  103466. private _zoomStopsAnimation;
  103467. private _idleRotationSpeed;
  103468. private _idleRotationWaitTime;
  103469. private _idleRotationSpinupTime;
  103470. /**
  103471. * Sets the flag that indicates if user zooming should stop animation.
  103472. */
  103473. /**
  103474. * Gets the flag that indicates if user zooming should stop animation.
  103475. */
  103476. zoomStopsAnimation: boolean;
  103477. /**
  103478. * Sets the default speed at which the camera rotates around the model.
  103479. */
  103480. /**
  103481. * Gets the default speed at which the camera rotates around the model.
  103482. */
  103483. idleRotationSpeed: number;
  103484. /**
  103485. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  103486. */
  103487. /**
  103488. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  103489. */
  103490. idleRotationWaitTime: number;
  103491. /**
  103492. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103493. */
  103494. /**
  103495. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103496. */
  103497. idleRotationSpinupTime: number;
  103498. /**
  103499. * Gets a value indicating if the camera is currently rotating because of this behavior
  103500. */
  103501. readonly rotationInProgress: boolean;
  103502. private _onPrePointerObservableObserver;
  103503. private _onAfterCheckInputsObserver;
  103504. private _attachedCamera;
  103505. private _isPointerDown;
  103506. private _lastFrameTime;
  103507. private _lastInteractionTime;
  103508. private _cameraRotationSpeed;
  103509. /**
  103510. * Initializes the behavior.
  103511. */
  103512. init(): void;
  103513. /**
  103514. * Attaches the behavior to its arc rotate camera.
  103515. * @param camera Defines the camera to attach the behavior to
  103516. */
  103517. attach(camera: ArcRotateCamera): void;
  103518. /**
  103519. * Detaches the behavior from its current arc rotate camera.
  103520. */
  103521. detach(): void;
  103522. /**
  103523. * Returns true if user is scrolling.
  103524. * @return true if user is scrolling.
  103525. */
  103526. private _userIsZooming;
  103527. private _lastFrameRadius;
  103528. private _shouldAnimationStopForInteraction;
  103529. /**
  103530. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103531. */
  103532. private _applyUserInteraction;
  103533. private _userIsMoving;
  103534. }
  103535. }
  103536. declare module BABYLON {
  103537. /**
  103538. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  103539. */
  103540. export class AttachToBoxBehavior implements Behavior<Mesh> {
  103541. private ui;
  103542. /**
  103543. * The name of the behavior
  103544. */
  103545. name: string;
  103546. /**
  103547. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  103548. */
  103549. distanceAwayFromFace: number;
  103550. /**
  103551. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  103552. */
  103553. distanceAwayFromBottomOfFace: number;
  103554. private _faceVectors;
  103555. private _target;
  103556. private _scene;
  103557. private _onRenderObserver;
  103558. private _tmpMatrix;
  103559. private _tmpVector;
  103560. /**
  103561. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  103562. * @param ui The transform node that should be attched to the mesh
  103563. */
  103564. constructor(ui: TransformNode);
  103565. /**
  103566. * Initializes the behavior
  103567. */
  103568. init(): void;
  103569. private _closestFace;
  103570. private _zeroVector;
  103571. private _lookAtTmpMatrix;
  103572. private _lookAtToRef;
  103573. /**
  103574. * Attaches the AttachToBoxBehavior to the passed in mesh
  103575. * @param target The mesh that the specified node will be attached to
  103576. */
  103577. attach(target: Mesh): void;
  103578. /**
  103579. * Detaches the behavior from the mesh
  103580. */
  103581. detach(): void;
  103582. }
  103583. }
  103584. declare module BABYLON {
  103585. /**
  103586. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  103587. */
  103588. export class FadeInOutBehavior implements Behavior<Mesh> {
  103589. /**
  103590. * Time in milliseconds to delay before fading in (Default: 0)
  103591. */
  103592. delay: number;
  103593. /**
  103594. * Time in milliseconds for the mesh to fade in (Default: 300)
  103595. */
  103596. fadeInTime: number;
  103597. private _millisecondsPerFrame;
  103598. private _hovered;
  103599. private _hoverValue;
  103600. private _ownerNode;
  103601. /**
  103602. * Instatiates the FadeInOutBehavior
  103603. */
  103604. constructor();
  103605. /**
  103606. * The name of the behavior
  103607. */
  103608. readonly name: string;
  103609. /**
  103610. * Initializes the behavior
  103611. */
  103612. init(): void;
  103613. /**
  103614. * Attaches the fade behavior on the passed in mesh
  103615. * @param ownerNode The mesh that will be faded in/out once attached
  103616. */
  103617. attach(ownerNode: Mesh): void;
  103618. /**
  103619. * Detaches the behavior from the mesh
  103620. */
  103621. detach(): void;
  103622. /**
  103623. * Triggers the mesh to begin fading in or out
  103624. * @param value if the object should fade in or out (true to fade in)
  103625. */
  103626. fadeIn(value: boolean): void;
  103627. private _update;
  103628. private _setAllVisibility;
  103629. }
  103630. }
  103631. declare module BABYLON {
  103632. /**
  103633. * Class containing a set of static utilities functions for managing Pivots
  103634. * @hidden
  103635. */
  103636. export class PivotTools {
  103637. private static _PivotCached;
  103638. private static _OldPivotPoint;
  103639. private static _PivotTranslation;
  103640. private static _PivotTmpVector;
  103641. /** @hidden */
  103642. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  103643. /** @hidden */
  103644. static _RestorePivotPoint(mesh: AbstractMesh): void;
  103645. }
  103646. }
  103647. declare module BABYLON {
  103648. /**
  103649. * Class containing static functions to help procedurally build meshes
  103650. */
  103651. export class PlaneBuilder {
  103652. /**
  103653. * Creates a plane mesh
  103654. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103655. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103656. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103658. * * 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
  103659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103660. * @param name defines the name of the mesh
  103661. * @param options defines the options used to create the mesh
  103662. * @param scene defines the hosting scene
  103663. * @returns the plane mesh
  103664. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103665. */
  103666. static CreatePlane(name: string, options: {
  103667. size?: number;
  103668. width?: number;
  103669. height?: number;
  103670. sideOrientation?: number;
  103671. frontUVs?: Vector4;
  103672. backUVs?: Vector4;
  103673. updatable?: boolean;
  103674. sourcePlane?: Plane;
  103675. }, scene?: Nullable<Scene>): Mesh;
  103676. }
  103677. }
  103678. declare module BABYLON {
  103679. /**
  103680. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  103681. */
  103682. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  103683. private static _AnyMouseID;
  103684. /**
  103685. * Abstract mesh the behavior is set on
  103686. */
  103687. attachedNode: AbstractMesh;
  103688. private _dragPlane;
  103689. private _scene;
  103690. private _pointerObserver;
  103691. private _beforeRenderObserver;
  103692. private static _planeScene;
  103693. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  103694. /**
  103695. * 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)
  103696. */
  103697. maxDragAngle: number;
  103698. /**
  103699. * @hidden
  103700. */
  103701. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  103702. /**
  103703. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103704. */
  103705. currentDraggingPointerID: number;
  103706. /**
  103707. * The last position where the pointer hit the drag plane in world space
  103708. */
  103709. lastDragPosition: Vector3;
  103710. /**
  103711. * If the behavior is currently in a dragging state
  103712. */
  103713. dragging: boolean;
  103714. /**
  103715. * 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)
  103716. */
  103717. dragDeltaRatio: number;
  103718. /**
  103719. * If the drag plane orientation should be updated during the dragging (Default: true)
  103720. */
  103721. updateDragPlane: boolean;
  103722. private _debugMode;
  103723. private _moving;
  103724. /**
  103725. * Fires each time the attached mesh is dragged with the pointer
  103726. * * delta between last drag position and current drag position in world space
  103727. * * dragDistance along the drag axis
  103728. * * dragPlaneNormal normal of the current drag plane used during the drag
  103729. * * dragPlanePoint in world space where the drag intersects the drag plane
  103730. */
  103731. onDragObservable: Observable<{
  103732. delta: Vector3;
  103733. dragPlanePoint: Vector3;
  103734. dragPlaneNormal: Vector3;
  103735. dragDistance: number;
  103736. pointerId: number;
  103737. }>;
  103738. /**
  103739. * Fires each time a drag begins (eg. mouse down on mesh)
  103740. */
  103741. onDragStartObservable: Observable<{
  103742. dragPlanePoint: Vector3;
  103743. pointerId: number;
  103744. }>;
  103745. /**
  103746. * Fires each time a drag ends (eg. mouse release after drag)
  103747. */
  103748. onDragEndObservable: Observable<{
  103749. dragPlanePoint: Vector3;
  103750. pointerId: number;
  103751. }>;
  103752. /**
  103753. * If the attached mesh should be moved when dragged
  103754. */
  103755. moveAttached: boolean;
  103756. /**
  103757. * If the drag behavior will react to drag events (Default: true)
  103758. */
  103759. enabled: boolean;
  103760. /**
  103761. * If pointer events should start and release the drag (Default: true)
  103762. */
  103763. startAndReleaseDragOnPointerEvents: boolean;
  103764. /**
  103765. * If camera controls should be detached during the drag
  103766. */
  103767. detachCameraControls: boolean;
  103768. /**
  103769. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  103770. */
  103771. useObjectOrienationForDragging: boolean;
  103772. private _options;
  103773. /**
  103774. * Creates a pointer drag behavior that can be attached to a mesh
  103775. * @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)
  103776. */
  103777. constructor(options?: {
  103778. dragAxis?: Vector3;
  103779. dragPlaneNormal?: Vector3;
  103780. });
  103781. /**
  103782. * Predicate to determine if it is valid to move the object to a new position when it is moved
  103783. */
  103784. validateDrag: (targetPosition: Vector3) => boolean;
  103785. /**
  103786. * The name of the behavior
  103787. */
  103788. readonly name: string;
  103789. /**
  103790. * Initializes the behavior
  103791. */
  103792. init(): void;
  103793. private _tmpVector;
  103794. private _alternatePickedPoint;
  103795. private _worldDragAxis;
  103796. private _targetPosition;
  103797. private _attachedElement;
  103798. /**
  103799. * Attaches the drag behavior the passed in mesh
  103800. * @param ownerNode The mesh that will be dragged around once attached
  103801. * @param predicate Predicate to use for pick filtering
  103802. */
  103803. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  103804. /**
  103805. * Force relase the drag action by code.
  103806. */
  103807. releaseDrag(): void;
  103808. private _startDragRay;
  103809. private _lastPointerRay;
  103810. /**
  103811. * Simulates the start of a pointer drag event on the behavior
  103812. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  103813. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  103814. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  103815. */
  103816. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  103817. private _startDrag;
  103818. private _dragDelta;
  103819. private _moveDrag;
  103820. private _pickWithRayOnDragPlane;
  103821. private _pointA;
  103822. private _pointB;
  103823. private _pointC;
  103824. private _lineA;
  103825. private _lineB;
  103826. private _localAxis;
  103827. private _lookAt;
  103828. private _updateDragPlanePosition;
  103829. /**
  103830. * Detaches the behavior from the mesh
  103831. */
  103832. detach(): void;
  103833. }
  103834. }
  103835. declare module BABYLON {
  103836. /**
  103837. * A behavior that when attached to a mesh will allow the mesh to be scaled
  103838. */
  103839. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  103840. private _dragBehaviorA;
  103841. private _dragBehaviorB;
  103842. private _startDistance;
  103843. private _initialScale;
  103844. private _targetScale;
  103845. private _ownerNode;
  103846. private _sceneRenderObserver;
  103847. /**
  103848. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  103849. */
  103850. constructor();
  103851. /**
  103852. * The name of the behavior
  103853. */
  103854. readonly name: string;
  103855. /**
  103856. * Initializes the behavior
  103857. */
  103858. init(): void;
  103859. private _getCurrentDistance;
  103860. /**
  103861. * Attaches the scale behavior the passed in mesh
  103862. * @param ownerNode The mesh that will be scaled around once attached
  103863. */
  103864. attach(ownerNode: Mesh): void;
  103865. /**
  103866. * Detaches the behavior from the mesh
  103867. */
  103868. detach(): void;
  103869. }
  103870. }
  103871. declare module BABYLON {
  103872. /**
  103873. * 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
  103874. */
  103875. export class SixDofDragBehavior implements Behavior<Mesh> {
  103876. private static _virtualScene;
  103877. private _ownerNode;
  103878. private _sceneRenderObserver;
  103879. private _scene;
  103880. private _targetPosition;
  103881. private _virtualOriginMesh;
  103882. private _virtualDragMesh;
  103883. private _pointerObserver;
  103884. private _moving;
  103885. private _startingOrientation;
  103886. /**
  103887. * 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)
  103888. */
  103889. private zDragFactor;
  103890. /**
  103891. * If the object should rotate to face the drag origin
  103892. */
  103893. rotateDraggedObject: boolean;
  103894. /**
  103895. * If the behavior is currently in a dragging state
  103896. */
  103897. dragging: boolean;
  103898. /**
  103899. * 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)
  103900. */
  103901. dragDeltaRatio: number;
  103902. /**
  103903. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103904. */
  103905. currentDraggingPointerID: number;
  103906. /**
  103907. * If camera controls should be detached during the drag
  103908. */
  103909. detachCameraControls: boolean;
  103910. /**
  103911. * Fires each time a drag starts
  103912. */
  103913. onDragStartObservable: Observable<{}>;
  103914. /**
  103915. * Fires each time a drag ends (eg. mouse release after drag)
  103916. */
  103917. onDragEndObservable: Observable<{}>;
  103918. /**
  103919. * 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
  103920. */
  103921. constructor();
  103922. /**
  103923. * The name of the behavior
  103924. */
  103925. readonly name: string;
  103926. /**
  103927. * Initializes the behavior
  103928. */
  103929. init(): void;
  103930. /**
  103931. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  103932. */
  103933. private readonly _pointerCamera;
  103934. /**
  103935. * Attaches the scale behavior the passed in mesh
  103936. * @param ownerNode The mesh that will be scaled around once attached
  103937. */
  103938. attach(ownerNode: Mesh): void;
  103939. /**
  103940. * Detaches the behavior from the mesh
  103941. */
  103942. detach(): void;
  103943. }
  103944. }
  103945. declare module BABYLON {
  103946. /**
  103947. * Class used to apply inverse kinematics to bones
  103948. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  103949. */
  103950. export class BoneIKController {
  103951. private static _tmpVecs;
  103952. private static _tmpQuat;
  103953. private static _tmpMats;
  103954. /**
  103955. * Gets or sets the target mesh
  103956. */
  103957. targetMesh: AbstractMesh;
  103958. /** Gets or sets the mesh used as pole */
  103959. poleTargetMesh: AbstractMesh;
  103960. /**
  103961. * Gets or sets the bone used as pole
  103962. */
  103963. poleTargetBone: Nullable<Bone>;
  103964. /**
  103965. * Gets or sets the target position
  103966. */
  103967. targetPosition: Vector3;
  103968. /**
  103969. * Gets or sets the pole target position
  103970. */
  103971. poleTargetPosition: Vector3;
  103972. /**
  103973. * Gets or sets the pole target local offset
  103974. */
  103975. poleTargetLocalOffset: Vector3;
  103976. /**
  103977. * Gets or sets the pole angle
  103978. */
  103979. poleAngle: number;
  103980. /**
  103981. * Gets or sets the mesh associated with the controller
  103982. */
  103983. mesh: AbstractMesh;
  103984. /**
  103985. * 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)
  103986. */
  103987. slerpAmount: number;
  103988. private _bone1Quat;
  103989. private _bone1Mat;
  103990. private _bone2Ang;
  103991. private _bone1;
  103992. private _bone2;
  103993. private _bone1Length;
  103994. private _bone2Length;
  103995. private _maxAngle;
  103996. private _maxReach;
  103997. private _rightHandedSystem;
  103998. private _bendAxis;
  103999. private _slerping;
  104000. private _adjustRoll;
  104001. /**
  104002. * Gets or sets maximum allowed angle
  104003. */
  104004. maxAngle: number;
  104005. /**
  104006. * Creates a new BoneIKController
  104007. * @param mesh defines the mesh to control
  104008. * @param bone defines the bone to control
  104009. * @param options defines options to set up the controller
  104010. */
  104011. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  104012. targetMesh?: AbstractMesh;
  104013. poleTargetMesh?: AbstractMesh;
  104014. poleTargetBone?: Bone;
  104015. poleTargetLocalOffset?: Vector3;
  104016. poleAngle?: number;
  104017. bendAxis?: Vector3;
  104018. maxAngle?: number;
  104019. slerpAmount?: number;
  104020. });
  104021. private _setMaxAngle;
  104022. /**
  104023. * Force the controller to update the bones
  104024. */
  104025. update(): void;
  104026. }
  104027. }
  104028. declare module BABYLON {
  104029. /**
  104030. * Class used to make a bone look toward a point in space
  104031. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  104032. */
  104033. export class BoneLookController {
  104034. private static _tmpVecs;
  104035. private static _tmpQuat;
  104036. private static _tmpMats;
  104037. /**
  104038. * The target Vector3 that the bone will look at
  104039. */
  104040. target: Vector3;
  104041. /**
  104042. * The mesh that the bone is attached to
  104043. */
  104044. mesh: AbstractMesh;
  104045. /**
  104046. * The bone that will be looking to the target
  104047. */
  104048. bone: Bone;
  104049. /**
  104050. * The up axis of the coordinate system that is used when the bone is rotated
  104051. */
  104052. upAxis: Vector3;
  104053. /**
  104054. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  104055. */
  104056. upAxisSpace: Space;
  104057. /**
  104058. * Used to make an adjustment to the yaw of the bone
  104059. */
  104060. adjustYaw: number;
  104061. /**
  104062. * Used to make an adjustment to the pitch of the bone
  104063. */
  104064. adjustPitch: number;
  104065. /**
  104066. * Used to make an adjustment to the roll of the bone
  104067. */
  104068. adjustRoll: number;
  104069. /**
  104070. * 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)
  104071. */
  104072. slerpAmount: number;
  104073. private _minYaw;
  104074. private _maxYaw;
  104075. private _minPitch;
  104076. private _maxPitch;
  104077. private _minYawSin;
  104078. private _minYawCos;
  104079. private _maxYawSin;
  104080. private _maxYawCos;
  104081. private _midYawConstraint;
  104082. private _minPitchTan;
  104083. private _maxPitchTan;
  104084. private _boneQuat;
  104085. private _slerping;
  104086. private _transformYawPitch;
  104087. private _transformYawPitchInv;
  104088. private _firstFrameSkipped;
  104089. private _yawRange;
  104090. private _fowardAxis;
  104091. /**
  104092. * Gets or sets the minimum yaw angle that the bone can look to
  104093. */
  104094. minYaw: number;
  104095. /**
  104096. * Gets or sets the maximum yaw angle that the bone can look to
  104097. */
  104098. maxYaw: number;
  104099. /**
  104100. * Gets or sets the minimum pitch angle that the bone can look to
  104101. */
  104102. minPitch: number;
  104103. /**
  104104. * Gets or sets the maximum pitch angle that the bone can look to
  104105. */
  104106. maxPitch: number;
  104107. /**
  104108. * Create a BoneLookController
  104109. * @param mesh the mesh that the bone belongs to
  104110. * @param bone the bone that will be looking to the target
  104111. * @param target the target Vector3 to look at
  104112. * @param options optional settings:
  104113. * * maxYaw: the maximum angle the bone will yaw to
  104114. * * minYaw: the minimum angle the bone will yaw to
  104115. * * maxPitch: the maximum angle the bone will pitch to
  104116. * * minPitch: the minimum angle the bone will yaw to
  104117. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  104118. * * upAxis: the up axis of the coordinate system
  104119. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104120. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104121. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104122. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104123. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104124. * * adjustRoll: used to make an adjustment to the roll of the bone
  104125. **/
  104126. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104127. maxYaw?: number;
  104128. minYaw?: number;
  104129. maxPitch?: number;
  104130. minPitch?: number;
  104131. slerpAmount?: number;
  104132. upAxis?: Vector3;
  104133. upAxisSpace?: Space;
  104134. yawAxis?: Vector3;
  104135. pitchAxis?: Vector3;
  104136. adjustYaw?: number;
  104137. adjustPitch?: number;
  104138. adjustRoll?: number;
  104139. });
  104140. /**
  104141. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104142. */
  104143. update(): void;
  104144. private _getAngleDiff;
  104145. private _getAngleBetween;
  104146. private _isAngleBetween;
  104147. }
  104148. }
  104149. declare module BABYLON {
  104150. /**
  104151. * Manage the gamepad inputs to control an arc rotate camera.
  104152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104153. */
  104154. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104155. /**
  104156. * Defines the camera the input is attached to.
  104157. */
  104158. camera: ArcRotateCamera;
  104159. /**
  104160. * Defines the gamepad the input is gathering event from.
  104161. */
  104162. gamepad: Nullable<Gamepad>;
  104163. /**
  104164. * Defines the gamepad rotation sensiblity.
  104165. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104166. */
  104167. gamepadRotationSensibility: number;
  104168. /**
  104169. * Defines the gamepad move sensiblity.
  104170. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104171. */
  104172. gamepadMoveSensibility: number;
  104173. private _yAxisScale;
  104174. /**
  104175. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  104176. */
  104177. invertYAxis: boolean;
  104178. private _onGamepadConnectedObserver;
  104179. private _onGamepadDisconnectedObserver;
  104180. /**
  104181. * Attach the input controls to a specific dom element to get the input from.
  104182. * @param element Defines the element the controls should be listened from
  104183. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104184. */
  104185. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104186. /**
  104187. * Detach the current controls from the specified dom element.
  104188. * @param element Defines the element to stop listening the inputs from
  104189. */
  104190. detachControl(element: Nullable<HTMLElement>): void;
  104191. /**
  104192. * Update the current camera state depending on the inputs that have been used this frame.
  104193. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104194. */
  104195. checkInputs(): void;
  104196. /**
  104197. * Gets the class name of the current intput.
  104198. * @returns the class name
  104199. */
  104200. getClassName(): string;
  104201. /**
  104202. * Get the friendly name associated with the input class.
  104203. * @returns the input friendly name
  104204. */
  104205. getSimpleName(): string;
  104206. }
  104207. }
  104208. declare module BABYLON {
  104209. interface ArcRotateCameraInputsManager {
  104210. /**
  104211. * Add orientation input support to the input manager.
  104212. * @returns the current input manager
  104213. */
  104214. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104215. }
  104216. /**
  104217. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104219. */
  104220. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104221. /**
  104222. * Defines the camera the input is attached to.
  104223. */
  104224. camera: ArcRotateCamera;
  104225. /**
  104226. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104227. */
  104228. alphaCorrection: number;
  104229. /**
  104230. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104231. */
  104232. gammaCorrection: number;
  104233. private _alpha;
  104234. private _gamma;
  104235. private _dirty;
  104236. private _deviceOrientationHandler;
  104237. /**
  104238. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104239. */
  104240. constructor();
  104241. /**
  104242. * Attach the input controls to a specific dom element to get the input from.
  104243. * @param element Defines the element the controls should be listened from
  104244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104245. */
  104246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104247. /** @hidden */
  104248. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  104249. /**
  104250. * Update the current camera state depending on the inputs that have been used this frame.
  104251. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104252. */
  104253. checkInputs(): void;
  104254. /**
  104255. * Detach the current controls from the specified dom element.
  104256. * @param element Defines the element to stop listening the inputs from
  104257. */
  104258. detachControl(element: Nullable<HTMLElement>): void;
  104259. /**
  104260. * Gets the class name of the current intput.
  104261. * @returns the class name
  104262. */
  104263. getClassName(): string;
  104264. /**
  104265. * Get the friendly name associated with the input class.
  104266. * @returns the input friendly name
  104267. */
  104268. getSimpleName(): string;
  104269. }
  104270. }
  104271. declare module BABYLON {
  104272. /**
  104273. * Listen to mouse events to control the camera.
  104274. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104275. */
  104276. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  104277. /**
  104278. * Defines the camera the input is attached to.
  104279. */
  104280. camera: FlyCamera;
  104281. /**
  104282. * Defines if touch is enabled. (Default is true.)
  104283. */
  104284. touchEnabled: boolean;
  104285. /**
  104286. * Defines the buttons associated with the input to handle camera rotation.
  104287. */
  104288. buttons: number[];
  104289. /**
  104290. * Assign buttons for Yaw control.
  104291. */
  104292. buttonsYaw: number[];
  104293. /**
  104294. * Assign buttons for Pitch control.
  104295. */
  104296. buttonsPitch: number[];
  104297. /**
  104298. * Assign buttons for Roll control.
  104299. */
  104300. buttonsRoll: number[];
  104301. /**
  104302. * Detect if any button is being pressed while mouse is moved.
  104303. * -1 = Mouse locked.
  104304. * 0 = Left button.
  104305. * 1 = Middle Button.
  104306. * 2 = Right Button.
  104307. */
  104308. activeButton: number;
  104309. /**
  104310. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  104311. * Higher values reduce its sensitivity.
  104312. */
  104313. angularSensibility: number;
  104314. private _mousemoveCallback;
  104315. private _observer;
  104316. private _rollObserver;
  104317. private previousPosition;
  104318. private noPreventDefault;
  104319. private element;
  104320. /**
  104321. * Listen to mouse events to control the camera.
  104322. * @param touchEnabled Define if touch is enabled. (Default is true.)
  104323. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104324. */
  104325. constructor(touchEnabled?: boolean);
  104326. /**
  104327. * Attach the mouse control to the HTML DOM element.
  104328. * @param element Defines the element that listens to the input events.
  104329. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  104330. */
  104331. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104332. /**
  104333. * Detach the current controls from the specified dom element.
  104334. * @param element Defines the element to stop listening the inputs from
  104335. */
  104336. detachControl(element: Nullable<HTMLElement>): void;
  104337. /**
  104338. * Gets the class name of the current input.
  104339. * @returns the class name.
  104340. */
  104341. getClassName(): string;
  104342. /**
  104343. * Get the friendly name associated with the input class.
  104344. * @returns the input's friendly name.
  104345. */
  104346. getSimpleName(): string;
  104347. private _pointerInput;
  104348. private _onMouseMove;
  104349. /**
  104350. * Rotate camera by mouse offset.
  104351. */
  104352. private rotateCamera;
  104353. }
  104354. }
  104355. declare module BABYLON {
  104356. /**
  104357. * Default Inputs manager for the FlyCamera.
  104358. * It groups all the default supported inputs for ease of use.
  104359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104360. */
  104361. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  104362. /**
  104363. * Instantiates a new FlyCameraInputsManager.
  104364. * @param camera Defines the camera the inputs belong to.
  104365. */
  104366. constructor(camera: FlyCamera);
  104367. /**
  104368. * Add keyboard input support to the input manager.
  104369. * @returns the new FlyCameraKeyboardMoveInput().
  104370. */
  104371. addKeyboard(): FlyCameraInputsManager;
  104372. /**
  104373. * Add mouse input support to the input manager.
  104374. * @param touchEnabled Enable touch screen support.
  104375. * @returns the new FlyCameraMouseInput().
  104376. */
  104377. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  104378. }
  104379. }
  104380. declare module BABYLON {
  104381. /**
  104382. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104383. * such as in a 3D Space Shooter or a Flight Simulator.
  104384. */
  104385. export class FlyCamera extends TargetCamera {
  104386. /**
  104387. * Define the collision ellipsoid of the camera.
  104388. * This is helpful for simulating a camera body, like a player's body.
  104389. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104390. */
  104391. ellipsoid: Vector3;
  104392. /**
  104393. * Define an offset for the position of the ellipsoid around the camera.
  104394. * This can be helpful if the camera is attached away from the player's body center,
  104395. * such as at its head.
  104396. */
  104397. ellipsoidOffset: Vector3;
  104398. /**
  104399. * Enable or disable collisions of the camera with the rest of the scene objects.
  104400. */
  104401. checkCollisions: boolean;
  104402. /**
  104403. * Enable or disable gravity on the camera.
  104404. */
  104405. applyGravity: boolean;
  104406. /**
  104407. * Define the current direction the camera is moving to.
  104408. */
  104409. cameraDirection: Vector3;
  104410. /**
  104411. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  104412. * This overrides and empties cameraRotation.
  104413. */
  104414. rotationQuaternion: Quaternion;
  104415. /**
  104416. * Track Roll to maintain the wanted Rolling when looking around.
  104417. */
  104418. _trackRoll: number;
  104419. /**
  104420. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  104421. */
  104422. rollCorrect: number;
  104423. /**
  104424. * Mimic a banked turn, Rolling the camera when Yawing.
  104425. * It's recommended to use rollCorrect = 10 for faster banking correction.
  104426. */
  104427. bankedTurn: boolean;
  104428. /**
  104429. * Limit in radians for how much Roll banking will add. (Default: 90°)
  104430. */
  104431. bankedTurnLimit: number;
  104432. /**
  104433. * Value of 0 disables the banked Roll.
  104434. * Value of 1 is equal to the Yaw angle in radians.
  104435. */
  104436. bankedTurnMultiplier: number;
  104437. /**
  104438. * The inputs manager loads all the input sources, such as keyboard and mouse.
  104439. */
  104440. inputs: FlyCameraInputsManager;
  104441. /**
  104442. * Gets the input sensibility for mouse input.
  104443. * Higher values reduce sensitivity.
  104444. */
  104445. /**
  104446. * Sets the input sensibility for a mouse input.
  104447. * Higher values reduce sensitivity.
  104448. */
  104449. angularSensibility: number;
  104450. /**
  104451. * Get the keys for camera movement forward.
  104452. */
  104453. /**
  104454. * Set the keys for camera movement forward.
  104455. */
  104456. keysForward: number[];
  104457. /**
  104458. * Get the keys for camera movement backward.
  104459. */
  104460. keysBackward: number[];
  104461. /**
  104462. * Get the keys for camera movement up.
  104463. */
  104464. /**
  104465. * Set the keys for camera movement up.
  104466. */
  104467. keysUp: number[];
  104468. /**
  104469. * Get the keys for camera movement down.
  104470. */
  104471. /**
  104472. * Set the keys for camera movement down.
  104473. */
  104474. keysDown: number[];
  104475. /**
  104476. * Get the keys for camera movement left.
  104477. */
  104478. /**
  104479. * Set the keys for camera movement left.
  104480. */
  104481. keysLeft: number[];
  104482. /**
  104483. * Set the keys for camera movement right.
  104484. */
  104485. /**
  104486. * Set the keys for camera movement right.
  104487. */
  104488. keysRight: number[];
  104489. /**
  104490. * Event raised when the camera collides with a mesh in the scene.
  104491. */
  104492. onCollide: (collidedMesh: AbstractMesh) => void;
  104493. private _collider;
  104494. private _needMoveForGravity;
  104495. private _oldPosition;
  104496. private _diffPosition;
  104497. private _newPosition;
  104498. /** @hidden */
  104499. _localDirection: Vector3;
  104500. /** @hidden */
  104501. _transformedDirection: Vector3;
  104502. /**
  104503. * Instantiates a FlyCamera.
  104504. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104505. * such as in a 3D Space Shooter or a Flight Simulator.
  104506. * @param name Define the name of the camera in the scene.
  104507. * @param position Define the starting position of the camera in the scene.
  104508. * @param scene Define the scene the camera belongs to.
  104509. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  104510. */
  104511. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104512. /**
  104513. * Attach a control to the HTML DOM element.
  104514. * @param element Defines the element that listens to the input events.
  104515. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  104516. */
  104517. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104518. /**
  104519. * Detach a control from the HTML DOM element.
  104520. * The camera will stop reacting to that input.
  104521. * @param element Defines the element that listens to the input events.
  104522. */
  104523. detachControl(element: HTMLElement): void;
  104524. private _collisionMask;
  104525. /**
  104526. * Get the mask that the camera ignores in collision events.
  104527. */
  104528. /**
  104529. * Set the mask that the camera ignores in collision events.
  104530. */
  104531. collisionMask: number;
  104532. /** @hidden */
  104533. _collideWithWorld(displacement: Vector3): void;
  104534. /** @hidden */
  104535. private _onCollisionPositionChange;
  104536. /** @hidden */
  104537. _checkInputs(): void;
  104538. /** @hidden */
  104539. _decideIfNeedsToMove(): boolean;
  104540. /** @hidden */
  104541. _updatePosition(): void;
  104542. /**
  104543. * Restore the Roll to its target value at the rate specified.
  104544. * @param rate - Higher means slower restoring.
  104545. * @hidden
  104546. */
  104547. restoreRoll(rate: number): void;
  104548. /**
  104549. * Destroy the camera and release the current resources held by it.
  104550. */
  104551. dispose(): void;
  104552. /**
  104553. * Get the current object class name.
  104554. * @returns the class name.
  104555. */
  104556. getClassName(): string;
  104557. }
  104558. }
  104559. declare module BABYLON {
  104560. /**
  104561. * Listen to keyboard events to control the camera.
  104562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104563. */
  104564. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  104565. /**
  104566. * Defines the camera the input is attached to.
  104567. */
  104568. camera: FlyCamera;
  104569. /**
  104570. * The list of keyboard keys used to control the forward move of the camera.
  104571. */
  104572. keysForward: number[];
  104573. /**
  104574. * The list of keyboard keys used to control the backward move of the camera.
  104575. */
  104576. keysBackward: number[];
  104577. /**
  104578. * The list of keyboard keys used to control the forward move of the camera.
  104579. */
  104580. keysUp: number[];
  104581. /**
  104582. * The list of keyboard keys used to control the backward move of the camera.
  104583. */
  104584. keysDown: number[];
  104585. /**
  104586. * The list of keyboard keys used to control the right strafe move of the camera.
  104587. */
  104588. keysRight: number[];
  104589. /**
  104590. * The list of keyboard keys used to control the left strafe move of the camera.
  104591. */
  104592. keysLeft: number[];
  104593. private _keys;
  104594. private _onCanvasBlurObserver;
  104595. private _onKeyboardObserver;
  104596. private _engine;
  104597. private _scene;
  104598. /**
  104599. * Attach the input controls to a specific dom element to get the input from.
  104600. * @param element Defines the element the controls should be listened from
  104601. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104602. */
  104603. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104604. /**
  104605. * Detach the current controls from the specified dom element.
  104606. * @param element Defines the element to stop listening the inputs from
  104607. */
  104608. detachControl(element: Nullable<HTMLElement>): void;
  104609. /**
  104610. * Gets the class name of the current intput.
  104611. * @returns the class name
  104612. */
  104613. getClassName(): string;
  104614. /** @hidden */
  104615. _onLostFocus(e: FocusEvent): void;
  104616. /**
  104617. * Get the friendly name associated with the input class.
  104618. * @returns the input friendly name
  104619. */
  104620. getSimpleName(): string;
  104621. /**
  104622. * Update the current camera state depending on the inputs that have been used this frame.
  104623. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104624. */
  104625. checkInputs(): void;
  104626. }
  104627. }
  104628. declare module BABYLON {
  104629. /**
  104630. * Manage the mouse wheel inputs to control a follow camera.
  104631. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104632. */
  104633. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  104634. /**
  104635. * Defines the camera the input is attached to.
  104636. */
  104637. camera: FollowCamera;
  104638. /**
  104639. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  104640. */
  104641. axisControlRadius: boolean;
  104642. /**
  104643. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  104644. */
  104645. axisControlHeight: boolean;
  104646. /**
  104647. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  104648. */
  104649. axisControlRotation: boolean;
  104650. /**
  104651. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  104652. * relation to mouseWheel events.
  104653. */
  104654. wheelPrecision: number;
  104655. /**
  104656. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104657. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104658. */
  104659. wheelDeltaPercentage: number;
  104660. private _wheel;
  104661. private _observer;
  104662. /**
  104663. * Attach the input controls to a specific dom element to get the input from.
  104664. * @param element Defines the element the controls should be listened from
  104665. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104666. */
  104667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104668. /**
  104669. * Detach the current controls from the specified dom element.
  104670. * @param element Defines the element to stop listening the inputs from
  104671. */
  104672. detachControl(element: Nullable<HTMLElement>): void;
  104673. /**
  104674. * Gets the class name of the current intput.
  104675. * @returns the class name
  104676. */
  104677. getClassName(): string;
  104678. /**
  104679. * Get the friendly name associated with the input class.
  104680. * @returns the input friendly name
  104681. */
  104682. getSimpleName(): string;
  104683. }
  104684. }
  104685. declare module BABYLON {
  104686. /**
  104687. * Manage the pointers inputs to control an follow camera.
  104688. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104689. */
  104690. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  104691. /**
  104692. * Defines the camera the input is attached to.
  104693. */
  104694. camera: FollowCamera;
  104695. /**
  104696. * Gets the class name of the current input.
  104697. * @returns the class name
  104698. */
  104699. getClassName(): string;
  104700. /**
  104701. * Defines the pointer angular sensibility along the X axis or how fast is
  104702. * the camera rotating.
  104703. * A negative number will reverse the axis direction.
  104704. */
  104705. angularSensibilityX: number;
  104706. /**
  104707. * Defines the pointer angular sensibility along the Y axis or how fast is
  104708. * the camera rotating.
  104709. * A negative number will reverse the axis direction.
  104710. */
  104711. angularSensibilityY: number;
  104712. /**
  104713. * Defines the pointer pinch precision or how fast is the camera zooming.
  104714. * A negative number will reverse the axis direction.
  104715. */
  104716. pinchPrecision: number;
  104717. /**
  104718. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104719. * from 0.
  104720. * It defines the percentage of current camera.radius to use as delta when
  104721. * pinch zoom is used.
  104722. */
  104723. pinchDeltaPercentage: number;
  104724. /**
  104725. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  104726. */
  104727. axisXControlRadius: boolean;
  104728. /**
  104729. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  104730. */
  104731. axisXControlHeight: boolean;
  104732. /**
  104733. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  104734. */
  104735. axisXControlRotation: boolean;
  104736. /**
  104737. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  104738. */
  104739. axisYControlRadius: boolean;
  104740. /**
  104741. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  104742. */
  104743. axisYControlHeight: boolean;
  104744. /**
  104745. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  104746. */
  104747. axisYControlRotation: boolean;
  104748. /**
  104749. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  104750. */
  104751. axisPinchControlRadius: boolean;
  104752. /**
  104753. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  104754. */
  104755. axisPinchControlHeight: boolean;
  104756. /**
  104757. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  104758. */
  104759. axisPinchControlRotation: boolean;
  104760. /**
  104761. * Log error messages if basic misconfiguration has occurred.
  104762. */
  104763. warningEnable: boolean;
  104764. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104765. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104766. private _warningCounter;
  104767. private _warning;
  104768. }
  104769. }
  104770. declare module BABYLON {
  104771. /**
  104772. * Default Inputs manager for the FollowCamera.
  104773. * It groups all the default supported inputs for ease of use.
  104774. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104775. */
  104776. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  104777. /**
  104778. * Instantiates a new FollowCameraInputsManager.
  104779. * @param camera Defines the camera the inputs belong to
  104780. */
  104781. constructor(camera: FollowCamera);
  104782. /**
  104783. * Add keyboard input support to the input manager.
  104784. * @returns the current input manager
  104785. */
  104786. addKeyboard(): FollowCameraInputsManager;
  104787. /**
  104788. * Add mouse wheel input support to the input manager.
  104789. * @returns the current input manager
  104790. */
  104791. addMouseWheel(): FollowCameraInputsManager;
  104792. /**
  104793. * Add pointers input support to the input manager.
  104794. * @returns the current input manager
  104795. */
  104796. addPointers(): FollowCameraInputsManager;
  104797. /**
  104798. * Add orientation input support to the input manager.
  104799. * @returns the current input manager
  104800. */
  104801. addVRDeviceOrientation(): FollowCameraInputsManager;
  104802. }
  104803. }
  104804. declare module BABYLON {
  104805. /**
  104806. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  104807. * an arc rotate version arcFollowCamera are available.
  104808. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104809. */
  104810. export class FollowCamera extends TargetCamera {
  104811. /**
  104812. * Distance the follow camera should follow an object at
  104813. */
  104814. radius: number;
  104815. /**
  104816. * Minimum allowed distance of the camera to the axis of rotation
  104817. * (The camera can not get closer).
  104818. * This can help limiting how the Camera is able to move in the scene.
  104819. */
  104820. lowerRadiusLimit: Nullable<number>;
  104821. /**
  104822. * Maximum allowed distance of the camera to the axis of rotation
  104823. * (The camera can not get further).
  104824. * This can help limiting how the Camera is able to move in the scene.
  104825. */
  104826. upperRadiusLimit: Nullable<number>;
  104827. /**
  104828. * Define a rotation offset between the camera and the object it follows
  104829. */
  104830. rotationOffset: number;
  104831. /**
  104832. * Minimum allowed angle to camera position relative to target object.
  104833. * This can help limiting how the Camera is able to move in the scene.
  104834. */
  104835. lowerRotationOffsetLimit: Nullable<number>;
  104836. /**
  104837. * Maximum allowed angle to camera position relative to target object.
  104838. * This can help limiting how the Camera is able to move in the scene.
  104839. */
  104840. upperRotationOffsetLimit: Nullable<number>;
  104841. /**
  104842. * Define a height offset between the camera and the object it follows.
  104843. * It can help following an object from the top (like a car chaing a plane)
  104844. */
  104845. heightOffset: number;
  104846. /**
  104847. * Minimum allowed height of camera position relative to target object.
  104848. * This can help limiting how the Camera is able to move in the scene.
  104849. */
  104850. lowerHeightOffsetLimit: Nullable<number>;
  104851. /**
  104852. * Maximum allowed height of camera position relative to target object.
  104853. * This can help limiting how the Camera is able to move in the scene.
  104854. */
  104855. upperHeightOffsetLimit: Nullable<number>;
  104856. /**
  104857. * Define how fast the camera can accelerate to follow it s target.
  104858. */
  104859. cameraAcceleration: number;
  104860. /**
  104861. * Define the speed limit of the camera following an object.
  104862. */
  104863. maxCameraSpeed: number;
  104864. /**
  104865. * Define the target of the camera.
  104866. */
  104867. lockedTarget: Nullable<AbstractMesh>;
  104868. /**
  104869. * Defines the input associated with the camera.
  104870. */
  104871. inputs: FollowCameraInputsManager;
  104872. /**
  104873. * Instantiates the follow camera.
  104874. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104875. * @param name Define the name of the camera in the scene
  104876. * @param position Define the position of the camera
  104877. * @param scene Define the scene the camera belong to
  104878. * @param lockedTarget Define the target of the camera
  104879. */
  104880. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  104881. private _follow;
  104882. /**
  104883. * Attached controls to the current camera.
  104884. * @param element Defines the element the controls should be listened from
  104885. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104886. */
  104887. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104888. /**
  104889. * Detach the current controls from the camera.
  104890. * The camera will stop reacting to inputs.
  104891. * @param element Defines the element to stop listening the inputs from
  104892. */
  104893. detachControl(element: HTMLElement): void;
  104894. /** @hidden */
  104895. _checkInputs(): void;
  104896. private _checkLimits;
  104897. /**
  104898. * Gets the camera class name.
  104899. * @returns the class name
  104900. */
  104901. getClassName(): string;
  104902. }
  104903. /**
  104904. * Arc Rotate version of the follow camera.
  104905. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  104906. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104907. */
  104908. export class ArcFollowCamera extends TargetCamera {
  104909. /** The longitudinal angle of the camera */
  104910. alpha: number;
  104911. /** The latitudinal angle of the camera */
  104912. beta: number;
  104913. /** The radius of the camera from its target */
  104914. radius: number;
  104915. /** Define the camera target (the messh it should follow) */
  104916. target: Nullable<AbstractMesh>;
  104917. private _cartesianCoordinates;
  104918. /**
  104919. * Instantiates a new ArcFollowCamera
  104920. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104921. * @param name Define the name of the camera
  104922. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  104923. * @param beta Define the rotation angle of the camera around the elevation axis
  104924. * @param radius Define the radius of the camera from its target point
  104925. * @param target Define the target of the camera
  104926. * @param scene Define the scene the camera belongs to
  104927. */
  104928. constructor(name: string,
  104929. /** The longitudinal angle of the camera */
  104930. alpha: number,
  104931. /** The latitudinal angle of the camera */
  104932. beta: number,
  104933. /** The radius of the camera from its target */
  104934. radius: number,
  104935. /** Define the camera target (the messh it should follow) */
  104936. target: Nullable<AbstractMesh>, scene: Scene);
  104937. private _follow;
  104938. /** @hidden */
  104939. _checkInputs(): void;
  104940. /**
  104941. * Returns the class name of the object.
  104942. * It is mostly used internally for serialization purposes.
  104943. */
  104944. getClassName(): string;
  104945. }
  104946. }
  104947. declare module BABYLON {
  104948. /**
  104949. * Manage the keyboard inputs to control the movement of a follow camera.
  104950. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104951. */
  104952. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  104953. /**
  104954. * Defines the camera the input is attached to.
  104955. */
  104956. camera: FollowCamera;
  104957. /**
  104958. * Defines the list of key codes associated with the up action (increase heightOffset)
  104959. */
  104960. keysHeightOffsetIncr: number[];
  104961. /**
  104962. * Defines the list of key codes associated with the down action (decrease heightOffset)
  104963. */
  104964. keysHeightOffsetDecr: number[];
  104965. /**
  104966. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  104967. */
  104968. keysHeightOffsetModifierAlt: boolean;
  104969. /**
  104970. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  104971. */
  104972. keysHeightOffsetModifierCtrl: boolean;
  104973. /**
  104974. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  104975. */
  104976. keysHeightOffsetModifierShift: boolean;
  104977. /**
  104978. * Defines the list of key codes associated with the left action (increase rotationOffset)
  104979. */
  104980. keysRotationOffsetIncr: number[];
  104981. /**
  104982. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  104983. */
  104984. keysRotationOffsetDecr: number[];
  104985. /**
  104986. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  104987. */
  104988. keysRotationOffsetModifierAlt: boolean;
  104989. /**
  104990. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  104991. */
  104992. keysRotationOffsetModifierCtrl: boolean;
  104993. /**
  104994. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  104995. */
  104996. keysRotationOffsetModifierShift: boolean;
  104997. /**
  104998. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  104999. */
  105000. keysRadiusIncr: number[];
  105001. /**
  105002. * Defines the list of key codes associated with the zoom-out action (increase radius)
  105003. */
  105004. keysRadiusDecr: number[];
  105005. /**
  105006. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  105007. */
  105008. keysRadiusModifierAlt: boolean;
  105009. /**
  105010. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  105011. */
  105012. keysRadiusModifierCtrl: boolean;
  105013. /**
  105014. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  105015. */
  105016. keysRadiusModifierShift: boolean;
  105017. /**
  105018. * Defines the rate of change of heightOffset.
  105019. */
  105020. heightSensibility: number;
  105021. /**
  105022. * Defines the rate of change of rotationOffset.
  105023. */
  105024. rotationSensibility: number;
  105025. /**
  105026. * Defines the rate of change of radius.
  105027. */
  105028. radiusSensibility: number;
  105029. private _keys;
  105030. private _ctrlPressed;
  105031. private _altPressed;
  105032. private _shiftPressed;
  105033. private _onCanvasBlurObserver;
  105034. private _onKeyboardObserver;
  105035. private _engine;
  105036. private _scene;
  105037. /**
  105038. * Attach the input controls to a specific dom element to get the input from.
  105039. * @param element Defines the element the controls should be listened from
  105040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105041. */
  105042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105043. /**
  105044. * Detach the current controls from the specified dom element.
  105045. * @param element Defines the element to stop listening the inputs from
  105046. */
  105047. detachControl(element: Nullable<HTMLElement>): void;
  105048. /**
  105049. * Update the current camera state depending on the inputs that have been used this frame.
  105050. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105051. */
  105052. checkInputs(): void;
  105053. /**
  105054. * Gets the class name of the current input.
  105055. * @returns the class name
  105056. */
  105057. getClassName(): string;
  105058. /**
  105059. * Get the friendly name associated with the input class.
  105060. * @returns the input friendly name
  105061. */
  105062. getSimpleName(): string;
  105063. /**
  105064. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105065. * allow modification of the heightOffset value.
  105066. */
  105067. private _modifierHeightOffset;
  105068. /**
  105069. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105070. * allow modification of the rotationOffset value.
  105071. */
  105072. private _modifierRotationOffset;
  105073. /**
  105074. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105075. * allow modification of the radius value.
  105076. */
  105077. private _modifierRadius;
  105078. }
  105079. }
  105080. declare module BABYLON {
  105081. interface FreeCameraInputsManager {
  105082. /**
  105083. * @hidden
  105084. */
  105085. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  105086. /**
  105087. * Add orientation input support to the input manager.
  105088. * @returns the current input manager
  105089. */
  105090. addDeviceOrientation(): FreeCameraInputsManager;
  105091. }
  105092. /**
  105093. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  105094. * Screen rotation is taken into account.
  105095. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105096. */
  105097. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  105098. private _camera;
  105099. private _screenOrientationAngle;
  105100. private _constantTranform;
  105101. private _screenQuaternion;
  105102. private _alpha;
  105103. private _beta;
  105104. private _gamma;
  105105. /**
  105106. * Can be used to detect if a device orientation sensor is availible on a device
  105107. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  105108. * @returns a promise that will resolve on orientation change
  105109. */
  105110. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  105111. /**
  105112. * @hidden
  105113. */
  105114. _onDeviceOrientationChangedObservable: Observable<void>;
  105115. /**
  105116. * Instantiates a new input
  105117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105118. */
  105119. constructor();
  105120. /**
  105121. * Define the camera controlled by the input.
  105122. */
  105123. camera: FreeCamera;
  105124. /**
  105125. * Attach the input controls to a specific dom element to get the input from.
  105126. * @param element Defines the element the controls should be listened from
  105127. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105128. */
  105129. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105130. private _orientationChanged;
  105131. private _deviceOrientation;
  105132. /**
  105133. * Detach the current controls from the specified dom element.
  105134. * @param element Defines the element to stop listening the inputs from
  105135. */
  105136. detachControl(element: Nullable<HTMLElement>): void;
  105137. /**
  105138. * Update the current camera state depending on the inputs that have been used this frame.
  105139. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105140. */
  105141. checkInputs(): void;
  105142. /**
  105143. * Gets the class name of the current intput.
  105144. * @returns the class name
  105145. */
  105146. getClassName(): string;
  105147. /**
  105148. * Get the friendly name associated with the input class.
  105149. * @returns the input friendly name
  105150. */
  105151. getSimpleName(): string;
  105152. }
  105153. }
  105154. declare module BABYLON {
  105155. /**
  105156. * Manage the gamepad inputs to control a free camera.
  105157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105158. */
  105159. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105160. /**
  105161. * Define the camera the input is attached to.
  105162. */
  105163. camera: FreeCamera;
  105164. /**
  105165. * Define the Gamepad controlling the input
  105166. */
  105167. gamepad: Nullable<Gamepad>;
  105168. /**
  105169. * Defines the gamepad rotation sensiblity.
  105170. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105171. */
  105172. gamepadAngularSensibility: number;
  105173. /**
  105174. * Defines the gamepad move sensiblity.
  105175. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105176. */
  105177. gamepadMoveSensibility: number;
  105178. private _yAxisScale;
  105179. /**
  105180. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105181. */
  105182. invertYAxis: boolean;
  105183. private _onGamepadConnectedObserver;
  105184. private _onGamepadDisconnectedObserver;
  105185. private _cameraTransform;
  105186. private _deltaTransform;
  105187. private _vector3;
  105188. private _vector2;
  105189. /**
  105190. * Attach the input controls to a specific dom element to get the input from.
  105191. * @param element Defines the element the controls should be listened from
  105192. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105193. */
  105194. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105195. /**
  105196. * Detach the current controls from the specified dom element.
  105197. * @param element Defines the element to stop listening the inputs from
  105198. */
  105199. detachControl(element: Nullable<HTMLElement>): void;
  105200. /**
  105201. * Update the current camera state depending on the inputs that have been used this frame.
  105202. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105203. */
  105204. checkInputs(): void;
  105205. /**
  105206. * Gets the class name of the current intput.
  105207. * @returns the class name
  105208. */
  105209. getClassName(): string;
  105210. /**
  105211. * Get the friendly name associated with the input class.
  105212. * @returns the input friendly name
  105213. */
  105214. getSimpleName(): string;
  105215. }
  105216. }
  105217. declare module BABYLON {
  105218. /**
  105219. * Defines the potential axis of a Joystick
  105220. */
  105221. export enum JoystickAxis {
  105222. /** X axis */
  105223. X = 0,
  105224. /** Y axis */
  105225. Y = 1,
  105226. /** Z axis */
  105227. Z = 2
  105228. }
  105229. /**
  105230. * Class used to define virtual joystick (used in touch mode)
  105231. */
  105232. export class VirtualJoystick {
  105233. /**
  105234. * Gets or sets a boolean indicating that left and right values must be inverted
  105235. */
  105236. reverseLeftRight: boolean;
  105237. /**
  105238. * Gets or sets a boolean indicating that up and down values must be inverted
  105239. */
  105240. reverseUpDown: boolean;
  105241. /**
  105242. * Gets the offset value for the position (ie. the change of the position value)
  105243. */
  105244. deltaPosition: Vector3;
  105245. /**
  105246. * Gets a boolean indicating if the virtual joystick was pressed
  105247. */
  105248. pressed: boolean;
  105249. /**
  105250. * Canvas the virtual joystick will render onto, default z-index of this is 5
  105251. */
  105252. static Canvas: Nullable<HTMLCanvasElement>;
  105253. private static _globalJoystickIndex;
  105254. private static vjCanvasContext;
  105255. private static vjCanvasWidth;
  105256. private static vjCanvasHeight;
  105257. private static halfWidth;
  105258. private _action;
  105259. private _axisTargetedByLeftAndRight;
  105260. private _axisTargetedByUpAndDown;
  105261. private _joystickSensibility;
  105262. private _inversedSensibility;
  105263. private _joystickPointerID;
  105264. private _joystickColor;
  105265. private _joystickPointerPos;
  105266. private _joystickPreviousPointerPos;
  105267. private _joystickPointerStartPos;
  105268. private _deltaJoystickVector;
  105269. private _leftJoystick;
  105270. private _touches;
  105271. private _onPointerDownHandlerRef;
  105272. private _onPointerMoveHandlerRef;
  105273. private _onPointerUpHandlerRef;
  105274. private _onResize;
  105275. /**
  105276. * Creates a new virtual joystick
  105277. * @param leftJoystick defines that the joystick is for left hand (false by default)
  105278. */
  105279. constructor(leftJoystick?: boolean);
  105280. /**
  105281. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  105282. * @param newJoystickSensibility defines the new sensibility
  105283. */
  105284. setJoystickSensibility(newJoystickSensibility: number): void;
  105285. private _onPointerDown;
  105286. private _onPointerMove;
  105287. private _onPointerUp;
  105288. /**
  105289. * Change the color of the virtual joystick
  105290. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  105291. */
  105292. setJoystickColor(newColor: string): void;
  105293. /**
  105294. * Defines a callback to call when the joystick is touched
  105295. * @param action defines the callback
  105296. */
  105297. setActionOnTouch(action: () => any): void;
  105298. /**
  105299. * Defines which axis you'd like to control for left & right
  105300. * @param axis defines the axis to use
  105301. */
  105302. setAxisForLeftRight(axis: JoystickAxis): void;
  105303. /**
  105304. * Defines which axis you'd like to control for up & down
  105305. * @param axis defines the axis to use
  105306. */
  105307. setAxisForUpDown(axis: JoystickAxis): void;
  105308. private _drawVirtualJoystick;
  105309. /**
  105310. * Release internal HTML canvas
  105311. */
  105312. releaseCanvas(): void;
  105313. }
  105314. }
  105315. declare module BABYLON {
  105316. interface FreeCameraInputsManager {
  105317. /**
  105318. * Add virtual joystick input support to the input manager.
  105319. * @returns the current input manager
  105320. */
  105321. addVirtualJoystick(): FreeCameraInputsManager;
  105322. }
  105323. /**
  105324. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  105325. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105326. */
  105327. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  105328. /**
  105329. * Defines the camera the input is attached to.
  105330. */
  105331. camera: FreeCamera;
  105332. private _leftjoystick;
  105333. private _rightjoystick;
  105334. /**
  105335. * Gets the left stick of the virtual joystick.
  105336. * @returns The virtual Joystick
  105337. */
  105338. getLeftJoystick(): VirtualJoystick;
  105339. /**
  105340. * Gets the right stick of the virtual joystick.
  105341. * @returns The virtual Joystick
  105342. */
  105343. getRightJoystick(): VirtualJoystick;
  105344. /**
  105345. * Update the current camera state depending on the inputs that have been used this frame.
  105346. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105347. */
  105348. checkInputs(): void;
  105349. /**
  105350. * Attach the input controls to a specific dom element to get the input from.
  105351. * @param element Defines the element the controls should be listened from
  105352. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105353. */
  105354. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105355. /**
  105356. * Detach the current controls from the specified dom element.
  105357. * @param element Defines the element to stop listening the inputs from
  105358. */
  105359. detachControl(element: Nullable<HTMLElement>): void;
  105360. /**
  105361. * Gets the class name of the current intput.
  105362. * @returns the class name
  105363. */
  105364. getClassName(): string;
  105365. /**
  105366. * Get the friendly name associated with the input class.
  105367. * @returns the input friendly name
  105368. */
  105369. getSimpleName(): string;
  105370. }
  105371. }
  105372. declare module BABYLON {
  105373. /**
  105374. * This represents a FPS type of camera controlled by touch.
  105375. * This is like a universal camera minus the Gamepad controls.
  105376. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105377. */
  105378. export class TouchCamera extends FreeCamera {
  105379. /**
  105380. * Defines the touch sensibility for rotation.
  105381. * The higher the faster.
  105382. */
  105383. touchAngularSensibility: number;
  105384. /**
  105385. * Defines the touch sensibility for move.
  105386. * The higher the faster.
  105387. */
  105388. touchMoveSensibility: number;
  105389. /**
  105390. * Instantiates a new touch camera.
  105391. * This represents a FPS type of camera controlled by touch.
  105392. * This is like a universal camera minus the Gamepad controls.
  105393. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105394. * @param name Define the name of the camera in the scene
  105395. * @param position Define the start position of the camera in the scene
  105396. * @param scene Define the scene the camera belongs to
  105397. */
  105398. constructor(name: string, position: Vector3, scene: Scene);
  105399. /**
  105400. * Gets the current object class name.
  105401. * @return the class name
  105402. */
  105403. getClassName(): string;
  105404. /** @hidden */
  105405. _setupInputs(): void;
  105406. }
  105407. }
  105408. declare module BABYLON {
  105409. /**
  105410. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  105411. * being tilted forward or back and left or right.
  105412. */
  105413. export class DeviceOrientationCamera extends FreeCamera {
  105414. private _initialQuaternion;
  105415. private _quaternionCache;
  105416. private _tmpDragQuaternion;
  105417. private _disablePointerInputWhenUsingDeviceOrientation;
  105418. /**
  105419. * Creates a new device orientation camera
  105420. * @param name The name of the camera
  105421. * @param position The start position camera
  105422. * @param scene The scene the camera belongs to
  105423. */
  105424. constructor(name: string, position: Vector3, scene: Scene);
  105425. /**
  105426. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  105427. */
  105428. disablePointerInputWhenUsingDeviceOrientation: boolean;
  105429. private _dragFactor;
  105430. /**
  105431. * Enabled turning on the y axis when the orientation sensor is active
  105432. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  105433. */
  105434. enableHorizontalDragging(dragFactor?: number): void;
  105435. /**
  105436. * Gets the current instance class name ("DeviceOrientationCamera").
  105437. * This helps avoiding instanceof at run time.
  105438. * @returns the class name
  105439. */
  105440. getClassName(): string;
  105441. /**
  105442. * @hidden
  105443. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  105444. */
  105445. _checkInputs(): void;
  105446. /**
  105447. * Reset the camera to its default orientation on the specified axis only.
  105448. * @param axis The axis to reset
  105449. */
  105450. resetToCurrentRotation(axis?: Axis): void;
  105451. }
  105452. }
  105453. declare module BABYLON {
  105454. /**
  105455. * Defines supported buttons for XBox360 compatible gamepads
  105456. */
  105457. export enum Xbox360Button {
  105458. /** A */
  105459. A = 0,
  105460. /** B */
  105461. B = 1,
  105462. /** X */
  105463. X = 2,
  105464. /** Y */
  105465. Y = 3,
  105466. /** Start */
  105467. Start = 4,
  105468. /** Back */
  105469. Back = 5,
  105470. /** Left button */
  105471. LB = 6,
  105472. /** Right button */
  105473. RB = 7,
  105474. /** Left stick */
  105475. LeftStick = 8,
  105476. /** Right stick */
  105477. RightStick = 9
  105478. }
  105479. /** Defines values for XBox360 DPad */
  105480. export enum Xbox360Dpad {
  105481. /** Up */
  105482. Up = 0,
  105483. /** Down */
  105484. Down = 1,
  105485. /** Left */
  105486. Left = 2,
  105487. /** Right */
  105488. Right = 3
  105489. }
  105490. /**
  105491. * Defines a XBox360 gamepad
  105492. */
  105493. export class Xbox360Pad extends Gamepad {
  105494. private _leftTrigger;
  105495. private _rightTrigger;
  105496. private _onlefttriggerchanged;
  105497. private _onrighttriggerchanged;
  105498. private _onbuttondown;
  105499. private _onbuttonup;
  105500. private _ondpaddown;
  105501. private _ondpadup;
  105502. /** Observable raised when a button is pressed */
  105503. onButtonDownObservable: Observable<Xbox360Button>;
  105504. /** Observable raised when a button is released */
  105505. onButtonUpObservable: Observable<Xbox360Button>;
  105506. /** Observable raised when a pad is pressed */
  105507. onPadDownObservable: Observable<Xbox360Dpad>;
  105508. /** Observable raised when a pad is released */
  105509. onPadUpObservable: Observable<Xbox360Dpad>;
  105510. private _buttonA;
  105511. private _buttonB;
  105512. private _buttonX;
  105513. private _buttonY;
  105514. private _buttonBack;
  105515. private _buttonStart;
  105516. private _buttonLB;
  105517. private _buttonRB;
  105518. private _buttonLeftStick;
  105519. private _buttonRightStick;
  105520. private _dPadUp;
  105521. private _dPadDown;
  105522. private _dPadLeft;
  105523. private _dPadRight;
  105524. private _isXboxOnePad;
  105525. /**
  105526. * Creates a new XBox360 gamepad object
  105527. * @param id defines the id of this gamepad
  105528. * @param index defines its index
  105529. * @param gamepad defines the internal HTML gamepad object
  105530. * @param xboxOne defines if it is a XBox One gamepad
  105531. */
  105532. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  105533. /**
  105534. * Defines the callback to call when left trigger is pressed
  105535. * @param callback defines the callback to use
  105536. */
  105537. onlefttriggerchanged(callback: (value: number) => void): void;
  105538. /**
  105539. * Defines the callback to call when right trigger is pressed
  105540. * @param callback defines the callback to use
  105541. */
  105542. onrighttriggerchanged(callback: (value: number) => void): void;
  105543. /**
  105544. * Gets the left trigger value
  105545. */
  105546. /**
  105547. * Sets the left trigger value
  105548. */
  105549. leftTrigger: number;
  105550. /**
  105551. * Gets the right trigger value
  105552. */
  105553. /**
  105554. * Sets the right trigger value
  105555. */
  105556. rightTrigger: number;
  105557. /**
  105558. * Defines the callback to call when a button is pressed
  105559. * @param callback defines the callback to use
  105560. */
  105561. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  105562. /**
  105563. * Defines the callback to call when a button is released
  105564. * @param callback defines the callback to use
  105565. */
  105566. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  105567. /**
  105568. * Defines the callback to call when a pad is pressed
  105569. * @param callback defines the callback to use
  105570. */
  105571. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  105572. /**
  105573. * Defines the callback to call when a pad is released
  105574. * @param callback defines the callback to use
  105575. */
  105576. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  105577. private _setButtonValue;
  105578. private _setDPadValue;
  105579. /**
  105580. * Gets the value of the `A` button
  105581. */
  105582. /**
  105583. * Sets the value of the `A` button
  105584. */
  105585. buttonA: number;
  105586. /**
  105587. * Gets the value of the `B` button
  105588. */
  105589. /**
  105590. * Sets the value of the `B` button
  105591. */
  105592. buttonB: number;
  105593. /**
  105594. * Gets the value of the `X` button
  105595. */
  105596. /**
  105597. * Sets the value of the `X` button
  105598. */
  105599. buttonX: number;
  105600. /**
  105601. * Gets the value of the `Y` button
  105602. */
  105603. /**
  105604. * Sets the value of the `Y` button
  105605. */
  105606. buttonY: number;
  105607. /**
  105608. * Gets the value of the `Start` button
  105609. */
  105610. /**
  105611. * Sets the value of the `Start` button
  105612. */
  105613. buttonStart: number;
  105614. /**
  105615. * Gets the value of the `Back` button
  105616. */
  105617. /**
  105618. * Sets the value of the `Back` button
  105619. */
  105620. buttonBack: number;
  105621. /**
  105622. * Gets the value of the `Left` button
  105623. */
  105624. /**
  105625. * Sets the value of the `Left` button
  105626. */
  105627. buttonLB: number;
  105628. /**
  105629. * Gets the value of the `Right` button
  105630. */
  105631. /**
  105632. * Sets the value of the `Right` button
  105633. */
  105634. buttonRB: number;
  105635. /**
  105636. * Gets the value of the Left joystick
  105637. */
  105638. /**
  105639. * Sets the value of the Left joystick
  105640. */
  105641. buttonLeftStick: number;
  105642. /**
  105643. * Gets the value of the Right joystick
  105644. */
  105645. /**
  105646. * Sets the value of the Right joystick
  105647. */
  105648. buttonRightStick: number;
  105649. /**
  105650. * Gets the value of D-pad up
  105651. */
  105652. /**
  105653. * Sets the value of D-pad up
  105654. */
  105655. dPadUp: number;
  105656. /**
  105657. * Gets the value of D-pad down
  105658. */
  105659. /**
  105660. * Sets the value of D-pad down
  105661. */
  105662. dPadDown: number;
  105663. /**
  105664. * Gets the value of D-pad left
  105665. */
  105666. /**
  105667. * Sets the value of D-pad left
  105668. */
  105669. dPadLeft: number;
  105670. /**
  105671. * Gets the value of D-pad right
  105672. */
  105673. /**
  105674. * Sets the value of D-pad right
  105675. */
  105676. dPadRight: number;
  105677. /**
  105678. * Force the gamepad to synchronize with device values
  105679. */
  105680. update(): void;
  105681. /**
  105682. * Disposes the gamepad
  105683. */
  105684. dispose(): void;
  105685. }
  105686. }
  105687. declare module BABYLON {
  105688. /**
  105689. * Defines supported buttons for DualShock compatible gamepads
  105690. */
  105691. export enum DualShockButton {
  105692. /** Cross */
  105693. Cross = 0,
  105694. /** Circle */
  105695. Circle = 1,
  105696. /** Square */
  105697. Square = 2,
  105698. /** Triangle */
  105699. Triangle = 3,
  105700. /** Options */
  105701. Options = 4,
  105702. /** Share */
  105703. Share = 5,
  105704. /** L1 */
  105705. L1 = 6,
  105706. /** R1 */
  105707. R1 = 7,
  105708. /** Left stick */
  105709. LeftStick = 8,
  105710. /** Right stick */
  105711. RightStick = 9
  105712. }
  105713. /** Defines values for DualShock DPad */
  105714. export enum DualShockDpad {
  105715. /** Up */
  105716. Up = 0,
  105717. /** Down */
  105718. Down = 1,
  105719. /** Left */
  105720. Left = 2,
  105721. /** Right */
  105722. Right = 3
  105723. }
  105724. /**
  105725. * Defines a DualShock gamepad
  105726. */
  105727. export class DualShockPad extends Gamepad {
  105728. private _leftTrigger;
  105729. private _rightTrigger;
  105730. private _onlefttriggerchanged;
  105731. private _onrighttriggerchanged;
  105732. private _onbuttondown;
  105733. private _onbuttonup;
  105734. private _ondpaddown;
  105735. private _ondpadup;
  105736. /** Observable raised when a button is pressed */
  105737. onButtonDownObservable: Observable<DualShockButton>;
  105738. /** Observable raised when a button is released */
  105739. onButtonUpObservable: Observable<DualShockButton>;
  105740. /** Observable raised when a pad is pressed */
  105741. onPadDownObservable: Observable<DualShockDpad>;
  105742. /** Observable raised when a pad is released */
  105743. onPadUpObservable: Observable<DualShockDpad>;
  105744. private _buttonCross;
  105745. private _buttonCircle;
  105746. private _buttonSquare;
  105747. private _buttonTriangle;
  105748. private _buttonShare;
  105749. private _buttonOptions;
  105750. private _buttonL1;
  105751. private _buttonR1;
  105752. private _buttonLeftStick;
  105753. private _buttonRightStick;
  105754. private _dPadUp;
  105755. private _dPadDown;
  105756. private _dPadLeft;
  105757. private _dPadRight;
  105758. /**
  105759. * Creates a new DualShock gamepad object
  105760. * @param id defines the id of this gamepad
  105761. * @param index defines its index
  105762. * @param gamepad defines the internal HTML gamepad object
  105763. */
  105764. constructor(id: string, index: number, gamepad: any);
  105765. /**
  105766. * Defines the callback to call when left trigger is pressed
  105767. * @param callback defines the callback to use
  105768. */
  105769. onlefttriggerchanged(callback: (value: number) => void): void;
  105770. /**
  105771. * Defines the callback to call when right trigger is pressed
  105772. * @param callback defines the callback to use
  105773. */
  105774. onrighttriggerchanged(callback: (value: number) => void): void;
  105775. /**
  105776. * Gets the left trigger value
  105777. */
  105778. /**
  105779. * Sets the left trigger value
  105780. */
  105781. leftTrigger: number;
  105782. /**
  105783. * Gets the right trigger value
  105784. */
  105785. /**
  105786. * Sets the right trigger value
  105787. */
  105788. rightTrigger: number;
  105789. /**
  105790. * Defines the callback to call when a button is pressed
  105791. * @param callback defines the callback to use
  105792. */
  105793. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  105794. /**
  105795. * Defines the callback to call when a button is released
  105796. * @param callback defines the callback to use
  105797. */
  105798. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  105799. /**
  105800. * Defines the callback to call when a pad is pressed
  105801. * @param callback defines the callback to use
  105802. */
  105803. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  105804. /**
  105805. * Defines the callback to call when a pad is released
  105806. * @param callback defines the callback to use
  105807. */
  105808. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  105809. private _setButtonValue;
  105810. private _setDPadValue;
  105811. /**
  105812. * Gets the value of the `Cross` button
  105813. */
  105814. /**
  105815. * Sets the value of the `Cross` button
  105816. */
  105817. buttonCross: number;
  105818. /**
  105819. * Gets the value of the `Circle` button
  105820. */
  105821. /**
  105822. * Sets the value of the `Circle` button
  105823. */
  105824. buttonCircle: number;
  105825. /**
  105826. * Gets the value of the `Square` button
  105827. */
  105828. /**
  105829. * Sets the value of the `Square` button
  105830. */
  105831. buttonSquare: number;
  105832. /**
  105833. * Gets the value of the `Triangle` button
  105834. */
  105835. /**
  105836. * Sets the value of the `Triangle` button
  105837. */
  105838. buttonTriangle: number;
  105839. /**
  105840. * Gets the value of the `Options` button
  105841. */
  105842. /**
  105843. * Sets the value of the `Options` button
  105844. */
  105845. buttonOptions: number;
  105846. /**
  105847. * Gets the value of the `Share` button
  105848. */
  105849. /**
  105850. * Sets the value of the `Share` button
  105851. */
  105852. buttonShare: number;
  105853. /**
  105854. * Gets the value of the `L1` button
  105855. */
  105856. /**
  105857. * Sets the value of the `L1` button
  105858. */
  105859. buttonL1: number;
  105860. /**
  105861. * Gets the value of the `R1` button
  105862. */
  105863. /**
  105864. * Sets the value of the `R1` button
  105865. */
  105866. buttonR1: number;
  105867. /**
  105868. * Gets the value of the Left joystick
  105869. */
  105870. /**
  105871. * Sets the value of the Left joystick
  105872. */
  105873. buttonLeftStick: number;
  105874. /**
  105875. * Gets the value of the Right joystick
  105876. */
  105877. /**
  105878. * Sets the value of the Right joystick
  105879. */
  105880. buttonRightStick: number;
  105881. /**
  105882. * Gets the value of D-pad up
  105883. */
  105884. /**
  105885. * Sets the value of D-pad up
  105886. */
  105887. dPadUp: number;
  105888. /**
  105889. * Gets the value of D-pad down
  105890. */
  105891. /**
  105892. * Sets the value of D-pad down
  105893. */
  105894. dPadDown: number;
  105895. /**
  105896. * Gets the value of D-pad left
  105897. */
  105898. /**
  105899. * Sets the value of D-pad left
  105900. */
  105901. dPadLeft: number;
  105902. /**
  105903. * Gets the value of D-pad right
  105904. */
  105905. /**
  105906. * Sets the value of D-pad right
  105907. */
  105908. dPadRight: number;
  105909. /**
  105910. * Force the gamepad to synchronize with device values
  105911. */
  105912. update(): void;
  105913. /**
  105914. * Disposes the gamepad
  105915. */
  105916. dispose(): void;
  105917. }
  105918. }
  105919. declare module BABYLON {
  105920. /**
  105921. * Manager for handling gamepads
  105922. */
  105923. export class GamepadManager {
  105924. private _scene?;
  105925. private _babylonGamepads;
  105926. private _oneGamepadConnected;
  105927. /** @hidden */
  105928. _isMonitoring: boolean;
  105929. private _gamepadEventSupported;
  105930. private _gamepadSupport;
  105931. /**
  105932. * observable to be triggered when the gamepad controller has been connected
  105933. */
  105934. onGamepadConnectedObservable: Observable<Gamepad>;
  105935. /**
  105936. * observable to be triggered when the gamepad controller has been disconnected
  105937. */
  105938. onGamepadDisconnectedObservable: Observable<Gamepad>;
  105939. private _onGamepadConnectedEvent;
  105940. private _onGamepadDisconnectedEvent;
  105941. /**
  105942. * Initializes the gamepad manager
  105943. * @param _scene BabylonJS scene
  105944. */
  105945. constructor(_scene?: Scene | undefined);
  105946. /**
  105947. * The gamepads in the game pad manager
  105948. */
  105949. readonly gamepads: Gamepad[];
  105950. /**
  105951. * Get the gamepad controllers based on type
  105952. * @param type The type of gamepad controller
  105953. * @returns Nullable gamepad
  105954. */
  105955. getGamepadByType(type?: number): Nullable<Gamepad>;
  105956. /**
  105957. * Disposes the gamepad manager
  105958. */
  105959. dispose(): void;
  105960. private _addNewGamepad;
  105961. private _startMonitoringGamepads;
  105962. private _stopMonitoringGamepads;
  105963. /** @hidden */
  105964. _checkGamepadsStatus(): void;
  105965. private _updateGamepadObjects;
  105966. }
  105967. }
  105968. declare module BABYLON {
  105969. interface Scene {
  105970. /** @hidden */
  105971. _gamepadManager: Nullable<GamepadManager>;
  105972. /**
  105973. * Gets the gamepad manager associated with the scene
  105974. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  105975. */
  105976. gamepadManager: GamepadManager;
  105977. }
  105978. /**
  105979. * Interface representing a free camera inputs manager
  105980. */
  105981. interface FreeCameraInputsManager {
  105982. /**
  105983. * Adds gamepad input support to the FreeCameraInputsManager.
  105984. * @returns the FreeCameraInputsManager
  105985. */
  105986. addGamepad(): FreeCameraInputsManager;
  105987. }
  105988. /**
  105989. * Interface representing an arc rotate camera inputs manager
  105990. */
  105991. interface ArcRotateCameraInputsManager {
  105992. /**
  105993. * Adds gamepad input support to the ArcRotateCamera InputManager.
  105994. * @returns the camera inputs manager
  105995. */
  105996. addGamepad(): ArcRotateCameraInputsManager;
  105997. }
  105998. /**
  105999. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  106000. */
  106001. export class GamepadSystemSceneComponent implements ISceneComponent {
  106002. /**
  106003. * The component name helpfull to identify the component in the list of scene components.
  106004. */
  106005. readonly name: string;
  106006. /**
  106007. * The scene the component belongs to.
  106008. */
  106009. scene: Scene;
  106010. /**
  106011. * Creates a new instance of the component for the given scene
  106012. * @param scene Defines the scene to register the component in
  106013. */
  106014. constructor(scene: Scene);
  106015. /**
  106016. * Registers the component in a given scene
  106017. */
  106018. register(): void;
  106019. /**
  106020. * Rebuilds the elements related to this component in case of
  106021. * context lost for instance.
  106022. */
  106023. rebuild(): void;
  106024. /**
  106025. * Disposes the component and the associated ressources
  106026. */
  106027. dispose(): void;
  106028. private _beforeCameraUpdate;
  106029. }
  106030. }
  106031. declare module BABYLON {
  106032. /**
  106033. * 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,
  106034. * which still works and will still be found in many Playgrounds.
  106035. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106036. */
  106037. export class UniversalCamera extends TouchCamera {
  106038. /**
  106039. * Defines the gamepad rotation sensiblity.
  106040. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106041. */
  106042. gamepadAngularSensibility: number;
  106043. /**
  106044. * Defines the gamepad move sensiblity.
  106045. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106046. */
  106047. gamepadMoveSensibility: number;
  106048. /**
  106049. * 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,
  106050. * which still works and will still be found in many Playgrounds.
  106051. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106052. * @param name Define the name of the camera in the scene
  106053. * @param position Define the start position of the camera in the scene
  106054. * @param scene Define the scene the camera belongs to
  106055. */
  106056. constructor(name: string, position: Vector3, scene: Scene);
  106057. /**
  106058. * Gets the current object class name.
  106059. * @return the class name
  106060. */
  106061. getClassName(): string;
  106062. }
  106063. }
  106064. declare module BABYLON {
  106065. /**
  106066. * This represents a FPS type of camera. This is only here for back compat purpose.
  106067. * Please use the UniversalCamera instead as both are identical.
  106068. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106069. */
  106070. export class GamepadCamera extends UniversalCamera {
  106071. /**
  106072. * Instantiates a new Gamepad Camera
  106073. * This represents a FPS type of camera. This is only here for back compat purpose.
  106074. * Please use the UniversalCamera instead as both are identical.
  106075. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106076. * @param name Define the name of the camera in the scene
  106077. * @param position Define the start position of the camera in the scene
  106078. * @param scene Define the scene the camera belongs to
  106079. */
  106080. constructor(name: string, position: Vector3, scene: Scene);
  106081. /**
  106082. * Gets the current object class name.
  106083. * @return the class name
  106084. */
  106085. getClassName(): string;
  106086. }
  106087. }
  106088. declare module BABYLON {
  106089. /** @hidden */
  106090. export var passPixelShader: {
  106091. name: string;
  106092. shader: string;
  106093. };
  106094. }
  106095. declare module BABYLON {
  106096. /** @hidden */
  106097. export var passCubePixelShader: {
  106098. name: string;
  106099. shader: string;
  106100. };
  106101. }
  106102. declare module BABYLON {
  106103. /**
  106104. * PassPostProcess which produces an output the same as it's input
  106105. */
  106106. export class PassPostProcess extends PostProcess {
  106107. /**
  106108. * Creates the PassPostProcess
  106109. * @param name The name of the effect.
  106110. * @param options The required width/height ratio to downsize to before computing the render pass.
  106111. * @param camera The camera to apply the render pass to.
  106112. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106113. * @param engine The engine which the post process will be applied. (default: current engine)
  106114. * @param reusable If the post process can be reused on the same frame. (default: false)
  106115. * @param textureType The type of texture to be used when performing the post processing.
  106116. * @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)
  106117. */
  106118. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106119. }
  106120. /**
  106121. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  106122. */
  106123. export class PassCubePostProcess extends PostProcess {
  106124. private _face;
  106125. /**
  106126. * Gets or sets the cube face to display.
  106127. * * 0 is +X
  106128. * * 1 is -X
  106129. * * 2 is +Y
  106130. * * 3 is -Y
  106131. * * 4 is +Z
  106132. * * 5 is -Z
  106133. */
  106134. face: number;
  106135. /**
  106136. * Creates the PassCubePostProcess
  106137. * @param name The name of the effect.
  106138. * @param options The required width/height ratio to downsize to before computing the render pass.
  106139. * @param camera The camera to apply the render pass to.
  106140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106141. * @param engine The engine which the post process will be applied. (default: current engine)
  106142. * @param reusable If the post process can be reused on the same frame. (default: false)
  106143. * @param textureType The type of texture to be used when performing the post processing.
  106144. * @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)
  106145. */
  106146. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106147. }
  106148. }
  106149. declare module BABYLON {
  106150. /** @hidden */
  106151. export var anaglyphPixelShader: {
  106152. name: string;
  106153. shader: string;
  106154. };
  106155. }
  106156. declare module BABYLON {
  106157. /**
  106158. * Postprocess used to generate anaglyphic rendering
  106159. */
  106160. export class AnaglyphPostProcess extends PostProcess {
  106161. private _passedProcess;
  106162. /**
  106163. * Creates a new AnaglyphPostProcess
  106164. * @param name defines postprocess name
  106165. * @param options defines creation options or target ratio scale
  106166. * @param rigCameras defines cameras using this postprocess
  106167. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106168. * @param engine defines hosting engine
  106169. * @param reusable defines if the postprocess will be reused multiple times per frame
  106170. */
  106171. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106172. }
  106173. }
  106174. declare module BABYLON {
  106175. /**
  106176. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106177. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106178. */
  106179. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106180. /**
  106181. * Creates a new AnaglyphArcRotateCamera
  106182. * @param name defines camera name
  106183. * @param alpha defines alpha angle (in radians)
  106184. * @param beta defines beta angle (in radians)
  106185. * @param radius defines radius
  106186. * @param target defines camera target
  106187. * @param interaxialDistance defines distance between each color axis
  106188. * @param scene defines the hosting scene
  106189. */
  106190. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106191. /**
  106192. * Gets camera class name
  106193. * @returns AnaglyphArcRotateCamera
  106194. */
  106195. getClassName(): string;
  106196. }
  106197. }
  106198. declare module BABYLON {
  106199. /**
  106200. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106201. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106202. */
  106203. export class AnaglyphFreeCamera extends FreeCamera {
  106204. /**
  106205. * Creates a new AnaglyphFreeCamera
  106206. * @param name defines camera name
  106207. * @param position defines initial position
  106208. * @param interaxialDistance defines distance between each color axis
  106209. * @param scene defines the hosting scene
  106210. */
  106211. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106212. /**
  106213. * Gets camera class name
  106214. * @returns AnaglyphFreeCamera
  106215. */
  106216. getClassName(): string;
  106217. }
  106218. }
  106219. declare module BABYLON {
  106220. /**
  106221. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106222. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106223. */
  106224. export class AnaglyphGamepadCamera extends GamepadCamera {
  106225. /**
  106226. * Creates a new AnaglyphGamepadCamera
  106227. * @param name defines camera name
  106228. * @param position defines initial position
  106229. * @param interaxialDistance defines distance between each color axis
  106230. * @param scene defines the hosting scene
  106231. */
  106232. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106233. /**
  106234. * Gets camera class name
  106235. * @returns AnaglyphGamepadCamera
  106236. */
  106237. getClassName(): string;
  106238. }
  106239. }
  106240. declare module BABYLON {
  106241. /**
  106242. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106243. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106244. */
  106245. export class AnaglyphUniversalCamera extends UniversalCamera {
  106246. /**
  106247. * Creates a new AnaglyphUniversalCamera
  106248. * @param name defines camera name
  106249. * @param position defines initial position
  106250. * @param interaxialDistance defines distance between each color axis
  106251. * @param scene defines the hosting scene
  106252. */
  106253. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106254. /**
  106255. * Gets camera class name
  106256. * @returns AnaglyphUniversalCamera
  106257. */
  106258. getClassName(): string;
  106259. }
  106260. }
  106261. declare module BABYLON {
  106262. /** @hidden */
  106263. export var stereoscopicInterlacePixelShader: {
  106264. name: string;
  106265. shader: string;
  106266. };
  106267. }
  106268. declare module BABYLON {
  106269. /**
  106270. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  106271. */
  106272. export class StereoscopicInterlacePostProcess extends PostProcess {
  106273. private _stepSize;
  106274. private _passedProcess;
  106275. /**
  106276. * Initializes a StereoscopicInterlacePostProcess
  106277. * @param name The name of the effect.
  106278. * @param rigCameras The rig cameras to be appled to the post process
  106279. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  106280. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106281. * @param engine The engine which the post process will be applied. (default: current engine)
  106282. * @param reusable If the post process can be reused on the same frame. (default: false)
  106283. */
  106284. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106285. }
  106286. }
  106287. declare module BABYLON {
  106288. /**
  106289. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  106290. * @see http://doc.babylonjs.com/features/cameras
  106291. */
  106292. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  106293. /**
  106294. * Creates a new StereoscopicArcRotateCamera
  106295. * @param name defines camera name
  106296. * @param alpha defines alpha angle (in radians)
  106297. * @param beta defines beta angle (in radians)
  106298. * @param radius defines radius
  106299. * @param target defines camera target
  106300. * @param interaxialDistance defines distance between each color axis
  106301. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106302. * @param scene defines the hosting scene
  106303. */
  106304. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106305. /**
  106306. * Gets camera class name
  106307. * @returns StereoscopicArcRotateCamera
  106308. */
  106309. getClassName(): string;
  106310. }
  106311. }
  106312. declare module BABYLON {
  106313. /**
  106314. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  106315. * @see http://doc.babylonjs.com/features/cameras
  106316. */
  106317. export class StereoscopicFreeCamera extends FreeCamera {
  106318. /**
  106319. * Creates a new StereoscopicFreeCamera
  106320. * @param name defines camera name
  106321. * @param position defines initial position
  106322. * @param interaxialDistance defines distance between each color axis
  106323. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106324. * @param scene defines the hosting scene
  106325. */
  106326. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106327. /**
  106328. * Gets camera class name
  106329. * @returns StereoscopicFreeCamera
  106330. */
  106331. getClassName(): string;
  106332. }
  106333. }
  106334. declare module BABYLON {
  106335. /**
  106336. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  106337. * @see http://doc.babylonjs.com/features/cameras
  106338. */
  106339. export class StereoscopicGamepadCamera extends GamepadCamera {
  106340. /**
  106341. * Creates a new StereoscopicGamepadCamera
  106342. * @param name defines camera name
  106343. * @param position defines initial position
  106344. * @param interaxialDistance defines distance between each color axis
  106345. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106346. * @param scene defines the hosting scene
  106347. */
  106348. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106349. /**
  106350. * Gets camera class name
  106351. * @returns StereoscopicGamepadCamera
  106352. */
  106353. getClassName(): string;
  106354. }
  106355. }
  106356. declare module BABYLON {
  106357. /**
  106358. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  106359. * @see http://doc.babylonjs.com/features/cameras
  106360. */
  106361. export class StereoscopicUniversalCamera extends UniversalCamera {
  106362. /**
  106363. * Creates a new StereoscopicUniversalCamera
  106364. * @param name defines camera name
  106365. * @param position defines initial position
  106366. * @param interaxialDistance defines distance between each color axis
  106367. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106368. * @param scene defines the hosting scene
  106369. */
  106370. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106371. /**
  106372. * Gets camera class name
  106373. * @returns StereoscopicUniversalCamera
  106374. */
  106375. getClassName(): string;
  106376. }
  106377. }
  106378. declare module BABYLON {
  106379. /**
  106380. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  106381. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106382. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106383. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106384. */
  106385. export class VirtualJoysticksCamera extends FreeCamera {
  106386. /**
  106387. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  106388. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106389. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106390. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106391. * @param name Define the name of the camera in the scene
  106392. * @param position Define the start position of the camera in the scene
  106393. * @param scene Define the scene the camera belongs to
  106394. */
  106395. constructor(name: string, position: Vector3, scene: Scene);
  106396. /**
  106397. * Gets the current object class name.
  106398. * @return the class name
  106399. */
  106400. getClassName(): string;
  106401. }
  106402. }
  106403. declare module BABYLON {
  106404. /**
  106405. * This represents all the required metrics to create a VR camera.
  106406. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  106407. */
  106408. export class VRCameraMetrics {
  106409. /**
  106410. * Define the horizontal resolution off the screen.
  106411. */
  106412. hResolution: number;
  106413. /**
  106414. * Define the vertical resolution off the screen.
  106415. */
  106416. vResolution: number;
  106417. /**
  106418. * Define the horizontal screen size.
  106419. */
  106420. hScreenSize: number;
  106421. /**
  106422. * Define the vertical screen size.
  106423. */
  106424. vScreenSize: number;
  106425. /**
  106426. * Define the vertical screen center position.
  106427. */
  106428. vScreenCenter: number;
  106429. /**
  106430. * Define the distance of the eyes to the screen.
  106431. */
  106432. eyeToScreenDistance: number;
  106433. /**
  106434. * Define the distance between both lenses
  106435. */
  106436. lensSeparationDistance: number;
  106437. /**
  106438. * Define the distance between both viewer's eyes.
  106439. */
  106440. interpupillaryDistance: number;
  106441. /**
  106442. * Define the distortion factor of the VR postprocess.
  106443. * Please, touch with care.
  106444. */
  106445. distortionK: number[];
  106446. /**
  106447. * Define the chromatic aberration correction factors for the VR post process.
  106448. */
  106449. chromaAbCorrection: number[];
  106450. /**
  106451. * Define the scale factor of the post process.
  106452. * The smaller the better but the slower.
  106453. */
  106454. postProcessScaleFactor: number;
  106455. /**
  106456. * Define an offset for the lens center.
  106457. */
  106458. lensCenterOffset: number;
  106459. /**
  106460. * Define if the current vr camera should compensate the distortion of the lense or not.
  106461. */
  106462. compensateDistortion: boolean;
  106463. /**
  106464. * Defines if multiview should be enabled when rendering (Default: false)
  106465. */
  106466. multiviewEnabled: boolean;
  106467. /**
  106468. * Gets the rendering aspect ratio based on the provided resolutions.
  106469. */
  106470. readonly aspectRatio: number;
  106471. /**
  106472. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  106473. */
  106474. readonly aspectRatioFov: number;
  106475. /**
  106476. * @hidden
  106477. */
  106478. readonly leftHMatrix: Matrix;
  106479. /**
  106480. * @hidden
  106481. */
  106482. readonly rightHMatrix: Matrix;
  106483. /**
  106484. * @hidden
  106485. */
  106486. readonly leftPreViewMatrix: Matrix;
  106487. /**
  106488. * @hidden
  106489. */
  106490. readonly rightPreViewMatrix: Matrix;
  106491. /**
  106492. * Get the default VRMetrics based on the most generic setup.
  106493. * @returns the default vr metrics
  106494. */
  106495. static GetDefault(): VRCameraMetrics;
  106496. }
  106497. }
  106498. declare module BABYLON {
  106499. /** @hidden */
  106500. export var vrDistortionCorrectionPixelShader: {
  106501. name: string;
  106502. shader: string;
  106503. };
  106504. }
  106505. declare module BABYLON {
  106506. /**
  106507. * VRDistortionCorrectionPostProcess used for mobile VR
  106508. */
  106509. export class VRDistortionCorrectionPostProcess extends PostProcess {
  106510. private _isRightEye;
  106511. private _distortionFactors;
  106512. private _postProcessScaleFactor;
  106513. private _lensCenterOffset;
  106514. private _scaleIn;
  106515. private _scaleFactor;
  106516. private _lensCenter;
  106517. /**
  106518. * Initializes the VRDistortionCorrectionPostProcess
  106519. * @param name The name of the effect.
  106520. * @param camera The camera to apply the render pass to.
  106521. * @param isRightEye If this is for the right eye distortion
  106522. * @param vrMetrics All the required metrics for the VR camera
  106523. */
  106524. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  106525. }
  106526. }
  106527. declare module BABYLON {
  106528. /**
  106529. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  106530. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106531. */
  106532. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  106533. /**
  106534. * Creates a new VRDeviceOrientationArcRotateCamera
  106535. * @param name defines camera name
  106536. * @param alpha defines the camera rotation along the logitudinal axis
  106537. * @param beta defines the camera rotation along the latitudinal axis
  106538. * @param radius defines the camera distance from its target
  106539. * @param target defines the camera target
  106540. * @param scene defines the scene the camera belongs to
  106541. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106542. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106543. */
  106544. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106545. /**
  106546. * Gets camera class name
  106547. * @returns VRDeviceOrientationArcRotateCamera
  106548. */
  106549. getClassName(): string;
  106550. }
  106551. }
  106552. declare module BABYLON {
  106553. /**
  106554. * Camera used to simulate VR rendering (based on FreeCamera)
  106555. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106556. */
  106557. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  106558. /**
  106559. * Creates a new VRDeviceOrientationFreeCamera
  106560. * @param name defines camera name
  106561. * @param position defines the start position of the camera
  106562. * @param scene defines the scene the camera belongs to
  106563. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106564. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106565. */
  106566. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106567. /**
  106568. * Gets camera class name
  106569. * @returns VRDeviceOrientationFreeCamera
  106570. */
  106571. getClassName(): string;
  106572. }
  106573. }
  106574. declare module BABYLON {
  106575. /**
  106576. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  106577. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106578. */
  106579. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  106580. /**
  106581. * Creates a new VRDeviceOrientationGamepadCamera
  106582. * @param name defines camera name
  106583. * @param position defines the start position of the camera
  106584. * @param scene defines the scene the camera belongs to
  106585. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106586. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106587. */
  106588. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106589. /**
  106590. * Gets camera class name
  106591. * @returns VRDeviceOrientationGamepadCamera
  106592. */
  106593. getClassName(): string;
  106594. }
  106595. }
  106596. declare module BABYLON {
  106597. /**
  106598. * Base class of materials working in push mode in babylon JS
  106599. * @hidden
  106600. */
  106601. export class PushMaterial extends Material {
  106602. protected _activeEffect: Effect;
  106603. protected _normalMatrix: Matrix;
  106604. /**
  106605. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  106606. * This means that the material can keep using a previous shader while a new one is being compiled.
  106607. * This is mostly used when shader parallel compilation is supported (true by default)
  106608. */
  106609. allowShaderHotSwapping: boolean;
  106610. constructor(name: string, scene: Scene);
  106611. getEffect(): Effect;
  106612. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  106613. /**
  106614. * Binds the given world matrix to the active effect
  106615. *
  106616. * @param world the matrix to bind
  106617. */
  106618. bindOnlyWorldMatrix(world: Matrix): void;
  106619. /**
  106620. * Binds the given normal matrix to the active effect
  106621. *
  106622. * @param normalMatrix the matrix to bind
  106623. */
  106624. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  106625. bind(world: Matrix, mesh?: Mesh): void;
  106626. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  106627. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  106628. }
  106629. }
  106630. declare module BABYLON {
  106631. /**
  106632. * This groups all the flags used to control the materials channel.
  106633. */
  106634. export class MaterialFlags {
  106635. private static _DiffuseTextureEnabled;
  106636. /**
  106637. * Are diffuse textures enabled in the application.
  106638. */
  106639. static DiffuseTextureEnabled: boolean;
  106640. private static _AmbientTextureEnabled;
  106641. /**
  106642. * Are ambient textures enabled in the application.
  106643. */
  106644. static AmbientTextureEnabled: boolean;
  106645. private static _OpacityTextureEnabled;
  106646. /**
  106647. * Are opacity textures enabled in the application.
  106648. */
  106649. static OpacityTextureEnabled: boolean;
  106650. private static _ReflectionTextureEnabled;
  106651. /**
  106652. * Are reflection textures enabled in the application.
  106653. */
  106654. static ReflectionTextureEnabled: boolean;
  106655. private static _EmissiveTextureEnabled;
  106656. /**
  106657. * Are emissive textures enabled in the application.
  106658. */
  106659. static EmissiveTextureEnabled: boolean;
  106660. private static _SpecularTextureEnabled;
  106661. /**
  106662. * Are specular textures enabled in the application.
  106663. */
  106664. static SpecularTextureEnabled: boolean;
  106665. private static _BumpTextureEnabled;
  106666. /**
  106667. * Are bump textures enabled in the application.
  106668. */
  106669. static BumpTextureEnabled: boolean;
  106670. private static _LightmapTextureEnabled;
  106671. /**
  106672. * Are lightmap textures enabled in the application.
  106673. */
  106674. static LightmapTextureEnabled: boolean;
  106675. private static _RefractionTextureEnabled;
  106676. /**
  106677. * Are refraction textures enabled in the application.
  106678. */
  106679. static RefractionTextureEnabled: boolean;
  106680. private static _ColorGradingTextureEnabled;
  106681. /**
  106682. * Are color grading textures enabled in the application.
  106683. */
  106684. static ColorGradingTextureEnabled: boolean;
  106685. private static _FresnelEnabled;
  106686. /**
  106687. * Are fresnels enabled in the application.
  106688. */
  106689. static FresnelEnabled: boolean;
  106690. private static _ClearCoatTextureEnabled;
  106691. /**
  106692. * Are clear coat textures enabled in the application.
  106693. */
  106694. static ClearCoatTextureEnabled: boolean;
  106695. private static _ClearCoatBumpTextureEnabled;
  106696. /**
  106697. * Are clear coat bump textures enabled in the application.
  106698. */
  106699. static ClearCoatBumpTextureEnabled: boolean;
  106700. private static _ClearCoatTintTextureEnabled;
  106701. /**
  106702. * Are clear coat tint textures enabled in the application.
  106703. */
  106704. static ClearCoatTintTextureEnabled: boolean;
  106705. private static _SheenTextureEnabled;
  106706. /**
  106707. * Are sheen textures enabled in the application.
  106708. */
  106709. static SheenTextureEnabled: boolean;
  106710. private static _AnisotropicTextureEnabled;
  106711. /**
  106712. * Are anisotropic textures enabled in the application.
  106713. */
  106714. static AnisotropicTextureEnabled: boolean;
  106715. private static _ThicknessTextureEnabled;
  106716. /**
  106717. * Are thickness textures enabled in the application.
  106718. */
  106719. static ThicknessTextureEnabled: boolean;
  106720. }
  106721. }
  106722. declare module BABYLON {
  106723. /** @hidden */
  106724. export var defaultFragmentDeclaration: {
  106725. name: string;
  106726. shader: string;
  106727. };
  106728. }
  106729. declare module BABYLON {
  106730. /** @hidden */
  106731. export var defaultUboDeclaration: {
  106732. name: string;
  106733. shader: string;
  106734. };
  106735. }
  106736. declare module BABYLON {
  106737. /** @hidden */
  106738. export var lightFragmentDeclaration: {
  106739. name: string;
  106740. shader: string;
  106741. };
  106742. }
  106743. declare module BABYLON {
  106744. /** @hidden */
  106745. export var lightUboDeclaration: {
  106746. name: string;
  106747. shader: string;
  106748. };
  106749. }
  106750. declare module BABYLON {
  106751. /** @hidden */
  106752. export var lightsFragmentFunctions: {
  106753. name: string;
  106754. shader: string;
  106755. };
  106756. }
  106757. declare module BABYLON {
  106758. /** @hidden */
  106759. export var shadowsFragmentFunctions: {
  106760. name: string;
  106761. shader: string;
  106762. };
  106763. }
  106764. declare module BABYLON {
  106765. /** @hidden */
  106766. export var fresnelFunction: {
  106767. name: string;
  106768. shader: string;
  106769. };
  106770. }
  106771. declare module BABYLON {
  106772. /** @hidden */
  106773. export var reflectionFunction: {
  106774. name: string;
  106775. shader: string;
  106776. };
  106777. }
  106778. declare module BABYLON {
  106779. /** @hidden */
  106780. export var bumpFragmentFunctions: {
  106781. name: string;
  106782. shader: string;
  106783. };
  106784. }
  106785. declare module BABYLON {
  106786. /** @hidden */
  106787. export var logDepthDeclaration: {
  106788. name: string;
  106789. shader: string;
  106790. };
  106791. }
  106792. declare module BABYLON {
  106793. /** @hidden */
  106794. export var bumpFragment: {
  106795. name: string;
  106796. shader: string;
  106797. };
  106798. }
  106799. declare module BABYLON {
  106800. /** @hidden */
  106801. export var depthPrePass: {
  106802. name: string;
  106803. shader: string;
  106804. };
  106805. }
  106806. declare module BABYLON {
  106807. /** @hidden */
  106808. export var lightFragment: {
  106809. name: string;
  106810. shader: string;
  106811. };
  106812. }
  106813. declare module BABYLON {
  106814. /** @hidden */
  106815. export var logDepthFragment: {
  106816. name: string;
  106817. shader: string;
  106818. };
  106819. }
  106820. declare module BABYLON {
  106821. /** @hidden */
  106822. export var defaultPixelShader: {
  106823. name: string;
  106824. shader: string;
  106825. };
  106826. }
  106827. declare module BABYLON {
  106828. /** @hidden */
  106829. export var defaultVertexDeclaration: {
  106830. name: string;
  106831. shader: string;
  106832. };
  106833. }
  106834. declare module BABYLON {
  106835. /** @hidden */
  106836. export var bumpVertexDeclaration: {
  106837. name: string;
  106838. shader: string;
  106839. };
  106840. }
  106841. declare module BABYLON {
  106842. /** @hidden */
  106843. export var bumpVertex: {
  106844. name: string;
  106845. shader: string;
  106846. };
  106847. }
  106848. declare module BABYLON {
  106849. /** @hidden */
  106850. export var fogVertex: {
  106851. name: string;
  106852. shader: string;
  106853. };
  106854. }
  106855. declare module BABYLON {
  106856. /** @hidden */
  106857. export var shadowsVertex: {
  106858. name: string;
  106859. shader: string;
  106860. };
  106861. }
  106862. declare module BABYLON {
  106863. /** @hidden */
  106864. export var pointCloudVertex: {
  106865. name: string;
  106866. shader: string;
  106867. };
  106868. }
  106869. declare module BABYLON {
  106870. /** @hidden */
  106871. export var logDepthVertex: {
  106872. name: string;
  106873. shader: string;
  106874. };
  106875. }
  106876. declare module BABYLON {
  106877. /** @hidden */
  106878. export var defaultVertexShader: {
  106879. name: string;
  106880. shader: string;
  106881. };
  106882. }
  106883. declare module BABYLON {
  106884. /** @hidden */
  106885. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106886. MAINUV1: boolean;
  106887. MAINUV2: boolean;
  106888. DIFFUSE: boolean;
  106889. DIFFUSEDIRECTUV: number;
  106890. AMBIENT: boolean;
  106891. AMBIENTDIRECTUV: number;
  106892. OPACITY: boolean;
  106893. OPACITYDIRECTUV: number;
  106894. OPACITYRGB: boolean;
  106895. REFLECTION: boolean;
  106896. EMISSIVE: boolean;
  106897. EMISSIVEDIRECTUV: number;
  106898. SPECULAR: boolean;
  106899. SPECULARDIRECTUV: number;
  106900. BUMP: boolean;
  106901. BUMPDIRECTUV: number;
  106902. PARALLAX: boolean;
  106903. PARALLAXOCCLUSION: boolean;
  106904. SPECULAROVERALPHA: boolean;
  106905. CLIPPLANE: boolean;
  106906. CLIPPLANE2: boolean;
  106907. CLIPPLANE3: boolean;
  106908. CLIPPLANE4: boolean;
  106909. ALPHATEST: boolean;
  106910. DEPTHPREPASS: boolean;
  106911. ALPHAFROMDIFFUSE: boolean;
  106912. POINTSIZE: boolean;
  106913. FOG: boolean;
  106914. SPECULARTERM: boolean;
  106915. DIFFUSEFRESNEL: boolean;
  106916. OPACITYFRESNEL: boolean;
  106917. REFLECTIONFRESNEL: boolean;
  106918. REFRACTIONFRESNEL: boolean;
  106919. EMISSIVEFRESNEL: boolean;
  106920. FRESNEL: boolean;
  106921. NORMAL: boolean;
  106922. UV1: boolean;
  106923. UV2: boolean;
  106924. VERTEXCOLOR: boolean;
  106925. VERTEXALPHA: boolean;
  106926. NUM_BONE_INFLUENCERS: number;
  106927. BonesPerMesh: number;
  106928. BONETEXTURE: boolean;
  106929. INSTANCES: boolean;
  106930. GLOSSINESS: boolean;
  106931. ROUGHNESS: boolean;
  106932. EMISSIVEASILLUMINATION: boolean;
  106933. LINKEMISSIVEWITHDIFFUSE: boolean;
  106934. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106935. LIGHTMAP: boolean;
  106936. LIGHTMAPDIRECTUV: number;
  106937. OBJECTSPACE_NORMALMAP: boolean;
  106938. USELIGHTMAPASSHADOWMAP: boolean;
  106939. REFLECTIONMAP_3D: boolean;
  106940. REFLECTIONMAP_SPHERICAL: boolean;
  106941. REFLECTIONMAP_PLANAR: boolean;
  106942. REFLECTIONMAP_CUBIC: boolean;
  106943. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106944. REFLECTIONMAP_PROJECTION: boolean;
  106945. REFLECTIONMAP_SKYBOX: boolean;
  106946. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  106947. REFLECTIONMAP_EXPLICIT: boolean;
  106948. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106949. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106950. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106951. INVERTCUBICMAP: boolean;
  106952. LOGARITHMICDEPTH: boolean;
  106953. REFRACTION: boolean;
  106954. REFRACTIONMAP_3D: boolean;
  106955. REFLECTIONOVERALPHA: boolean;
  106956. TWOSIDEDLIGHTING: boolean;
  106957. SHADOWFLOAT: boolean;
  106958. MORPHTARGETS: boolean;
  106959. MORPHTARGETS_NORMAL: boolean;
  106960. MORPHTARGETS_TANGENT: boolean;
  106961. MORPHTARGETS_UV: boolean;
  106962. NUM_MORPH_INFLUENCERS: number;
  106963. NONUNIFORMSCALING: boolean;
  106964. PREMULTIPLYALPHA: boolean;
  106965. IMAGEPROCESSING: boolean;
  106966. VIGNETTE: boolean;
  106967. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106968. VIGNETTEBLENDMODEOPAQUE: boolean;
  106969. TONEMAPPING: boolean;
  106970. TONEMAPPING_ACES: boolean;
  106971. CONTRAST: boolean;
  106972. COLORCURVES: boolean;
  106973. COLORGRADING: boolean;
  106974. COLORGRADING3D: boolean;
  106975. SAMPLER3DGREENDEPTH: boolean;
  106976. SAMPLER3DBGRMAP: boolean;
  106977. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106978. MULTIVIEW: boolean;
  106979. /**
  106980. * If the reflection texture on this material is in linear color space
  106981. * @hidden
  106982. */
  106983. IS_REFLECTION_LINEAR: boolean;
  106984. /**
  106985. * If the refraction texture on this material is in linear color space
  106986. * @hidden
  106987. */
  106988. IS_REFRACTION_LINEAR: boolean;
  106989. EXPOSURE: boolean;
  106990. constructor();
  106991. setReflectionMode(modeToEnable: string): void;
  106992. }
  106993. /**
  106994. * This is the default material used in Babylon. It is the best trade off between quality
  106995. * and performances.
  106996. * @see http://doc.babylonjs.com/babylon101/materials
  106997. */
  106998. export class StandardMaterial extends PushMaterial {
  106999. private _diffuseTexture;
  107000. /**
  107001. * The basic texture of the material as viewed under a light.
  107002. */
  107003. diffuseTexture: Nullable<BaseTexture>;
  107004. private _ambientTexture;
  107005. /**
  107006. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107007. */
  107008. ambientTexture: Nullable<BaseTexture>;
  107009. private _opacityTexture;
  107010. /**
  107011. * Define the transparency of the material from a texture.
  107012. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107013. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107014. */
  107015. opacityTexture: Nullable<BaseTexture>;
  107016. private _reflectionTexture;
  107017. /**
  107018. * Define the texture used to display the reflection.
  107019. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107020. */
  107021. reflectionTexture: Nullable<BaseTexture>;
  107022. private _emissiveTexture;
  107023. /**
  107024. * Define texture of the material as if self lit.
  107025. * This will be mixed in the final result even in the absence of light.
  107026. */
  107027. emissiveTexture: Nullable<BaseTexture>;
  107028. private _specularTexture;
  107029. /**
  107030. * Define how the color and intensity of the highlight given by the light in the material.
  107031. */
  107032. specularTexture: Nullable<BaseTexture>;
  107033. private _bumpTexture;
  107034. /**
  107035. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107036. * 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.
  107037. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107038. */
  107039. bumpTexture: Nullable<BaseTexture>;
  107040. private _lightmapTexture;
  107041. /**
  107042. * Complex lighting can be computationally expensive to compute at runtime.
  107043. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107044. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107045. */
  107046. lightmapTexture: Nullable<BaseTexture>;
  107047. private _refractionTexture;
  107048. /**
  107049. * Define the texture used to display the refraction.
  107050. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107051. */
  107052. refractionTexture: Nullable<BaseTexture>;
  107053. /**
  107054. * The color of the material lit by the environmental background lighting.
  107055. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107056. */
  107057. ambientColor: Color3;
  107058. /**
  107059. * The basic color of the material as viewed under a light.
  107060. */
  107061. diffuseColor: Color3;
  107062. /**
  107063. * Define how the color and intensity of the highlight given by the light in the material.
  107064. */
  107065. specularColor: Color3;
  107066. /**
  107067. * Define the color of the material as if self lit.
  107068. * This will be mixed in the final result even in the absence of light.
  107069. */
  107070. emissiveColor: Color3;
  107071. /**
  107072. * Defines how sharp are the highlights in the material.
  107073. * The bigger the value the sharper giving a more glossy feeling to the result.
  107074. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107075. */
  107076. specularPower: number;
  107077. private _useAlphaFromDiffuseTexture;
  107078. /**
  107079. * Does the transparency come from the diffuse texture alpha channel.
  107080. */
  107081. useAlphaFromDiffuseTexture: boolean;
  107082. private _useEmissiveAsIllumination;
  107083. /**
  107084. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107085. */
  107086. useEmissiveAsIllumination: boolean;
  107087. private _linkEmissiveWithDiffuse;
  107088. /**
  107089. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107090. * the emissive level when the final color is close to one.
  107091. */
  107092. linkEmissiveWithDiffuse: boolean;
  107093. private _useSpecularOverAlpha;
  107094. /**
  107095. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107096. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107097. */
  107098. useSpecularOverAlpha: boolean;
  107099. private _useReflectionOverAlpha;
  107100. /**
  107101. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107102. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107103. */
  107104. useReflectionOverAlpha: boolean;
  107105. private _disableLighting;
  107106. /**
  107107. * Does lights from the scene impacts this material.
  107108. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107109. */
  107110. disableLighting: boolean;
  107111. private _useObjectSpaceNormalMap;
  107112. /**
  107113. * Allows using an object space normal map (instead of tangent space).
  107114. */
  107115. useObjectSpaceNormalMap: boolean;
  107116. private _useParallax;
  107117. /**
  107118. * Is parallax enabled or not.
  107119. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107120. */
  107121. useParallax: boolean;
  107122. private _useParallaxOcclusion;
  107123. /**
  107124. * Is parallax occlusion enabled or not.
  107125. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107126. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107127. */
  107128. useParallaxOcclusion: boolean;
  107129. /**
  107130. * 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.
  107131. */
  107132. parallaxScaleBias: number;
  107133. private _roughness;
  107134. /**
  107135. * Helps to define how blurry the reflections should appears in the material.
  107136. */
  107137. roughness: number;
  107138. /**
  107139. * In case of refraction, define the value of the index of refraction.
  107140. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107141. */
  107142. indexOfRefraction: number;
  107143. /**
  107144. * Invert the refraction texture alongside the y axis.
  107145. * It can be useful with procedural textures or probe for instance.
  107146. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107147. */
  107148. invertRefractionY: boolean;
  107149. /**
  107150. * Defines the alpha limits in alpha test mode.
  107151. */
  107152. alphaCutOff: number;
  107153. private _useLightmapAsShadowmap;
  107154. /**
  107155. * In case of light mapping, define whether the map contains light or shadow informations.
  107156. */
  107157. useLightmapAsShadowmap: boolean;
  107158. private _diffuseFresnelParameters;
  107159. /**
  107160. * Define the diffuse fresnel parameters of the material.
  107161. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107162. */
  107163. diffuseFresnelParameters: FresnelParameters;
  107164. private _opacityFresnelParameters;
  107165. /**
  107166. * Define the opacity fresnel parameters of the material.
  107167. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107168. */
  107169. opacityFresnelParameters: FresnelParameters;
  107170. private _reflectionFresnelParameters;
  107171. /**
  107172. * Define the reflection fresnel parameters of the material.
  107173. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107174. */
  107175. reflectionFresnelParameters: FresnelParameters;
  107176. private _refractionFresnelParameters;
  107177. /**
  107178. * Define the refraction fresnel parameters of the material.
  107179. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107180. */
  107181. refractionFresnelParameters: FresnelParameters;
  107182. private _emissiveFresnelParameters;
  107183. /**
  107184. * Define the emissive fresnel parameters of the material.
  107185. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107186. */
  107187. emissiveFresnelParameters: FresnelParameters;
  107188. private _useReflectionFresnelFromSpecular;
  107189. /**
  107190. * If true automatically deducts the fresnels values from the material specularity.
  107191. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107192. */
  107193. useReflectionFresnelFromSpecular: boolean;
  107194. private _useGlossinessFromSpecularMapAlpha;
  107195. /**
  107196. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107197. */
  107198. useGlossinessFromSpecularMapAlpha: boolean;
  107199. private _maxSimultaneousLights;
  107200. /**
  107201. * Defines the maximum number of lights that can be used in the material
  107202. */
  107203. maxSimultaneousLights: number;
  107204. private _invertNormalMapX;
  107205. /**
  107206. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107207. */
  107208. invertNormalMapX: boolean;
  107209. private _invertNormalMapY;
  107210. /**
  107211. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107212. */
  107213. invertNormalMapY: boolean;
  107214. private _twoSidedLighting;
  107215. /**
  107216. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107217. */
  107218. twoSidedLighting: boolean;
  107219. /**
  107220. * Default configuration related to image processing available in the standard Material.
  107221. */
  107222. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107223. /**
  107224. * Gets the image processing configuration used either in this material.
  107225. */
  107226. /**
  107227. * Sets the Default image processing configuration used either in the this material.
  107228. *
  107229. * If sets to null, the scene one is in use.
  107230. */
  107231. imageProcessingConfiguration: ImageProcessingConfiguration;
  107232. /**
  107233. * Keep track of the image processing observer to allow dispose and replace.
  107234. */
  107235. private _imageProcessingObserver;
  107236. /**
  107237. * Attaches a new image processing configuration to the Standard Material.
  107238. * @param configuration
  107239. */
  107240. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107241. /**
  107242. * Gets wether the color curves effect is enabled.
  107243. */
  107244. /**
  107245. * Sets wether the color curves effect is enabled.
  107246. */
  107247. cameraColorCurvesEnabled: boolean;
  107248. /**
  107249. * Gets wether the color grading effect is enabled.
  107250. */
  107251. /**
  107252. * Gets wether the color grading effect is enabled.
  107253. */
  107254. cameraColorGradingEnabled: boolean;
  107255. /**
  107256. * Gets wether tonemapping is enabled or not.
  107257. */
  107258. /**
  107259. * Sets wether tonemapping is enabled or not
  107260. */
  107261. cameraToneMappingEnabled: boolean;
  107262. /**
  107263. * The camera exposure used on this material.
  107264. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107265. * This corresponds to a photographic exposure.
  107266. */
  107267. /**
  107268. * The camera exposure used on this material.
  107269. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107270. * This corresponds to a photographic exposure.
  107271. */
  107272. cameraExposure: number;
  107273. /**
  107274. * Gets The camera contrast used on this material.
  107275. */
  107276. /**
  107277. * Sets The camera contrast used on this material.
  107278. */
  107279. cameraContrast: number;
  107280. /**
  107281. * Gets the Color Grading 2D Lookup Texture.
  107282. */
  107283. /**
  107284. * Sets the Color Grading 2D Lookup Texture.
  107285. */
  107286. cameraColorGradingTexture: Nullable<BaseTexture>;
  107287. /**
  107288. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107289. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107290. * 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;
  107291. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107292. */
  107293. /**
  107294. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107295. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107296. * 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;
  107297. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107298. */
  107299. cameraColorCurves: Nullable<ColorCurves>;
  107300. /**
  107301. * Custom callback helping to override the default shader used in the material.
  107302. */
  107303. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  107304. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107305. protected _worldViewProjectionMatrix: Matrix;
  107306. protected _globalAmbientColor: Color3;
  107307. protected _useLogarithmicDepth: boolean;
  107308. protected _rebuildInParallel: boolean;
  107309. /**
  107310. * Instantiates a new standard material.
  107311. * This is the default material used in Babylon. It is the best trade off between quality
  107312. * and performances.
  107313. * @see http://doc.babylonjs.com/babylon101/materials
  107314. * @param name Define the name of the material in the scene
  107315. * @param scene Define the scene the material belong to
  107316. */
  107317. constructor(name: string, scene: Scene);
  107318. /**
  107319. * Gets a boolean indicating that current material needs to register RTT
  107320. */
  107321. readonly hasRenderTargetTextures: boolean;
  107322. /**
  107323. * Gets the current class name of the material e.g. "StandardMaterial"
  107324. * Mainly use in serialization.
  107325. * @returns the class name
  107326. */
  107327. getClassName(): string;
  107328. /**
  107329. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107330. * You can try switching to logarithmic depth.
  107331. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107332. */
  107333. useLogarithmicDepth: boolean;
  107334. /**
  107335. * Specifies if the material will require alpha blending
  107336. * @returns a boolean specifying if alpha blending is needed
  107337. */
  107338. needAlphaBlending(): boolean;
  107339. /**
  107340. * Specifies if this material should be rendered in alpha test mode
  107341. * @returns a boolean specifying if an alpha test is needed.
  107342. */
  107343. needAlphaTesting(): boolean;
  107344. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107345. /**
  107346. * Get the texture used for alpha test purpose.
  107347. * @returns the diffuse texture in case of the standard material.
  107348. */
  107349. getAlphaTestTexture(): Nullable<BaseTexture>;
  107350. /**
  107351. * Get if the submesh is ready to be used and all its information available.
  107352. * Child classes can use it to update shaders
  107353. * @param mesh defines the mesh to check
  107354. * @param subMesh defines which submesh to check
  107355. * @param useInstances specifies that instances should be used
  107356. * @returns a boolean indicating that the submesh is ready or not
  107357. */
  107358. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107359. /**
  107360. * Builds the material UBO layouts.
  107361. * Used internally during the effect preparation.
  107362. */
  107363. buildUniformLayout(): void;
  107364. /**
  107365. * Unbinds the material from the mesh
  107366. */
  107367. unbind(): void;
  107368. /**
  107369. * Binds the submesh to this material by preparing the effect and shader to draw
  107370. * @param world defines the world transformation matrix
  107371. * @param mesh defines the mesh containing the submesh
  107372. * @param subMesh defines the submesh to bind the material to
  107373. */
  107374. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107375. /**
  107376. * Get the list of animatables in the material.
  107377. * @returns the list of animatables object used in the material
  107378. */
  107379. getAnimatables(): IAnimatable[];
  107380. /**
  107381. * Gets the active textures from the material
  107382. * @returns an array of textures
  107383. */
  107384. getActiveTextures(): BaseTexture[];
  107385. /**
  107386. * Specifies if the material uses a texture
  107387. * @param texture defines the texture to check against the material
  107388. * @returns a boolean specifying if the material uses the texture
  107389. */
  107390. hasTexture(texture: BaseTexture): boolean;
  107391. /**
  107392. * Disposes the material
  107393. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107394. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107395. */
  107396. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107397. /**
  107398. * Makes a duplicate of the material, and gives it a new name
  107399. * @param name defines the new name for the duplicated material
  107400. * @returns the cloned material
  107401. */
  107402. clone(name: string): StandardMaterial;
  107403. /**
  107404. * Serializes this material in a JSON representation
  107405. * @returns the serialized material object
  107406. */
  107407. serialize(): any;
  107408. /**
  107409. * Creates a standard material from parsed material data
  107410. * @param source defines the JSON representation of the material
  107411. * @param scene defines the hosting scene
  107412. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107413. * @returns a new standard material
  107414. */
  107415. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107416. /**
  107417. * Are diffuse textures enabled in the application.
  107418. */
  107419. static DiffuseTextureEnabled: boolean;
  107420. /**
  107421. * Are ambient textures enabled in the application.
  107422. */
  107423. static AmbientTextureEnabled: boolean;
  107424. /**
  107425. * Are opacity textures enabled in the application.
  107426. */
  107427. static OpacityTextureEnabled: boolean;
  107428. /**
  107429. * Are reflection textures enabled in the application.
  107430. */
  107431. static ReflectionTextureEnabled: boolean;
  107432. /**
  107433. * Are emissive textures enabled in the application.
  107434. */
  107435. static EmissiveTextureEnabled: boolean;
  107436. /**
  107437. * Are specular textures enabled in the application.
  107438. */
  107439. static SpecularTextureEnabled: boolean;
  107440. /**
  107441. * Are bump textures enabled in the application.
  107442. */
  107443. static BumpTextureEnabled: boolean;
  107444. /**
  107445. * Are lightmap textures enabled in the application.
  107446. */
  107447. static LightmapTextureEnabled: boolean;
  107448. /**
  107449. * Are refraction textures enabled in the application.
  107450. */
  107451. static RefractionTextureEnabled: boolean;
  107452. /**
  107453. * Are color grading textures enabled in the application.
  107454. */
  107455. static ColorGradingTextureEnabled: boolean;
  107456. /**
  107457. * Are fresnels enabled in the application.
  107458. */
  107459. static FresnelEnabled: boolean;
  107460. }
  107461. }
  107462. declare module BABYLON {
  107463. /** @hidden */
  107464. export var imageProcessingPixelShader: {
  107465. name: string;
  107466. shader: string;
  107467. };
  107468. }
  107469. declare module BABYLON {
  107470. /**
  107471. * ImageProcessingPostProcess
  107472. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  107473. */
  107474. export class ImageProcessingPostProcess extends PostProcess {
  107475. /**
  107476. * Default configuration related to image processing available in the PBR Material.
  107477. */
  107478. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107479. /**
  107480. * Gets the image processing configuration used either in this material.
  107481. */
  107482. /**
  107483. * Sets the Default image processing configuration used either in the this material.
  107484. *
  107485. * If sets to null, the scene one is in use.
  107486. */
  107487. imageProcessingConfiguration: ImageProcessingConfiguration;
  107488. /**
  107489. * Keep track of the image processing observer to allow dispose and replace.
  107490. */
  107491. private _imageProcessingObserver;
  107492. /**
  107493. * Attaches a new image processing configuration to the PBR Material.
  107494. * @param configuration
  107495. */
  107496. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  107497. /**
  107498. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107499. */
  107500. /**
  107501. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107502. */
  107503. colorCurves: Nullable<ColorCurves>;
  107504. /**
  107505. * Gets wether the color curves effect is enabled.
  107506. */
  107507. /**
  107508. * Sets wether the color curves effect is enabled.
  107509. */
  107510. colorCurvesEnabled: boolean;
  107511. /**
  107512. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107513. */
  107514. /**
  107515. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107516. */
  107517. colorGradingTexture: Nullable<BaseTexture>;
  107518. /**
  107519. * Gets wether the color grading effect is enabled.
  107520. */
  107521. /**
  107522. * Gets wether the color grading effect is enabled.
  107523. */
  107524. colorGradingEnabled: boolean;
  107525. /**
  107526. * Gets exposure used in the effect.
  107527. */
  107528. /**
  107529. * Sets exposure used in the effect.
  107530. */
  107531. exposure: number;
  107532. /**
  107533. * Gets wether tonemapping is enabled or not.
  107534. */
  107535. /**
  107536. * Sets wether tonemapping is enabled or not
  107537. */
  107538. toneMappingEnabled: boolean;
  107539. /**
  107540. * Gets the type of tone mapping effect.
  107541. */
  107542. /**
  107543. * Sets the type of tone mapping effect.
  107544. */
  107545. toneMappingType: number;
  107546. /**
  107547. * Gets contrast used in the effect.
  107548. */
  107549. /**
  107550. * Sets contrast used in the effect.
  107551. */
  107552. contrast: number;
  107553. /**
  107554. * Gets Vignette stretch size.
  107555. */
  107556. /**
  107557. * Sets Vignette stretch size.
  107558. */
  107559. vignetteStretch: number;
  107560. /**
  107561. * Gets Vignette centre X Offset.
  107562. */
  107563. /**
  107564. * Sets Vignette centre X Offset.
  107565. */
  107566. vignetteCentreX: number;
  107567. /**
  107568. * Gets Vignette centre Y Offset.
  107569. */
  107570. /**
  107571. * Sets Vignette centre Y Offset.
  107572. */
  107573. vignetteCentreY: number;
  107574. /**
  107575. * Gets Vignette weight or intensity of the vignette effect.
  107576. */
  107577. /**
  107578. * Sets Vignette weight or intensity of the vignette effect.
  107579. */
  107580. vignetteWeight: number;
  107581. /**
  107582. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107583. * if vignetteEnabled is set to true.
  107584. */
  107585. /**
  107586. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107587. * if vignetteEnabled is set to true.
  107588. */
  107589. vignetteColor: Color4;
  107590. /**
  107591. * Gets Camera field of view used by the Vignette effect.
  107592. */
  107593. /**
  107594. * Sets Camera field of view used by the Vignette effect.
  107595. */
  107596. vignetteCameraFov: number;
  107597. /**
  107598. * Gets the vignette blend mode allowing different kind of effect.
  107599. */
  107600. /**
  107601. * Sets the vignette blend mode allowing different kind of effect.
  107602. */
  107603. vignetteBlendMode: number;
  107604. /**
  107605. * Gets wether the vignette effect is enabled.
  107606. */
  107607. /**
  107608. * Sets wether the vignette effect is enabled.
  107609. */
  107610. vignetteEnabled: boolean;
  107611. private _fromLinearSpace;
  107612. /**
  107613. * Gets wether the input of the processing is in Gamma or Linear Space.
  107614. */
  107615. /**
  107616. * Sets wether the input of the processing is in Gamma or Linear Space.
  107617. */
  107618. fromLinearSpace: boolean;
  107619. /**
  107620. * Defines cache preventing GC.
  107621. */
  107622. private _defines;
  107623. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  107624. /**
  107625. * "ImageProcessingPostProcess"
  107626. * @returns "ImageProcessingPostProcess"
  107627. */
  107628. getClassName(): string;
  107629. protected _updateParameters(): void;
  107630. dispose(camera?: Camera): void;
  107631. }
  107632. }
  107633. declare module BABYLON {
  107634. /**
  107635. * Class containing static functions to help procedurally build meshes
  107636. */
  107637. export class GroundBuilder {
  107638. /**
  107639. * Creates a ground mesh
  107640. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107641. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107643. * @param name defines the name of the mesh
  107644. * @param options defines the options used to create the mesh
  107645. * @param scene defines the hosting scene
  107646. * @returns the ground mesh
  107647. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107648. */
  107649. static CreateGround(name: string, options: {
  107650. width?: number;
  107651. height?: number;
  107652. subdivisions?: number;
  107653. subdivisionsX?: number;
  107654. subdivisionsY?: number;
  107655. updatable?: boolean;
  107656. }, scene: any): Mesh;
  107657. /**
  107658. * Creates a tiled ground mesh
  107659. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107660. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107661. * * 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
  107662. * * 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
  107663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107664. * @param name defines the name of the mesh
  107665. * @param options defines the options used to create the mesh
  107666. * @param scene defines the hosting scene
  107667. * @returns the tiled ground mesh
  107668. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107669. */
  107670. static CreateTiledGround(name: string, options: {
  107671. xmin: number;
  107672. zmin: number;
  107673. xmax: number;
  107674. zmax: number;
  107675. subdivisions?: {
  107676. w: number;
  107677. h: number;
  107678. };
  107679. precision?: {
  107680. w: number;
  107681. h: number;
  107682. };
  107683. updatable?: boolean;
  107684. }, scene?: Nullable<Scene>): Mesh;
  107685. /**
  107686. * Creates a ground mesh from a height map
  107687. * * The parameter `url` sets the URL of the height map image resource.
  107688. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107689. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107690. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107691. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107692. * * 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.
  107693. * * 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).
  107694. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107696. * @param name defines the name of the mesh
  107697. * @param url defines the url to the height map
  107698. * @param options defines the options used to create the mesh
  107699. * @param scene defines the hosting scene
  107700. * @returns the ground mesh
  107701. * @see https://doc.babylonjs.com/babylon101/height_map
  107702. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107703. */
  107704. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107705. width?: number;
  107706. height?: number;
  107707. subdivisions?: number;
  107708. minHeight?: number;
  107709. maxHeight?: number;
  107710. colorFilter?: Color3;
  107711. alphaFilter?: number;
  107712. updatable?: boolean;
  107713. onReady?: (mesh: GroundMesh) => void;
  107714. }, scene?: Nullable<Scene>): GroundMesh;
  107715. }
  107716. }
  107717. declare module BABYLON {
  107718. /**
  107719. * Class containing static functions to help procedurally build meshes
  107720. */
  107721. export class TorusBuilder {
  107722. /**
  107723. * Creates a torus mesh
  107724. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107725. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107726. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107728. * * 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
  107729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107730. * @param name defines the name of the mesh
  107731. * @param options defines the options used to create the mesh
  107732. * @param scene defines the hosting scene
  107733. * @returns the torus mesh
  107734. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107735. */
  107736. static CreateTorus(name: string, options: {
  107737. diameter?: number;
  107738. thickness?: number;
  107739. tessellation?: number;
  107740. updatable?: boolean;
  107741. sideOrientation?: number;
  107742. frontUVs?: Vector4;
  107743. backUVs?: Vector4;
  107744. }, scene: any): Mesh;
  107745. }
  107746. }
  107747. declare module BABYLON {
  107748. /**
  107749. * Class containing static functions to help procedurally build meshes
  107750. */
  107751. export class CylinderBuilder {
  107752. /**
  107753. * Creates a cylinder or a cone mesh
  107754. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107755. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107756. * * 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.
  107757. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107758. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107759. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107760. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107761. * * 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).
  107762. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107763. * * 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).
  107764. * * 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
  107765. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107766. * * 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
  107767. * * 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.
  107768. * * If `enclose` is false, a ring surface is one element.
  107769. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107770. * * 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
  107771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107772. * * 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
  107773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107774. * @param name defines the name of the mesh
  107775. * @param options defines the options used to create the mesh
  107776. * @param scene defines the hosting scene
  107777. * @returns the cylinder mesh
  107778. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107779. */
  107780. static CreateCylinder(name: string, options: {
  107781. height?: number;
  107782. diameterTop?: number;
  107783. diameterBottom?: number;
  107784. diameter?: number;
  107785. tessellation?: number;
  107786. subdivisions?: number;
  107787. arc?: number;
  107788. faceColors?: Color4[];
  107789. faceUV?: Vector4[];
  107790. updatable?: boolean;
  107791. hasRings?: boolean;
  107792. enclose?: boolean;
  107793. cap?: number;
  107794. sideOrientation?: number;
  107795. frontUVs?: Vector4;
  107796. backUVs?: Vector4;
  107797. }, scene: any): Mesh;
  107798. }
  107799. }
  107800. declare module BABYLON {
  107801. /**
  107802. * Options to modify the vr teleportation behavior.
  107803. */
  107804. export interface VRTeleportationOptions {
  107805. /**
  107806. * The name of the mesh which should be used as the teleportation floor. (default: null)
  107807. */
  107808. floorMeshName?: string;
  107809. /**
  107810. * A list of meshes to be used as the teleportation floor. (default: empty)
  107811. */
  107812. floorMeshes?: Mesh[];
  107813. }
  107814. /**
  107815. * Options to modify the vr experience helper's behavior.
  107816. */
  107817. export interface VRExperienceHelperOptions extends WebVROptions {
  107818. /**
  107819. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  107820. */
  107821. createDeviceOrientationCamera?: boolean;
  107822. /**
  107823. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  107824. */
  107825. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  107826. /**
  107827. * Uses the main button on the controller to toggle the laser casted. (default: true)
  107828. */
  107829. laserToggle?: boolean;
  107830. /**
  107831. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  107832. */
  107833. floorMeshes?: Mesh[];
  107834. /**
  107835. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  107836. */
  107837. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  107838. }
  107839. /**
  107840. * Event containing information after VR has been entered
  107841. */
  107842. export class OnAfterEnteringVRObservableEvent {
  107843. /**
  107844. * If entering vr was successful
  107845. */
  107846. success: boolean;
  107847. }
  107848. /**
  107849. * Helps to quickly add VR support to an existing scene.
  107850. * See http://doc.babylonjs.com/how_to/webvr_helper
  107851. */
  107852. export class VRExperienceHelper {
  107853. /** Options to modify the vr experience helper's behavior. */
  107854. webVROptions: VRExperienceHelperOptions;
  107855. private _scene;
  107856. private _position;
  107857. private _btnVR;
  107858. private _btnVRDisplayed;
  107859. private _webVRsupported;
  107860. private _webVRready;
  107861. private _webVRrequesting;
  107862. private _webVRpresenting;
  107863. private _hasEnteredVR;
  107864. private _fullscreenVRpresenting;
  107865. private _canvas;
  107866. private _webVRCamera;
  107867. private _vrDeviceOrientationCamera;
  107868. private _deviceOrientationCamera;
  107869. private _existingCamera;
  107870. private _onKeyDown;
  107871. private _onVrDisplayPresentChange;
  107872. private _onVRDisplayChanged;
  107873. private _onVRRequestPresentStart;
  107874. private _onVRRequestPresentComplete;
  107875. /**
  107876. * 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)
  107877. */
  107878. enableGazeEvenWhenNoPointerLock: boolean;
  107879. /**
  107880. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  107881. */
  107882. exitVROnDoubleTap: boolean;
  107883. /**
  107884. * Observable raised right before entering VR.
  107885. */
  107886. onEnteringVRObservable: Observable<VRExperienceHelper>;
  107887. /**
  107888. * Observable raised when entering VR has completed.
  107889. */
  107890. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  107891. /**
  107892. * Observable raised when exiting VR.
  107893. */
  107894. onExitingVRObservable: Observable<VRExperienceHelper>;
  107895. /**
  107896. * Observable raised when controller mesh is loaded.
  107897. */
  107898. onControllerMeshLoadedObservable: Observable<WebVRController>;
  107899. /** Return this.onEnteringVRObservable
  107900. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  107901. */
  107902. readonly onEnteringVR: Observable<VRExperienceHelper>;
  107903. /** Return this.onExitingVRObservable
  107904. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  107905. */
  107906. readonly onExitingVR: Observable<VRExperienceHelper>;
  107907. /** Return this.onControllerMeshLoadedObservable
  107908. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  107909. */
  107910. readonly onControllerMeshLoaded: Observable<WebVRController>;
  107911. private _rayLength;
  107912. private _useCustomVRButton;
  107913. private _teleportationRequested;
  107914. private _teleportActive;
  107915. private _floorMeshName;
  107916. private _floorMeshesCollection;
  107917. private _rotationAllowed;
  107918. private _teleportBackwardsVector;
  107919. private _teleportationTarget;
  107920. private _isDefaultTeleportationTarget;
  107921. private _postProcessMove;
  107922. private _teleportationFillColor;
  107923. private _teleportationBorderColor;
  107924. private _rotationAngle;
  107925. private _haloCenter;
  107926. private _cameraGazer;
  107927. private _padSensibilityUp;
  107928. private _padSensibilityDown;
  107929. private _leftController;
  107930. private _rightController;
  107931. /**
  107932. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  107933. */
  107934. onNewMeshSelected: Observable<AbstractMesh>;
  107935. /**
  107936. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  107937. * This observable will provide the mesh and the controller used to select the mesh
  107938. */
  107939. onMeshSelectedWithController: Observable<{
  107940. mesh: AbstractMesh;
  107941. controller: WebVRController;
  107942. }>;
  107943. /**
  107944. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  107945. */
  107946. onNewMeshPicked: Observable<PickingInfo>;
  107947. private _circleEase;
  107948. /**
  107949. * Observable raised before camera teleportation
  107950. */
  107951. onBeforeCameraTeleport: Observable<Vector3>;
  107952. /**
  107953. * Observable raised after camera teleportation
  107954. */
  107955. onAfterCameraTeleport: Observable<Vector3>;
  107956. /**
  107957. * Observable raised when current selected mesh gets unselected
  107958. */
  107959. onSelectedMeshUnselected: Observable<AbstractMesh>;
  107960. private _raySelectionPredicate;
  107961. /**
  107962. * To be optionaly changed by user to define custom ray selection
  107963. */
  107964. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  107965. /**
  107966. * To be optionaly changed by user to define custom selection logic (after ray selection)
  107967. */
  107968. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107969. /**
  107970. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  107971. */
  107972. teleportationEnabled: boolean;
  107973. private _defaultHeight;
  107974. private _teleportationInitialized;
  107975. private _interactionsEnabled;
  107976. private _interactionsRequested;
  107977. private _displayGaze;
  107978. private _displayLaserPointer;
  107979. /**
  107980. * The mesh used to display where the user is going to teleport.
  107981. */
  107982. /**
  107983. * Sets the mesh to be used to display where the user is going to teleport.
  107984. */
  107985. teleportationTarget: Mesh;
  107986. /**
  107987. * 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
  107988. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  107989. * See http://doc.babylonjs.com/resources/baking_transformations
  107990. */
  107991. gazeTrackerMesh: Mesh;
  107992. /**
  107993. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  107994. */
  107995. updateGazeTrackerScale: boolean;
  107996. /**
  107997. * If the gaze trackers color should be updated when selecting meshes
  107998. */
  107999. updateGazeTrackerColor: boolean;
  108000. /**
  108001. * If the controller laser color should be updated when selecting meshes
  108002. */
  108003. updateControllerLaserColor: boolean;
  108004. /**
  108005. * The gaze tracking mesh corresponding to the left controller
  108006. */
  108007. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  108008. /**
  108009. * The gaze tracking mesh corresponding to the right controller
  108010. */
  108011. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  108012. /**
  108013. * If the ray of the gaze should be displayed.
  108014. */
  108015. /**
  108016. * Sets if the ray of the gaze should be displayed.
  108017. */
  108018. displayGaze: boolean;
  108019. /**
  108020. * If the ray of the LaserPointer should be displayed.
  108021. */
  108022. /**
  108023. * Sets if the ray of the LaserPointer should be displayed.
  108024. */
  108025. displayLaserPointer: boolean;
  108026. /**
  108027. * The deviceOrientationCamera used as the camera when not in VR.
  108028. */
  108029. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  108030. /**
  108031. * Based on the current WebVR support, returns the current VR camera used.
  108032. */
  108033. readonly currentVRCamera: Nullable<Camera>;
  108034. /**
  108035. * The webVRCamera which is used when in VR.
  108036. */
  108037. readonly webVRCamera: WebVRFreeCamera;
  108038. /**
  108039. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  108040. */
  108041. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  108042. /**
  108043. * The html button that is used to trigger entering into VR.
  108044. */
  108045. readonly vrButton: Nullable<HTMLButtonElement>;
  108046. private readonly _teleportationRequestInitiated;
  108047. /**
  108048. * Defines wether or not Pointer lock should be requested when switching to
  108049. * full screen.
  108050. */
  108051. requestPointerLockOnFullScreen: boolean;
  108052. /**
  108053. * Instantiates a VRExperienceHelper.
  108054. * Helps to quickly add VR support to an existing scene.
  108055. * @param scene The scene the VRExperienceHelper belongs to.
  108056. * @param webVROptions Options to modify the vr experience helper's behavior.
  108057. */
  108058. constructor(scene: Scene,
  108059. /** Options to modify the vr experience helper's behavior. */
  108060. webVROptions?: VRExperienceHelperOptions);
  108061. private _onDefaultMeshLoaded;
  108062. private _onResize;
  108063. private _onFullscreenChange;
  108064. /**
  108065. * Gets a value indicating if we are currently in VR mode.
  108066. */
  108067. readonly isInVRMode: boolean;
  108068. private onVrDisplayPresentChange;
  108069. private onVRDisplayChanged;
  108070. private moveButtonToBottomRight;
  108071. private displayVRButton;
  108072. private updateButtonVisibility;
  108073. private _cachedAngularSensibility;
  108074. /**
  108075. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  108076. * Otherwise, will use the fullscreen API.
  108077. */
  108078. enterVR(): void;
  108079. /**
  108080. * Attempt to exit VR, or fullscreen.
  108081. */
  108082. exitVR(): void;
  108083. /**
  108084. * The position of the vr experience helper.
  108085. */
  108086. /**
  108087. * Sets the position of the vr experience helper.
  108088. */
  108089. position: Vector3;
  108090. /**
  108091. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  108092. */
  108093. enableInteractions(): void;
  108094. private readonly _noControllerIsActive;
  108095. private beforeRender;
  108096. private _isTeleportationFloor;
  108097. /**
  108098. * Adds a floor mesh to be used for teleportation.
  108099. * @param floorMesh the mesh to be used for teleportation.
  108100. */
  108101. addFloorMesh(floorMesh: Mesh): void;
  108102. /**
  108103. * Removes a floor mesh from being used for teleportation.
  108104. * @param floorMesh the mesh to be removed.
  108105. */
  108106. removeFloorMesh(floorMesh: Mesh): void;
  108107. /**
  108108. * Enables interactions and teleportation using the VR controllers and gaze.
  108109. * @param vrTeleportationOptions options to modify teleportation behavior.
  108110. */
  108111. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  108112. private _onNewGamepadConnected;
  108113. private _tryEnableInteractionOnController;
  108114. private _onNewGamepadDisconnected;
  108115. private _enableInteractionOnController;
  108116. private _checkTeleportWithRay;
  108117. private _checkRotate;
  108118. private _checkTeleportBackwards;
  108119. private _enableTeleportationOnController;
  108120. private _createTeleportationCircles;
  108121. private _displayTeleportationTarget;
  108122. private _hideTeleportationTarget;
  108123. private _rotateCamera;
  108124. private _moveTeleportationSelectorTo;
  108125. private _workingVector;
  108126. private _workingQuaternion;
  108127. private _workingMatrix;
  108128. /**
  108129. * Teleports the users feet to the desired location
  108130. * @param location The location where the user's feet should be placed
  108131. */
  108132. teleportCamera(location: Vector3): void;
  108133. private _convertNormalToDirectionOfRay;
  108134. private _castRayAndSelectObject;
  108135. private _notifySelectedMeshUnselected;
  108136. /**
  108137. * Sets the color of the laser ray from the vr controllers.
  108138. * @param color new color for the ray.
  108139. */
  108140. changeLaserColor(color: Color3): void;
  108141. /**
  108142. * Sets the color of the ray from the vr headsets gaze.
  108143. * @param color new color for the ray.
  108144. */
  108145. changeGazeColor(color: Color3): void;
  108146. /**
  108147. * Exits VR and disposes of the vr experience helper
  108148. */
  108149. dispose(): void;
  108150. /**
  108151. * Gets the name of the VRExperienceHelper class
  108152. * @returns "VRExperienceHelper"
  108153. */
  108154. getClassName(): string;
  108155. }
  108156. }
  108157. declare module BABYLON {
  108158. /**
  108159. * Manages an XRSession to work with Babylon's engine
  108160. * @see https://doc.babylonjs.com/how_to/webxr
  108161. */
  108162. export class WebXRSessionManager implements IDisposable {
  108163. private scene;
  108164. /**
  108165. * Fires every time a new xrFrame arrives which can be used to update the camera
  108166. */
  108167. onXRFrameObservable: Observable<any>;
  108168. /**
  108169. * Fires when the xr session is ended either by the device or manually done
  108170. */
  108171. onXRSessionEnded: Observable<any>;
  108172. /**
  108173. * Underlying xr session
  108174. */
  108175. session: XRSession;
  108176. /**
  108177. * Type of reference space used when creating the session
  108178. */
  108179. referenceSpace: XRReferenceSpace;
  108180. /** @hidden */
  108181. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108182. /**
  108183. * Current XR frame
  108184. */
  108185. currentFrame: Nullable<XRFrame>;
  108186. private _xrNavigator;
  108187. private baseLayer;
  108188. /**
  108189. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108190. * @param scene The scene which the session should be created for
  108191. */
  108192. constructor(scene: Scene);
  108193. /**
  108194. * Initializes the manager
  108195. * After initialization enterXR can be called to start an XR session
  108196. * @returns Promise which resolves after it is initialized
  108197. */
  108198. initializeAsync(): Promise<void>;
  108199. /**
  108200. * Initializes an xr session
  108201. * @param xrSessionMode mode to initialize
  108202. * @returns a promise which will resolve once the session has been initialized
  108203. */
  108204. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108205. /**
  108206. * Sets the reference space on the xr session
  108207. * @param referenceSpace space to set
  108208. * @returns a promise that will resolve once the reference space has been set
  108209. */
  108210. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108211. /**
  108212. * Updates the render state of the session
  108213. * @param state state to set
  108214. * @returns a promise that resolves once the render state has been updated
  108215. */
  108216. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  108217. /**
  108218. * Starts rendering to the xr layer
  108219. * @returns a promise that will resolve once rendering has started
  108220. */
  108221. startRenderingToXRAsync(): Promise<void>;
  108222. /**
  108223. * Stops the xrSession and restores the renderloop
  108224. * @returns Promise which resolves after it exits XR
  108225. */
  108226. exitXRAsync(): Promise<unknown>;
  108227. /**
  108228. * Checks if a session would be supported for the creation options specified
  108229. * @param sessionMode session mode to check if supported eg. immersive-vr
  108230. * @returns true if supported
  108231. */
  108232. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108233. /**
  108234. * @hidden
  108235. * Converts the render layer of xrSession to a render target
  108236. * @param session session to create render target for
  108237. * @param scene scene the new render target should be created for
  108238. */
  108239. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108240. /**
  108241. * Disposes of the session manager
  108242. */
  108243. dispose(): void;
  108244. }
  108245. }
  108246. declare module BABYLON {
  108247. /**
  108248. * WebXR Camera which holds the views for the xrSession
  108249. * @see https://doc.babylonjs.com/how_to/webxr
  108250. */
  108251. export class WebXRCamera extends FreeCamera {
  108252. private static _TmpMatrix;
  108253. /**
  108254. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  108255. * @param name the name of the camera
  108256. * @param scene the scene to add the camera to
  108257. */
  108258. constructor(name: string, scene: Scene);
  108259. private _updateNumberOfRigCameras;
  108260. /** @hidden */
  108261. _updateForDualEyeDebugging(pupilDistance?: number): void;
  108262. /**
  108263. * Updates the cameras position from the current pose information of the XR session
  108264. * @param xrSessionManager the session containing pose information
  108265. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  108266. */
  108267. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  108268. }
  108269. }
  108270. declare module BABYLON {
  108271. /**
  108272. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  108273. */
  108274. export class WebXRManagedOutputCanvas implements IDisposable {
  108275. private helper;
  108276. private _canvas;
  108277. /**
  108278. * xrpresent context of the canvas which can be used to display/mirror xr content
  108279. */
  108280. canvasContext: WebGLRenderingContext;
  108281. /**
  108282. * xr layer for the canvas
  108283. */
  108284. xrLayer: Nullable<XRWebGLLayer>;
  108285. /**
  108286. * Initializes the xr layer for the session
  108287. * @param xrSession xr session
  108288. * @returns a promise that will resolve once the XR Layer has been created
  108289. */
  108290. initializeXRLayerAsync(xrSession: any): any;
  108291. /**
  108292. * Initializes the canvas to be added/removed upon entering/exiting xr
  108293. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  108294. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  108295. */
  108296. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  108297. /**
  108298. * Disposes of the object
  108299. */
  108300. dispose(): void;
  108301. private _setManagedOutputCanvas;
  108302. private _addCanvas;
  108303. private _removeCanvas;
  108304. }
  108305. }
  108306. declare module BABYLON {
  108307. /**
  108308. * States of the webXR experience
  108309. */
  108310. export enum WebXRState {
  108311. /**
  108312. * Transitioning to being in XR mode
  108313. */
  108314. ENTERING_XR = 0,
  108315. /**
  108316. * Transitioning to non XR mode
  108317. */
  108318. EXITING_XR = 1,
  108319. /**
  108320. * In XR mode and presenting
  108321. */
  108322. IN_XR = 2,
  108323. /**
  108324. * Not entered XR mode
  108325. */
  108326. NOT_IN_XR = 3
  108327. }
  108328. /**
  108329. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  108330. * @see https://doc.babylonjs.com/how_to/webxr
  108331. */
  108332. export class WebXRExperienceHelper implements IDisposable {
  108333. private scene;
  108334. /**
  108335. * 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
  108336. */
  108337. container: AbstractMesh;
  108338. /**
  108339. * Camera used to render xr content
  108340. */
  108341. camera: WebXRCamera;
  108342. /**
  108343. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  108344. */
  108345. state: WebXRState;
  108346. private _setState;
  108347. private static _TmpVector;
  108348. /**
  108349. * Fires when the state of the experience helper has changed
  108350. */
  108351. onStateChangedObservable: Observable<WebXRState>;
  108352. /** Session manager used to keep track of xr session */
  108353. sessionManager: WebXRSessionManager;
  108354. private _nonVRCamera;
  108355. private _originalSceneAutoClear;
  108356. private _supported;
  108357. /**
  108358. * Creates the experience helper
  108359. * @param scene the scene to attach the experience helper to
  108360. * @returns a promise for the experience helper
  108361. */
  108362. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  108363. /**
  108364. * Creates a WebXRExperienceHelper
  108365. * @param scene The scene the helper should be created in
  108366. */
  108367. private constructor();
  108368. /**
  108369. * Exits XR mode and returns the scene to its original state
  108370. * @returns promise that resolves after xr mode has exited
  108371. */
  108372. exitXRAsync(): Promise<unknown>;
  108373. /**
  108374. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  108375. * @param sessionCreationOptions options for the XR session
  108376. * @param referenceSpaceType frame of reference of the XR session
  108377. * @param outputCanvas the output canvas that will be used to enter XR mode
  108378. * @returns promise that resolves after xr mode has entered
  108379. */
  108380. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  108381. /**
  108382. * Updates the global position of the camera by moving the camera's container
  108383. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  108384. * @param position The desired global position of the camera
  108385. */
  108386. setPositionOfCameraUsingContainer(position: Vector3): void;
  108387. /**
  108388. * Rotates the xr camera by rotating the camera's container around the camera's position
  108389. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  108390. * @param rotation the desired quaternion rotation to apply to the camera
  108391. */
  108392. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  108393. /**
  108394. * Disposes of the experience helper
  108395. */
  108396. dispose(): void;
  108397. }
  108398. }
  108399. declare module BABYLON {
  108400. /**
  108401. * Button which can be used to enter a different mode of XR
  108402. */
  108403. export class WebXREnterExitUIButton {
  108404. /** button element */
  108405. element: HTMLElement;
  108406. /** XR initialization options for the button */
  108407. sessionMode: XRSessionMode;
  108408. /** Reference space type */
  108409. referenceSpaceType: XRReferenceSpaceType;
  108410. /**
  108411. * Creates a WebXREnterExitUIButton
  108412. * @param element button element
  108413. * @param sessionMode XR initialization session mode
  108414. * @param referenceSpaceType the type of reference space to be used
  108415. */
  108416. constructor(
  108417. /** button element */
  108418. element: HTMLElement,
  108419. /** XR initialization options for the button */
  108420. sessionMode: XRSessionMode,
  108421. /** Reference space type */
  108422. referenceSpaceType: XRReferenceSpaceType);
  108423. /**
  108424. * Overwritable function which can be used to update the button's visuals when the state changes
  108425. * @param activeButton the current active button in the UI
  108426. */
  108427. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  108428. }
  108429. /**
  108430. * Options to create the webXR UI
  108431. */
  108432. export class WebXREnterExitUIOptions {
  108433. /**
  108434. * Context to enter xr with
  108435. */
  108436. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  108437. /**
  108438. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  108439. */
  108440. customButtons?: Array<WebXREnterExitUIButton>;
  108441. }
  108442. /**
  108443. * UI to allow the user to enter/exit XR mode
  108444. */
  108445. export class WebXREnterExitUI implements IDisposable {
  108446. private scene;
  108447. private _overlay;
  108448. private _buttons;
  108449. private _activeButton;
  108450. /**
  108451. * Fired every time the active button is changed.
  108452. *
  108453. * When xr is entered via a button that launches xr that button will be the callback parameter
  108454. *
  108455. * When exiting xr the callback parameter will be null)
  108456. */
  108457. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  108458. /**
  108459. * Creates UI to allow the user to enter/exit XR mode
  108460. * @param scene the scene to add the ui to
  108461. * @param helper the xr experience helper to enter/exit xr with
  108462. * @param options options to configure the UI
  108463. * @returns the created ui
  108464. */
  108465. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  108466. private constructor();
  108467. private _updateButtons;
  108468. /**
  108469. * Disposes of the object
  108470. */
  108471. dispose(): void;
  108472. }
  108473. }
  108474. declare module BABYLON {
  108475. /**
  108476. * Represents an XR input
  108477. */
  108478. export class WebXRController {
  108479. private scene;
  108480. /** The underlying input source for the controller */
  108481. inputSource: XRInputSource;
  108482. private parentContainer;
  108483. /**
  108484. * 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
  108485. */
  108486. grip?: AbstractMesh;
  108487. /**
  108488. * Pointer which can be used to select objects or attach a visible laser to
  108489. */
  108490. pointer: AbstractMesh;
  108491. /**
  108492. * Event that fires when the controller is removed/disposed
  108493. */
  108494. onDisposeObservable: Observable<{}>;
  108495. private _tmpMatrix;
  108496. private _tmpQuaternion;
  108497. private _tmpVector;
  108498. /**
  108499. * Creates the controller
  108500. * @see https://doc.babylonjs.com/how_to/webxr
  108501. * @param scene the scene which the controller should be associated to
  108502. * @param inputSource the underlying input source for the controller
  108503. * @param parentContainer parent that the controller meshes should be children of
  108504. */
  108505. constructor(scene: Scene,
  108506. /** The underlying input source for the controller */
  108507. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  108508. /**
  108509. * Updates the controller pose based on the given XRFrame
  108510. * @param xrFrame xr frame to update the pose with
  108511. * @param referenceSpace reference space to use
  108512. */
  108513. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  108514. /**
  108515. * Gets a world space ray coming from the controller
  108516. * @param result the resulting ray
  108517. */
  108518. getWorldPointerRayToRef(result: Ray): void;
  108519. /**
  108520. * Disposes of the object
  108521. */
  108522. dispose(): void;
  108523. }
  108524. }
  108525. declare module BABYLON {
  108526. /**
  108527. * XR input used to track XR inputs such as controllers/rays
  108528. */
  108529. export class WebXRInput implements IDisposable {
  108530. /**
  108531. * Base experience the input listens to
  108532. */
  108533. baseExperience: WebXRExperienceHelper;
  108534. /**
  108535. * XR controllers being tracked
  108536. */
  108537. controllers: Array<WebXRController>;
  108538. private _frameObserver;
  108539. private _stateObserver;
  108540. /**
  108541. * Event when a controller has been connected/added
  108542. */
  108543. onControllerAddedObservable: Observable<WebXRController>;
  108544. /**
  108545. * Event when a controller has been removed/disconnected
  108546. */
  108547. onControllerRemovedObservable: Observable<WebXRController>;
  108548. /**
  108549. * Initializes the WebXRInput
  108550. * @param baseExperience experience helper which the input should be created for
  108551. */
  108552. constructor(
  108553. /**
  108554. * Base experience the input listens to
  108555. */
  108556. baseExperience: WebXRExperienceHelper);
  108557. private _onInputSourcesChange;
  108558. private _addAndRemoveControllers;
  108559. /**
  108560. * Disposes of the object
  108561. */
  108562. dispose(): void;
  108563. }
  108564. }
  108565. declare module BABYLON {
  108566. /**
  108567. * Enables teleportation
  108568. */
  108569. export class WebXRControllerTeleportation {
  108570. private _teleportationFillColor;
  108571. private _teleportationBorderColor;
  108572. private _tmpRay;
  108573. private _tmpVector;
  108574. /**
  108575. * Creates a WebXRControllerTeleportation
  108576. * @param input input manager to add teleportation to
  108577. * @param floorMeshes floormeshes which can be teleported to
  108578. */
  108579. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  108580. }
  108581. }
  108582. declare module BABYLON {
  108583. /**
  108584. * Handles pointer input automatically for the pointer of XR controllers
  108585. */
  108586. export class WebXRControllerPointerSelection {
  108587. private static _idCounter;
  108588. private _tmpRay;
  108589. /**
  108590. * Creates a WebXRControllerPointerSelection
  108591. * @param input input manager to setup pointer selection
  108592. */
  108593. constructor(input: WebXRInput);
  108594. private _convertNormalToDirectionOfRay;
  108595. private _updatePointerDistance;
  108596. }
  108597. }
  108598. declare module BABYLON {
  108599. /**
  108600. * Class used to represent data loading progression
  108601. */
  108602. export class SceneLoaderProgressEvent {
  108603. /** defines if data length to load can be evaluated */
  108604. readonly lengthComputable: boolean;
  108605. /** defines the loaded data length */
  108606. readonly loaded: number;
  108607. /** defines the data length to load */
  108608. readonly total: number;
  108609. /**
  108610. * Create a new progress event
  108611. * @param lengthComputable defines if data length to load can be evaluated
  108612. * @param loaded defines the loaded data length
  108613. * @param total defines the data length to load
  108614. */
  108615. constructor(
  108616. /** defines if data length to load can be evaluated */
  108617. lengthComputable: boolean,
  108618. /** defines the loaded data length */
  108619. loaded: number,
  108620. /** defines the data length to load */
  108621. total: number);
  108622. /**
  108623. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  108624. * @param event defines the source event
  108625. * @returns a new SceneLoaderProgressEvent
  108626. */
  108627. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  108628. }
  108629. /**
  108630. * Interface used by SceneLoader plugins to define supported file extensions
  108631. */
  108632. export interface ISceneLoaderPluginExtensions {
  108633. /**
  108634. * Defines the list of supported extensions
  108635. */
  108636. [extension: string]: {
  108637. isBinary: boolean;
  108638. };
  108639. }
  108640. /**
  108641. * Interface used by SceneLoader plugin factory
  108642. */
  108643. export interface ISceneLoaderPluginFactory {
  108644. /**
  108645. * Defines the name of the factory
  108646. */
  108647. name: string;
  108648. /**
  108649. * Function called to create a new plugin
  108650. * @return the new plugin
  108651. */
  108652. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  108653. /**
  108654. * Boolean indicating if the plugin can direct load specific data
  108655. */
  108656. canDirectLoad?: (data: string) => boolean;
  108657. }
  108658. /**
  108659. * Interface used to define a SceneLoader plugin
  108660. */
  108661. export interface ISceneLoaderPlugin {
  108662. /**
  108663. * The friendly name of this plugin.
  108664. */
  108665. name: string;
  108666. /**
  108667. * The file extensions supported by this plugin.
  108668. */
  108669. extensions: string | ISceneLoaderPluginExtensions;
  108670. /**
  108671. * Import meshes into a scene.
  108672. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108673. * @param scene The scene to import into
  108674. * @param data The data to import
  108675. * @param rootUrl The root url for scene and resources
  108676. * @param meshes The meshes array to import into
  108677. * @param particleSystems The particle systems array to import into
  108678. * @param skeletons The skeletons array to import into
  108679. * @param onError The callback when import fails
  108680. * @returns True if successful or false otherwise
  108681. */
  108682. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  108683. /**
  108684. * Load into a scene.
  108685. * @param scene The scene to load into
  108686. * @param data The data to import
  108687. * @param rootUrl The root url for scene and resources
  108688. * @param onError The callback when import fails
  108689. * @returns true if successful or false otherwise
  108690. */
  108691. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  108692. /**
  108693. * The callback that returns true if the data can be directly loaded.
  108694. */
  108695. canDirectLoad?: (data: string) => boolean;
  108696. /**
  108697. * The callback that allows custom handling of the root url based on the response url.
  108698. */
  108699. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108700. /**
  108701. * Load into an asset container.
  108702. * @param scene The scene to load into
  108703. * @param data The data to import
  108704. * @param rootUrl The root url for scene and resources
  108705. * @param onError The callback when import fails
  108706. * @returns The loaded asset container
  108707. */
  108708. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  108709. }
  108710. /**
  108711. * Interface used to define an async SceneLoader plugin
  108712. */
  108713. export interface ISceneLoaderPluginAsync {
  108714. /**
  108715. * The friendly name of this plugin.
  108716. */
  108717. name: string;
  108718. /**
  108719. * The file extensions supported by this plugin.
  108720. */
  108721. extensions: string | ISceneLoaderPluginExtensions;
  108722. /**
  108723. * Import meshes into a scene.
  108724. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108725. * @param scene The scene to import into
  108726. * @param data The data to import
  108727. * @param rootUrl The root url for scene and resources
  108728. * @param onProgress The callback when the load progresses
  108729. * @param fileName Defines the name of the file to load
  108730. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  108731. */
  108732. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  108733. meshes: AbstractMesh[];
  108734. particleSystems: IParticleSystem[];
  108735. skeletons: Skeleton[];
  108736. animationGroups: AnimationGroup[];
  108737. }>;
  108738. /**
  108739. * Load into a scene.
  108740. * @param scene The scene to load into
  108741. * @param data The data to import
  108742. * @param rootUrl The root url for scene and resources
  108743. * @param onProgress The callback when the load progresses
  108744. * @param fileName Defines the name of the file to load
  108745. * @returns Nothing
  108746. */
  108747. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  108748. /**
  108749. * The callback that returns true if the data can be directly loaded.
  108750. */
  108751. canDirectLoad?: (data: string) => boolean;
  108752. /**
  108753. * The callback that allows custom handling of the root url based on the response url.
  108754. */
  108755. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108756. /**
  108757. * Load into an asset container.
  108758. * @param scene The scene to load into
  108759. * @param data The data to import
  108760. * @param rootUrl The root url for scene and resources
  108761. * @param onProgress The callback when the load progresses
  108762. * @param fileName Defines the name of the file to load
  108763. * @returns The loaded asset container
  108764. */
  108765. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  108766. }
  108767. /**
  108768. * Class used to load scene from various file formats using registered plugins
  108769. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  108770. */
  108771. export class SceneLoader {
  108772. /**
  108773. * No logging while loading
  108774. */
  108775. static readonly NO_LOGGING: number;
  108776. /**
  108777. * Minimal logging while loading
  108778. */
  108779. static readonly MINIMAL_LOGGING: number;
  108780. /**
  108781. * Summary logging while loading
  108782. */
  108783. static readonly SUMMARY_LOGGING: number;
  108784. /**
  108785. * Detailled logging while loading
  108786. */
  108787. static readonly DETAILED_LOGGING: number;
  108788. /**
  108789. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  108790. */
  108791. static ForceFullSceneLoadingForIncremental: boolean;
  108792. /**
  108793. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  108794. */
  108795. static ShowLoadingScreen: boolean;
  108796. /**
  108797. * Defines the current logging level (while loading the scene)
  108798. * @ignorenaming
  108799. */
  108800. static loggingLevel: number;
  108801. /**
  108802. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  108803. */
  108804. static CleanBoneMatrixWeights: boolean;
  108805. /**
  108806. * Event raised when a plugin is used to load a scene
  108807. */
  108808. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  108809. private static _registeredPlugins;
  108810. private static _getDefaultPlugin;
  108811. private static _getPluginForExtension;
  108812. private static _getPluginForDirectLoad;
  108813. private static _getPluginForFilename;
  108814. private static _getDirectLoad;
  108815. private static _loadData;
  108816. private static _getFileInfo;
  108817. /**
  108818. * Gets a plugin that can load the given extension
  108819. * @param extension defines the extension to load
  108820. * @returns a plugin or null if none works
  108821. */
  108822. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  108823. /**
  108824. * Gets a boolean indicating that the given extension can be loaded
  108825. * @param extension defines the extension to load
  108826. * @returns true if the extension is supported
  108827. */
  108828. static IsPluginForExtensionAvailable(extension: string): boolean;
  108829. /**
  108830. * Adds a new plugin to the list of registered plugins
  108831. * @param plugin defines the plugin to add
  108832. */
  108833. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  108834. /**
  108835. * Import meshes into a scene
  108836. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108837. * @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)
  108838. * @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)
  108839. * @param scene the instance of BABYLON.Scene to append to
  108840. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  108841. * @param onProgress a callback with a progress event for each file being loaded
  108842. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108843. * @param pluginExtension the extension used to determine the plugin
  108844. * @returns The loaded plugin
  108845. */
  108846. 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>;
  108847. /**
  108848. * Import meshes into a scene
  108849. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108850. * @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)
  108851. * @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)
  108852. * @param scene the instance of BABYLON.Scene to append to
  108853. * @param onProgress a callback with a progress event for each file being loaded
  108854. * @param pluginExtension the extension used to determine the plugin
  108855. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  108856. */
  108857. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  108858. meshes: AbstractMesh[];
  108859. particleSystems: IParticleSystem[];
  108860. skeletons: Skeleton[];
  108861. animationGroups: AnimationGroup[];
  108862. }>;
  108863. /**
  108864. * Load a scene
  108865. * @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)
  108866. * @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)
  108867. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108868. * @param onSuccess a callback with the scene when import succeeds
  108869. * @param onProgress a callback with a progress event for each file being loaded
  108870. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108871. * @param pluginExtension the extension used to determine the plugin
  108872. * @returns The loaded plugin
  108873. */
  108874. 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>;
  108875. /**
  108876. * Load a scene
  108877. * @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)
  108878. * @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)
  108879. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108880. * @param onProgress a callback with a progress event for each file being loaded
  108881. * @param pluginExtension the extension used to determine the plugin
  108882. * @returns The loaded scene
  108883. */
  108884. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108885. /**
  108886. * Append a scene
  108887. * @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)
  108888. * @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)
  108889. * @param scene is the instance of BABYLON.Scene to append to
  108890. * @param onSuccess a callback with the scene when import succeeds
  108891. * @param onProgress a callback with a progress event for each file being loaded
  108892. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108893. * @param pluginExtension the extension used to determine the plugin
  108894. * @returns The loaded plugin
  108895. */
  108896. 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>;
  108897. /**
  108898. * Append a scene
  108899. * @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)
  108900. * @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)
  108901. * @param scene is the instance of BABYLON.Scene to append to
  108902. * @param onProgress a callback with a progress event for each file being loaded
  108903. * @param pluginExtension the extension used to determine the plugin
  108904. * @returns The given scene
  108905. */
  108906. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108907. /**
  108908. * Load a scene into an asset container
  108909. * @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)
  108910. * @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)
  108911. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  108912. * @param onSuccess a callback with the scene when import succeeds
  108913. * @param onProgress a callback with a progress event for each file being loaded
  108914. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108915. * @param pluginExtension the extension used to determine the plugin
  108916. * @returns The loaded plugin
  108917. */
  108918. 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>;
  108919. /**
  108920. * Load a scene into an asset container
  108921. * @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)
  108922. * @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)
  108923. * @param scene is the instance of Scene to append to
  108924. * @param onProgress a callback with a progress event for each file being loaded
  108925. * @param pluginExtension the extension used to determine the plugin
  108926. * @returns The loaded asset container
  108927. */
  108928. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  108929. }
  108930. }
  108931. declare module BABYLON {
  108932. /**
  108933. * Generic Controller
  108934. */
  108935. export class GenericController extends WebVRController {
  108936. /**
  108937. * Base Url for the controller model.
  108938. */
  108939. static readonly MODEL_BASE_URL: string;
  108940. /**
  108941. * File name for the controller model.
  108942. */
  108943. static readonly MODEL_FILENAME: string;
  108944. /**
  108945. * Creates a new GenericController from a gamepad
  108946. * @param vrGamepad the gamepad that the controller should be created from
  108947. */
  108948. constructor(vrGamepad: any);
  108949. /**
  108950. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108951. * @param scene scene in which to add meshes
  108952. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108953. */
  108954. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108955. /**
  108956. * Called once for each button that changed state since the last frame
  108957. * @param buttonIdx Which button index changed
  108958. * @param state New state of the button
  108959. * @param changes Which properties on the state changed since last frame
  108960. */
  108961. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108962. }
  108963. }
  108964. declare module BABYLON {
  108965. /**
  108966. * Defines the WindowsMotionController object that the state of the windows motion controller
  108967. */
  108968. export class WindowsMotionController extends WebVRController {
  108969. /**
  108970. * The base url used to load the left and right controller models
  108971. */
  108972. static MODEL_BASE_URL: string;
  108973. /**
  108974. * The name of the left controller model file
  108975. */
  108976. static MODEL_LEFT_FILENAME: string;
  108977. /**
  108978. * The name of the right controller model file
  108979. */
  108980. static MODEL_RIGHT_FILENAME: string;
  108981. /**
  108982. * The controller name prefix for this controller type
  108983. */
  108984. static readonly GAMEPAD_ID_PREFIX: string;
  108985. /**
  108986. * The controller id pattern for this controller type
  108987. */
  108988. private static readonly GAMEPAD_ID_PATTERN;
  108989. private _loadedMeshInfo;
  108990. private readonly _mapping;
  108991. /**
  108992. * Fired when the trackpad on this controller is clicked
  108993. */
  108994. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  108995. /**
  108996. * Fired when the trackpad on this controller is modified
  108997. */
  108998. onTrackpadValuesChangedObservable: Observable<StickValues>;
  108999. /**
  109000. * The current x and y values of this controller's trackpad
  109001. */
  109002. trackpad: StickValues;
  109003. /**
  109004. * Creates a new WindowsMotionController from a gamepad
  109005. * @param vrGamepad the gamepad that the controller should be created from
  109006. */
  109007. constructor(vrGamepad: any);
  109008. /**
  109009. * Fired when the trigger on this controller is modified
  109010. */
  109011. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109012. /**
  109013. * Fired when the menu button on this controller is modified
  109014. */
  109015. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109016. /**
  109017. * Fired when the grip button on this controller is modified
  109018. */
  109019. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109020. /**
  109021. * Fired when the thumbstick button on this controller is modified
  109022. */
  109023. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109024. /**
  109025. * Fired when the touchpad button on this controller is modified
  109026. */
  109027. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109028. /**
  109029. * Fired when the touchpad values on this controller are modified
  109030. */
  109031. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  109032. private _updateTrackpad;
  109033. /**
  109034. * Called once per frame by the engine.
  109035. */
  109036. update(): void;
  109037. /**
  109038. * Called once for each button that changed state since the last frame
  109039. * @param buttonIdx Which button index changed
  109040. * @param state New state of the button
  109041. * @param changes Which properties on the state changed since last frame
  109042. */
  109043. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109044. /**
  109045. * Moves the buttons on the controller mesh based on their current state
  109046. * @param buttonName the name of the button to move
  109047. * @param buttonValue the value of the button which determines the buttons new position
  109048. */
  109049. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  109050. /**
  109051. * Moves the axis on the controller mesh based on its current state
  109052. * @param axis the index of the axis
  109053. * @param axisValue the value of the axis which determines the meshes new position
  109054. * @hidden
  109055. */
  109056. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  109057. /**
  109058. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109059. * @param scene scene in which to add meshes
  109060. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109061. */
  109062. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  109063. /**
  109064. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  109065. * can be transformed by button presses and axes values, based on this._mapping.
  109066. *
  109067. * @param scene scene in which the meshes exist
  109068. * @param meshes list of meshes that make up the controller model to process
  109069. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  109070. */
  109071. private processModel;
  109072. private createMeshInfo;
  109073. /**
  109074. * Gets the ray of the controller in the direction the controller is pointing
  109075. * @param length the length the resulting ray should be
  109076. * @returns a ray in the direction the controller is pointing
  109077. */
  109078. getForwardRay(length?: number): Ray;
  109079. /**
  109080. * Disposes of the controller
  109081. */
  109082. dispose(): void;
  109083. }
  109084. }
  109085. declare module BABYLON {
  109086. /**
  109087. * Oculus Touch Controller
  109088. */
  109089. export class OculusTouchController extends WebVRController {
  109090. /**
  109091. * Base Url for the controller model.
  109092. */
  109093. static MODEL_BASE_URL: string;
  109094. /**
  109095. * File name for the left controller model.
  109096. */
  109097. static MODEL_LEFT_FILENAME: string;
  109098. /**
  109099. * File name for the right controller model.
  109100. */
  109101. static MODEL_RIGHT_FILENAME: string;
  109102. /**
  109103. * Base Url for the Quest controller model.
  109104. */
  109105. static QUEST_MODEL_BASE_URL: string;
  109106. /**
  109107. * @hidden
  109108. * If the controllers are running on a device that needs the updated Quest controller models
  109109. */
  109110. static _IsQuest: boolean;
  109111. /**
  109112. * Fired when the secondary trigger on this controller is modified
  109113. */
  109114. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  109115. /**
  109116. * Fired when the thumb rest on this controller is modified
  109117. */
  109118. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  109119. /**
  109120. * Creates a new OculusTouchController from a gamepad
  109121. * @param vrGamepad the gamepad that the controller should be created from
  109122. */
  109123. constructor(vrGamepad: any);
  109124. /**
  109125. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109126. * @param scene scene in which to add meshes
  109127. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109128. */
  109129. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109130. /**
  109131. * Fired when the A button on this controller is modified
  109132. */
  109133. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109134. /**
  109135. * Fired when the B button on this controller is modified
  109136. */
  109137. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109138. /**
  109139. * Fired when the X button on this controller is modified
  109140. */
  109141. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109142. /**
  109143. * Fired when the Y button on this controller is modified
  109144. */
  109145. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109146. /**
  109147. * Called once for each button that changed state since the last frame
  109148. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109149. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109150. * 2) secondary trigger (same)
  109151. * 3) A (right) X (left), touch, pressed = value
  109152. * 4) B / Y
  109153. * 5) thumb rest
  109154. * @param buttonIdx Which button index changed
  109155. * @param state New state of the button
  109156. * @param changes Which properties on the state changed since last frame
  109157. */
  109158. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109159. }
  109160. }
  109161. declare module BABYLON {
  109162. /**
  109163. * Vive Controller
  109164. */
  109165. export class ViveController extends WebVRController {
  109166. /**
  109167. * Base Url for the controller model.
  109168. */
  109169. static MODEL_BASE_URL: string;
  109170. /**
  109171. * File name for the controller model.
  109172. */
  109173. static MODEL_FILENAME: string;
  109174. /**
  109175. * Creates a new ViveController from a gamepad
  109176. * @param vrGamepad the gamepad that the controller should be created from
  109177. */
  109178. constructor(vrGamepad: any);
  109179. /**
  109180. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109181. * @param scene scene in which to add meshes
  109182. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109183. */
  109184. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109185. /**
  109186. * Fired when the left button on this controller is modified
  109187. */
  109188. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109189. /**
  109190. * Fired when the right button on this controller is modified
  109191. */
  109192. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109193. /**
  109194. * Fired when the menu button on this controller is modified
  109195. */
  109196. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109197. /**
  109198. * Called once for each button that changed state since the last frame
  109199. * Vive mapping:
  109200. * 0: touchpad
  109201. * 1: trigger
  109202. * 2: left AND right buttons
  109203. * 3: menu button
  109204. * @param buttonIdx Which button index changed
  109205. * @param state New state of the button
  109206. * @param changes Which properties on the state changed since last frame
  109207. */
  109208. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109209. }
  109210. }
  109211. declare module BABYLON {
  109212. /**
  109213. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  109214. */
  109215. export class WebXRControllerModelLoader {
  109216. /**
  109217. * Creates the WebXRControllerModelLoader
  109218. * @param input xr input that creates the controllers
  109219. */
  109220. constructor(input: WebXRInput);
  109221. }
  109222. }
  109223. declare module BABYLON {
  109224. /**
  109225. * Contains an array of blocks representing the octree
  109226. */
  109227. export interface IOctreeContainer<T> {
  109228. /**
  109229. * Blocks within the octree
  109230. */
  109231. blocks: Array<OctreeBlock<T>>;
  109232. }
  109233. /**
  109234. * Class used to store a cell in an octree
  109235. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109236. */
  109237. export class OctreeBlock<T> {
  109238. /**
  109239. * Gets the content of the current block
  109240. */
  109241. entries: T[];
  109242. /**
  109243. * Gets the list of block children
  109244. */
  109245. blocks: Array<OctreeBlock<T>>;
  109246. private _depth;
  109247. private _maxDepth;
  109248. private _capacity;
  109249. private _minPoint;
  109250. private _maxPoint;
  109251. private _boundingVectors;
  109252. private _creationFunc;
  109253. /**
  109254. * Creates a new block
  109255. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  109256. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  109257. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109258. * @param depth defines the current depth of this block in the octree
  109259. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  109260. * @param creationFunc defines a callback to call when an element is added to the block
  109261. */
  109262. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  109263. /**
  109264. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109265. */
  109266. readonly capacity: number;
  109267. /**
  109268. * Gets the minimum vector (in world space) of the block's bounding box
  109269. */
  109270. readonly minPoint: Vector3;
  109271. /**
  109272. * Gets the maximum vector (in world space) of the block's bounding box
  109273. */
  109274. readonly maxPoint: Vector3;
  109275. /**
  109276. * Add a new element to this block
  109277. * @param entry defines the element to add
  109278. */
  109279. addEntry(entry: T): void;
  109280. /**
  109281. * Remove an element from this block
  109282. * @param entry defines the element to remove
  109283. */
  109284. removeEntry(entry: T): void;
  109285. /**
  109286. * Add an array of elements to this block
  109287. * @param entries defines the array of elements to add
  109288. */
  109289. addEntries(entries: T[]): void;
  109290. /**
  109291. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  109292. * @param frustumPlanes defines the frustum planes to test
  109293. * @param selection defines the array to store current content if selection is positive
  109294. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109295. */
  109296. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109297. /**
  109298. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  109299. * @param sphereCenter defines the bounding sphere center
  109300. * @param sphereRadius defines the bounding sphere radius
  109301. * @param selection defines the array to store current content if selection is positive
  109302. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109303. */
  109304. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109305. /**
  109306. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  109307. * @param ray defines the ray to test with
  109308. * @param selection defines the array to store current content if selection is positive
  109309. */
  109310. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  109311. /**
  109312. * Subdivide the content into child blocks (this block will then be empty)
  109313. */
  109314. createInnerBlocks(): void;
  109315. /**
  109316. * @hidden
  109317. */
  109318. 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;
  109319. }
  109320. }
  109321. declare module BABYLON {
  109322. /**
  109323. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  109324. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109325. */
  109326. export class Octree<T> {
  109327. /** 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.) */
  109328. maxDepth: number;
  109329. /**
  109330. * Blocks within the octree containing objects
  109331. */
  109332. blocks: Array<OctreeBlock<T>>;
  109333. /**
  109334. * Content stored in the octree
  109335. */
  109336. dynamicContent: T[];
  109337. private _maxBlockCapacity;
  109338. private _selectionContent;
  109339. private _creationFunc;
  109340. /**
  109341. * Creates a octree
  109342. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109343. * @param creationFunc function to be used to instatiate the octree
  109344. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  109345. * @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.)
  109346. */
  109347. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  109348. /** 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.) */
  109349. maxDepth?: number);
  109350. /**
  109351. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  109352. * @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);
  109353. * @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);
  109354. * @param entries meshes to be added to the octree blocks
  109355. */
  109356. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  109357. /**
  109358. * Adds a mesh to the octree
  109359. * @param entry Mesh to add to the octree
  109360. */
  109361. addMesh(entry: T): void;
  109362. /**
  109363. * Remove an element from the octree
  109364. * @param entry defines the element to remove
  109365. */
  109366. removeMesh(entry: T): void;
  109367. /**
  109368. * Selects an array of meshes within the frustum
  109369. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  109370. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  109371. * @returns array of meshes within the frustum
  109372. */
  109373. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  109374. /**
  109375. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  109376. * @param sphereCenter defines the bounding sphere center
  109377. * @param sphereRadius defines the bounding sphere radius
  109378. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109379. * @returns an array of objects that intersect the sphere
  109380. */
  109381. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  109382. /**
  109383. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  109384. * @param ray defines the ray to test with
  109385. * @returns array of intersected objects
  109386. */
  109387. intersectsRay(ray: Ray): SmartArray<T>;
  109388. /**
  109389. * Adds a mesh into the octree block if it intersects the block
  109390. */
  109391. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  109392. /**
  109393. * Adds a submesh into the octree block if it intersects the block
  109394. */
  109395. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  109396. }
  109397. }
  109398. declare module BABYLON {
  109399. interface Scene {
  109400. /**
  109401. * @hidden
  109402. * Backing Filed
  109403. */
  109404. _selectionOctree: Octree<AbstractMesh>;
  109405. /**
  109406. * Gets the octree used to boost mesh selection (picking)
  109407. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109408. */
  109409. selectionOctree: Octree<AbstractMesh>;
  109410. /**
  109411. * Creates or updates the octree used to boost selection (picking)
  109412. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109413. * @param maxCapacity defines the maximum capacity per leaf
  109414. * @param maxDepth defines the maximum depth of the octree
  109415. * @returns an octree of AbstractMesh
  109416. */
  109417. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  109418. }
  109419. interface AbstractMesh {
  109420. /**
  109421. * @hidden
  109422. * Backing Field
  109423. */
  109424. _submeshesOctree: Octree<SubMesh>;
  109425. /**
  109426. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  109427. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  109428. * @param maxCapacity defines the maximum size of each block (64 by default)
  109429. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  109430. * @returns the new octree
  109431. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  109432. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109433. */
  109434. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  109435. }
  109436. /**
  109437. * Defines the octree scene component responsible to manage any octrees
  109438. * in a given scene.
  109439. */
  109440. export class OctreeSceneComponent {
  109441. /**
  109442. * The component name help to identify the component in the list of scene components.
  109443. */
  109444. readonly name: string;
  109445. /**
  109446. * The scene the component belongs to.
  109447. */
  109448. scene: Scene;
  109449. /**
  109450. * Indicates if the meshes have been checked to make sure they are isEnabled()
  109451. */
  109452. readonly checksIsEnabled: boolean;
  109453. /**
  109454. * Creates a new instance of the component for the given scene
  109455. * @param scene Defines the scene to register the component in
  109456. */
  109457. constructor(scene: Scene);
  109458. /**
  109459. * Registers the component in a given scene
  109460. */
  109461. register(): void;
  109462. /**
  109463. * Return the list of active meshes
  109464. * @returns the list of active meshes
  109465. */
  109466. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109467. /**
  109468. * Return the list of active sub meshes
  109469. * @param mesh The mesh to get the candidates sub meshes from
  109470. * @returns the list of active sub meshes
  109471. */
  109472. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109473. private _tempRay;
  109474. /**
  109475. * Return the list of sub meshes intersecting with a given local ray
  109476. * @param mesh defines the mesh to find the submesh for
  109477. * @param localRay defines the ray in local space
  109478. * @returns the list of intersecting sub meshes
  109479. */
  109480. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  109481. /**
  109482. * Return the list of sub meshes colliding with a collider
  109483. * @param mesh defines the mesh to find the submesh for
  109484. * @param collider defines the collider to evaluate the collision against
  109485. * @returns the list of colliding sub meshes
  109486. */
  109487. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  109488. /**
  109489. * Rebuilds the elements related to this component in case of
  109490. * context lost for instance.
  109491. */
  109492. rebuild(): void;
  109493. /**
  109494. * Disposes the component and the associated ressources.
  109495. */
  109496. dispose(): void;
  109497. }
  109498. }
  109499. declare module BABYLON {
  109500. /**
  109501. * Renders a layer on top of an existing scene
  109502. */
  109503. export class UtilityLayerRenderer implements IDisposable {
  109504. /** the original scene that will be rendered on top of */
  109505. originalScene: Scene;
  109506. private _pointerCaptures;
  109507. private _lastPointerEvents;
  109508. private static _DefaultUtilityLayer;
  109509. private static _DefaultKeepDepthUtilityLayer;
  109510. private _sharedGizmoLight;
  109511. private _renderCamera;
  109512. /**
  109513. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  109514. * @returns the camera that is used when rendering the utility layer
  109515. */
  109516. getRenderCamera(): Nullable<Camera>;
  109517. /**
  109518. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  109519. * @param cam the camera that should be used when rendering the utility layer
  109520. */
  109521. setRenderCamera(cam: Nullable<Camera>): void;
  109522. /**
  109523. * @hidden
  109524. * Light which used by gizmos to get light shading
  109525. */
  109526. _getSharedGizmoLight(): HemisphericLight;
  109527. /**
  109528. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  109529. */
  109530. pickUtilitySceneFirst: boolean;
  109531. /**
  109532. * 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)
  109533. */
  109534. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  109535. /**
  109536. * 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)
  109537. */
  109538. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  109539. /**
  109540. * The scene that is rendered on top of the original scene
  109541. */
  109542. utilityLayerScene: Scene;
  109543. /**
  109544. * If the utility layer should automatically be rendered on top of existing scene
  109545. */
  109546. shouldRender: boolean;
  109547. /**
  109548. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  109549. */
  109550. onlyCheckPointerDownEvents: boolean;
  109551. /**
  109552. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  109553. */
  109554. processAllEvents: boolean;
  109555. /**
  109556. * Observable raised when the pointer move from the utility layer scene to the main scene
  109557. */
  109558. onPointerOutObservable: Observable<number>;
  109559. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  109560. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  109561. private _afterRenderObserver;
  109562. private _sceneDisposeObserver;
  109563. private _originalPointerObserver;
  109564. /**
  109565. * Instantiates a UtilityLayerRenderer
  109566. * @param originalScene the original scene that will be rendered on top of
  109567. * @param handleEvents boolean indicating if the utility layer should handle events
  109568. */
  109569. constructor(
  109570. /** the original scene that will be rendered on top of */
  109571. originalScene: Scene, handleEvents?: boolean);
  109572. private _notifyObservers;
  109573. /**
  109574. * Renders the utility layers scene on top of the original scene
  109575. */
  109576. render(): void;
  109577. /**
  109578. * Disposes of the renderer
  109579. */
  109580. dispose(): void;
  109581. private _updateCamera;
  109582. }
  109583. }
  109584. declare module BABYLON {
  109585. /**
  109586. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  109587. */
  109588. export class Gizmo implements IDisposable {
  109589. /** The utility layer the gizmo will be added to */
  109590. gizmoLayer: UtilityLayerRenderer;
  109591. /**
  109592. * The root mesh of the gizmo
  109593. */
  109594. _rootMesh: Mesh;
  109595. private _attachedMesh;
  109596. /**
  109597. * Ratio for the scale of the gizmo (Default: 1)
  109598. */
  109599. scaleRatio: number;
  109600. /**
  109601. * If a custom mesh has been set (Default: false)
  109602. */
  109603. protected _customMeshSet: boolean;
  109604. /**
  109605. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  109606. * * When set, interactions will be enabled
  109607. */
  109608. attachedMesh: Nullable<AbstractMesh>;
  109609. /**
  109610. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  109611. * @param mesh The mesh to replace the default mesh of the gizmo
  109612. */
  109613. setCustomMesh(mesh: Mesh): void;
  109614. /**
  109615. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  109616. */
  109617. updateGizmoRotationToMatchAttachedMesh: boolean;
  109618. /**
  109619. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  109620. */
  109621. updateGizmoPositionToMatchAttachedMesh: boolean;
  109622. /**
  109623. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  109624. */
  109625. updateScale: boolean;
  109626. protected _interactionsEnabled: boolean;
  109627. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109628. private _beforeRenderObserver;
  109629. private _tempVector;
  109630. /**
  109631. * Creates a gizmo
  109632. * @param gizmoLayer The utility layer the gizmo will be added to
  109633. */
  109634. constructor(
  109635. /** The utility layer the gizmo will be added to */
  109636. gizmoLayer?: UtilityLayerRenderer);
  109637. /**
  109638. * Updates the gizmo to match the attached mesh's position/rotation
  109639. */
  109640. protected _update(): void;
  109641. /**
  109642. * Disposes of the gizmo
  109643. */
  109644. dispose(): void;
  109645. }
  109646. }
  109647. declare module BABYLON {
  109648. /**
  109649. * Single plane drag gizmo
  109650. */
  109651. export class PlaneDragGizmo extends Gizmo {
  109652. /**
  109653. * Drag behavior responsible for the gizmos dragging interactions
  109654. */
  109655. dragBehavior: PointerDragBehavior;
  109656. private _pointerObserver;
  109657. /**
  109658. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109659. */
  109660. snapDistance: number;
  109661. /**
  109662. * Event that fires each time the gizmo snaps to a new location.
  109663. * * snapDistance is the the change in distance
  109664. */
  109665. onSnapObservable: Observable<{
  109666. snapDistance: number;
  109667. }>;
  109668. private _plane;
  109669. private _coloredMaterial;
  109670. private _hoverMaterial;
  109671. private _isEnabled;
  109672. private _parent;
  109673. /** @hidden */
  109674. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  109675. /** @hidden */
  109676. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109677. /**
  109678. * Creates a PlaneDragGizmo
  109679. * @param gizmoLayer The utility layer the gizmo will be added to
  109680. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  109681. * @param color The color of the gizmo
  109682. */
  109683. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109684. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109685. /**
  109686. * If the gizmo is enabled
  109687. */
  109688. isEnabled: boolean;
  109689. /**
  109690. * Disposes of the gizmo
  109691. */
  109692. dispose(): void;
  109693. }
  109694. }
  109695. declare module BABYLON {
  109696. /**
  109697. * Gizmo that enables dragging a mesh along 3 axis
  109698. */
  109699. export class PositionGizmo extends Gizmo {
  109700. /**
  109701. * Internal gizmo used for interactions on the x axis
  109702. */
  109703. xGizmo: AxisDragGizmo;
  109704. /**
  109705. * Internal gizmo used for interactions on the y axis
  109706. */
  109707. yGizmo: AxisDragGizmo;
  109708. /**
  109709. * Internal gizmo used for interactions on the z axis
  109710. */
  109711. zGizmo: AxisDragGizmo;
  109712. /**
  109713. * Internal gizmo used for interactions on the yz plane
  109714. */
  109715. xPlaneGizmo: PlaneDragGizmo;
  109716. /**
  109717. * Internal gizmo used for interactions on the xz plane
  109718. */
  109719. yPlaneGizmo: PlaneDragGizmo;
  109720. /**
  109721. * Internal gizmo used for interactions on the xy plane
  109722. */
  109723. zPlaneGizmo: PlaneDragGizmo;
  109724. /**
  109725. * private variables
  109726. */
  109727. private _meshAttached;
  109728. private _updateGizmoRotationToMatchAttachedMesh;
  109729. private _snapDistance;
  109730. private _scaleRatio;
  109731. /** Fires an event when any of it's sub gizmos are dragged */
  109732. onDragStartObservable: Observable<unknown>;
  109733. /** Fires an event when any of it's sub gizmos are released from dragging */
  109734. onDragEndObservable: Observable<unknown>;
  109735. /**
  109736. * If set to true, planar drag is enabled
  109737. */
  109738. private _planarGizmoEnabled;
  109739. attachedMesh: Nullable<AbstractMesh>;
  109740. /**
  109741. * Creates a PositionGizmo
  109742. * @param gizmoLayer The utility layer the gizmo will be added to
  109743. */
  109744. constructor(gizmoLayer?: UtilityLayerRenderer);
  109745. /**
  109746. * If the planar drag gizmo is enabled
  109747. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  109748. */
  109749. planarGizmoEnabled: boolean;
  109750. updateGizmoRotationToMatchAttachedMesh: boolean;
  109751. /**
  109752. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109753. */
  109754. snapDistance: number;
  109755. /**
  109756. * Ratio for the scale of the gizmo (Default: 1)
  109757. */
  109758. scaleRatio: number;
  109759. /**
  109760. * Disposes of the gizmo
  109761. */
  109762. dispose(): void;
  109763. /**
  109764. * CustomMeshes are not supported by this gizmo
  109765. * @param mesh The mesh to replace the default mesh of the gizmo
  109766. */
  109767. setCustomMesh(mesh: Mesh): void;
  109768. }
  109769. }
  109770. declare module BABYLON {
  109771. /**
  109772. * Single axis drag gizmo
  109773. */
  109774. export class AxisDragGizmo extends Gizmo {
  109775. /**
  109776. * Drag behavior responsible for the gizmos dragging interactions
  109777. */
  109778. dragBehavior: PointerDragBehavior;
  109779. private _pointerObserver;
  109780. /**
  109781. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109782. */
  109783. snapDistance: number;
  109784. /**
  109785. * Event that fires each time the gizmo snaps to a new location.
  109786. * * snapDistance is the the change in distance
  109787. */
  109788. onSnapObservable: Observable<{
  109789. snapDistance: number;
  109790. }>;
  109791. private _isEnabled;
  109792. private _parent;
  109793. private _arrow;
  109794. private _coloredMaterial;
  109795. private _hoverMaterial;
  109796. /** @hidden */
  109797. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  109798. /** @hidden */
  109799. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109800. /**
  109801. * Creates an AxisDragGizmo
  109802. * @param gizmoLayer The utility layer the gizmo will be added to
  109803. * @param dragAxis The axis which the gizmo will be able to drag on
  109804. * @param color The color of the gizmo
  109805. */
  109806. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109807. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109808. /**
  109809. * If the gizmo is enabled
  109810. */
  109811. isEnabled: boolean;
  109812. /**
  109813. * Disposes of the gizmo
  109814. */
  109815. dispose(): void;
  109816. }
  109817. }
  109818. declare module BABYLON.Debug {
  109819. /**
  109820. * The Axes viewer will show 3 axes in a specific point in space
  109821. */
  109822. export class AxesViewer {
  109823. private _xAxis;
  109824. private _yAxis;
  109825. private _zAxis;
  109826. private _scaleLinesFactor;
  109827. private _instanced;
  109828. /**
  109829. * Gets the hosting scene
  109830. */
  109831. scene: Scene;
  109832. /**
  109833. * Gets or sets a number used to scale line length
  109834. */
  109835. scaleLines: number;
  109836. /** Gets the node hierarchy used to render x-axis */
  109837. readonly xAxis: TransformNode;
  109838. /** Gets the node hierarchy used to render y-axis */
  109839. readonly yAxis: TransformNode;
  109840. /** Gets the node hierarchy used to render z-axis */
  109841. readonly zAxis: TransformNode;
  109842. /**
  109843. * Creates a new AxesViewer
  109844. * @param scene defines the hosting scene
  109845. * @param scaleLines defines a number used to scale line length (1 by default)
  109846. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  109847. * @param xAxis defines the node hierarchy used to render the x-axis
  109848. * @param yAxis defines the node hierarchy used to render the y-axis
  109849. * @param zAxis defines the node hierarchy used to render the z-axis
  109850. */
  109851. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  109852. /**
  109853. * Force the viewer to update
  109854. * @param position defines the position of the viewer
  109855. * @param xaxis defines the x axis of the viewer
  109856. * @param yaxis defines the y axis of the viewer
  109857. * @param zaxis defines the z axis of the viewer
  109858. */
  109859. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  109860. /**
  109861. * Creates an instance of this axes viewer.
  109862. * @returns a new axes viewer with instanced meshes
  109863. */
  109864. createInstance(): AxesViewer;
  109865. /** Releases resources */
  109866. dispose(): void;
  109867. private static _SetRenderingGroupId;
  109868. }
  109869. }
  109870. declare module BABYLON.Debug {
  109871. /**
  109872. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  109873. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  109874. */
  109875. export class BoneAxesViewer extends AxesViewer {
  109876. /**
  109877. * Gets or sets the target mesh where to display the axes viewer
  109878. */
  109879. mesh: Nullable<Mesh>;
  109880. /**
  109881. * Gets or sets the target bone where to display the axes viewer
  109882. */
  109883. bone: Nullable<Bone>;
  109884. /** Gets current position */
  109885. pos: Vector3;
  109886. /** Gets direction of X axis */
  109887. xaxis: Vector3;
  109888. /** Gets direction of Y axis */
  109889. yaxis: Vector3;
  109890. /** Gets direction of Z axis */
  109891. zaxis: Vector3;
  109892. /**
  109893. * Creates a new BoneAxesViewer
  109894. * @param scene defines the hosting scene
  109895. * @param bone defines the target bone
  109896. * @param mesh defines the target mesh
  109897. * @param scaleLines defines a scaling factor for line length (1 by default)
  109898. */
  109899. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  109900. /**
  109901. * Force the viewer to update
  109902. */
  109903. update(): void;
  109904. /** Releases resources */
  109905. dispose(): void;
  109906. }
  109907. }
  109908. declare module BABYLON {
  109909. /**
  109910. * Interface used to define scene explorer extensibility option
  109911. */
  109912. export interface IExplorerExtensibilityOption {
  109913. /**
  109914. * Define the option label
  109915. */
  109916. label: string;
  109917. /**
  109918. * Defines the action to execute on click
  109919. */
  109920. action: (entity: any) => void;
  109921. }
  109922. /**
  109923. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  109924. */
  109925. export interface IExplorerExtensibilityGroup {
  109926. /**
  109927. * Defines a predicate to test if a given type mut be extended
  109928. */
  109929. predicate: (entity: any) => boolean;
  109930. /**
  109931. * Gets the list of options added to a type
  109932. */
  109933. entries: IExplorerExtensibilityOption[];
  109934. }
  109935. /**
  109936. * Interface used to define the options to use to create the Inspector
  109937. */
  109938. export interface IInspectorOptions {
  109939. /**
  109940. * Display in overlay mode (default: false)
  109941. */
  109942. overlay?: boolean;
  109943. /**
  109944. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  109945. */
  109946. globalRoot?: HTMLElement;
  109947. /**
  109948. * Display the Scene explorer
  109949. */
  109950. showExplorer?: boolean;
  109951. /**
  109952. * Display the property inspector
  109953. */
  109954. showInspector?: boolean;
  109955. /**
  109956. * Display in embed mode (both panes on the right)
  109957. */
  109958. embedMode?: boolean;
  109959. /**
  109960. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  109961. */
  109962. handleResize?: boolean;
  109963. /**
  109964. * Allow the panes to popup (default: true)
  109965. */
  109966. enablePopup?: boolean;
  109967. /**
  109968. * Allow the panes to be closed by users (default: true)
  109969. */
  109970. enableClose?: boolean;
  109971. /**
  109972. * Optional list of extensibility entries
  109973. */
  109974. explorerExtensibility?: IExplorerExtensibilityGroup[];
  109975. /**
  109976. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  109977. */
  109978. inspectorURL?: string;
  109979. }
  109980. interface Scene {
  109981. /**
  109982. * @hidden
  109983. * Backing field
  109984. */
  109985. _debugLayer: DebugLayer;
  109986. /**
  109987. * Gets the debug layer (aka Inspector) associated with the scene
  109988. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109989. */
  109990. debugLayer: DebugLayer;
  109991. }
  109992. /**
  109993. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109994. * what is happening in your scene
  109995. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109996. */
  109997. export class DebugLayer {
  109998. /**
  109999. * Define the url to get the inspector script from.
  110000. * By default it uses the babylonjs CDN.
  110001. * @ignoreNaming
  110002. */
  110003. static InspectorURL: string;
  110004. private _scene;
  110005. private BJSINSPECTOR;
  110006. private _onPropertyChangedObservable?;
  110007. /**
  110008. * Observable triggered when a property is changed through the inspector.
  110009. */
  110010. readonly onPropertyChangedObservable: any;
  110011. /**
  110012. * Instantiates a new debug layer.
  110013. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110014. * what is happening in your scene
  110015. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110016. * @param scene Defines the scene to inspect
  110017. */
  110018. constructor(scene: Scene);
  110019. /** Creates the inspector window. */
  110020. private _createInspector;
  110021. /**
  110022. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  110023. * @param entity defines the entity to select
  110024. * @param lineContainerTitle defines the specific block to highlight
  110025. */
  110026. select(entity: any, lineContainerTitle?: string): void;
  110027. /** Get the inspector from bundle or global */
  110028. private _getGlobalInspector;
  110029. /**
  110030. * Get if the inspector is visible or not.
  110031. * @returns true if visible otherwise, false
  110032. */
  110033. isVisible(): boolean;
  110034. /**
  110035. * Hide the inspector and close its window.
  110036. */
  110037. hide(): void;
  110038. /**
  110039. * Launch the debugLayer.
  110040. * @param config Define the configuration of the inspector
  110041. * @return a promise fulfilled when the debug layer is visible
  110042. */
  110043. show(config?: IInspectorOptions): Promise<DebugLayer>;
  110044. }
  110045. }
  110046. declare module BABYLON {
  110047. /**
  110048. * Class containing static functions to help procedurally build meshes
  110049. */
  110050. export class BoxBuilder {
  110051. /**
  110052. * Creates a box mesh
  110053. * * The parameter `size` sets the size (float) of each box side (default 1)
  110054. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110055. * * 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)
  110056. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110058. * * 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
  110059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110060. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110061. * @param name defines the name of the mesh
  110062. * @param options defines the options used to create the mesh
  110063. * @param scene defines the hosting scene
  110064. * @returns the box mesh
  110065. */
  110066. static CreateBox(name: string, options: {
  110067. size?: number;
  110068. width?: number;
  110069. height?: number;
  110070. depth?: number;
  110071. faceUV?: Vector4[];
  110072. faceColors?: Color4[];
  110073. sideOrientation?: number;
  110074. frontUVs?: Vector4;
  110075. backUVs?: Vector4;
  110076. wrap?: boolean;
  110077. topBaseAt?: number;
  110078. bottomBaseAt?: number;
  110079. updatable?: boolean;
  110080. }, scene?: Nullable<Scene>): Mesh;
  110081. }
  110082. }
  110083. declare module BABYLON {
  110084. /**
  110085. * Class containing static functions to help procedurally build meshes
  110086. */
  110087. export class SphereBuilder {
  110088. /**
  110089. * Creates a sphere mesh
  110090. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110091. * * 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`)
  110092. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110093. * * 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
  110094. * * 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)
  110095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110096. * * 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
  110097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110098. * @param name defines the name of the mesh
  110099. * @param options defines the options used to create the mesh
  110100. * @param scene defines the hosting scene
  110101. * @returns the sphere mesh
  110102. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110103. */
  110104. static CreateSphere(name: string, options: {
  110105. segments?: number;
  110106. diameter?: number;
  110107. diameterX?: number;
  110108. diameterY?: number;
  110109. diameterZ?: number;
  110110. arc?: number;
  110111. slice?: number;
  110112. sideOrientation?: number;
  110113. frontUVs?: Vector4;
  110114. backUVs?: Vector4;
  110115. updatable?: boolean;
  110116. }, scene?: Nullable<Scene>): Mesh;
  110117. }
  110118. }
  110119. declare module BABYLON.Debug {
  110120. /**
  110121. * Used to show the physics impostor around the specific mesh
  110122. */
  110123. export class PhysicsViewer {
  110124. /** @hidden */
  110125. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  110126. /** @hidden */
  110127. protected _meshes: Array<Nullable<AbstractMesh>>;
  110128. /** @hidden */
  110129. protected _scene: Nullable<Scene>;
  110130. /** @hidden */
  110131. protected _numMeshes: number;
  110132. /** @hidden */
  110133. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110134. private _renderFunction;
  110135. private _utilityLayer;
  110136. private _debugBoxMesh;
  110137. private _debugSphereMesh;
  110138. private _debugCylinderMesh;
  110139. private _debugMaterial;
  110140. private _debugMeshMeshes;
  110141. /**
  110142. * Creates a new PhysicsViewer
  110143. * @param scene defines the hosting scene
  110144. */
  110145. constructor(scene: Scene);
  110146. /** @hidden */
  110147. protected _updateDebugMeshes(): void;
  110148. /**
  110149. * Renders a specified physic impostor
  110150. * @param impostor defines the impostor to render
  110151. * @param targetMesh defines the mesh represented by the impostor
  110152. * @returns the new debug mesh used to render the impostor
  110153. */
  110154. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110155. /**
  110156. * Hides a specified physic impostor
  110157. * @param impostor defines the impostor to hide
  110158. */
  110159. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110160. private _getDebugMaterial;
  110161. private _getDebugBoxMesh;
  110162. private _getDebugSphereMesh;
  110163. private _getDebugCylinderMesh;
  110164. private _getDebugMeshMesh;
  110165. private _getDebugMesh;
  110166. /** Releases all resources */
  110167. dispose(): void;
  110168. }
  110169. }
  110170. declare module BABYLON {
  110171. /**
  110172. * Class containing static functions to help procedurally build meshes
  110173. */
  110174. export class LinesBuilder {
  110175. /**
  110176. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110177. * * 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
  110178. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110179. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110180. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110181. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110182. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110183. * * 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
  110184. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110186. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110187. * @param name defines the name of the new line system
  110188. * @param options defines the options used to create the line system
  110189. * @param scene defines the hosting scene
  110190. * @returns a new line system mesh
  110191. */
  110192. static CreateLineSystem(name: string, options: {
  110193. lines: Vector3[][];
  110194. updatable?: boolean;
  110195. instance?: Nullable<LinesMesh>;
  110196. colors?: Nullable<Color4[][]>;
  110197. useVertexAlpha?: boolean;
  110198. }, scene: Nullable<Scene>): LinesMesh;
  110199. /**
  110200. * Creates a line mesh
  110201. * 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
  110202. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110203. * * The parameter `points` is an array successive Vector3
  110204. * * 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
  110205. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110206. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110207. * * When updating an instance, remember that only point positions can change, not the number of points
  110208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110209. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110210. * @param name defines the name of the new line system
  110211. * @param options defines the options used to create the line system
  110212. * @param scene defines the hosting scene
  110213. * @returns a new line mesh
  110214. */
  110215. static CreateLines(name: string, options: {
  110216. points: Vector3[];
  110217. updatable?: boolean;
  110218. instance?: Nullable<LinesMesh>;
  110219. colors?: Color4[];
  110220. useVertexAlpha?: boolean;
  110221. }, scene?: Nullable<Scene>): LinesMesh;
  110222. /**
  110223. * Creates a dashed line mesh
  110224. * * 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
  110225. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110226. * * The parameter `points` is an array successive Vector3
  110227. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110228. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110229. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110230. * * 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
  110231. * * When updating an instance, remember that only point positions can change, not the number of points
  110232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110233. * @param name defines the name of the mesh
  110234. * @param options defines the options used to create the mesh
  110235. * @param scene defines the hosting scene
  110236. * @returns the dashed line mesh
  110237. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110238. */
  110239. static CreateDashedLines(name: string, options: {
  110240. points: Vector3[];
  110241. dashSize?: number;
  110242. gapSize?: number;
  110243. dashNb?: number;
  110244. updatable?: boolean;
  110245. instance?: LinesMesh;
  110246. }, scene?: Nullable<Scene>): LinesMesh;
  110247. }
  110248. }
  110249. declare module BABYLON {
  110250. /**
  110251. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110252. * in order to better appreciate the issue one might have.
  110253. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110254. */
  110255. export class RayHelper {
  110256. /**
  110257. * Defines the ray we are currently tryin to visualize.
  110258. */
  110259. ray: Nullable<Ray>;
  110260. private _renderPoints;
  110261. private _renderLine;
  110262. private _renderFunction;
  110263. private _scene;
  110264. private _updateToMeshFunction;
  110265. private _attachedToMesh;
  110266. private _meshSpaceDirection;
  110267. private _meshSpaceOrigin;
  110268. /**
  110269. * Helper function to create a colored helper in a scene in one line.
  110270. * @param ray Defines the ray we are currently tryin to visualize
  110271. * @param scene Defines the scene the ray is used in
  110272. * @param color Defines the color we want to see the ray in
  110273. * @returns The newly created ray helper.
  110274. */
  110275. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  110276. /**
  110277. * Instantiate a new ray helper.
  110278. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110279. * in order to better appreciate the issue one might have.
  110280. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110281. * @param ray Defines the ray we are currently tryin to visualize
  110282. */
  110283. constructor(ray: Ray);
  110284. /**
  110285. * Shows the ray we are willing to debug.
  110286. * @param scene Defines the scene the ray needs to be rendered in
  110287. * @param color Defines the color the ray needs to be rendered in
  110288. */
  110289. show(scene: Scene, color?: Color3): void;
  110290. /**
  110291. * Hides the ray we are debugging.
  110292. */
  110293. hide(): void;
  110294. private _render;
  110295. /**
  110296. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  110297. * @param mesh Defines the mesh we want the helper attached to
  110298. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  110299. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  110300. * @param length Defines the length of the ray
  110301. */
  110302. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  110303. /**
  110304. * Detach the ray helper from the mesh it has previously been attached to.
  110305. */
  110306. detachFromMesh(): void;
  110307. private _updateToMesh;
  110308. /**
  110309. * Dispose the helper and release its associated resources.
  110310. */
  110311. dispose(): void;
  110312. }
  110313. }
  110314. declare module BABYLON.Debug {
  110315. /**
  110316. * Class used to render a debug view of a given skeleton
  110317. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  110318. */
  110319. export class SkeletonViewer {
  110320. /** defines the skeleton to render */
  110321. skeleton: Skeleton;
  110322. /** defines the mesh attached to the skeleton */
  110323. mesh: AbstractMesh;
  110324. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110325. autoUpdateBonesMatrices: boolean;
  110326. /** defines the rendering group id to use with the viewer */
  110327. renderingGroupId: number;
  110328. /** Gets or sets the color used to render the skeleton */
  110329. color: Color3;
  110330. private _scene;
  110331. private _debugLines;
  110332. private _debugMesh;
  110333. private _isEnabled;
  110334. private _renderFunction;
  110335. private _utilityLayer;
  110336. /**
  110337. * Returns the mesh used to render the bones
  110338. */
  110339. readonly debugMesh: Nullable<LinesMesh>;
  110340. /**
  110341. * Creates a new SkeletonViewer
  110342. * @param skeleton defines the skeleton to render
  110343. * @param mesh defines the mesh attached to the skeleton
  110344. * @param scene defines the hosting scene
  110345. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  110346. * @param renderingGroupId defines the rendering group id to use with the viewer
  110347. */
  110348. constructor(
  110349. /** defines the skeleton to render */
  110350. skeleton: Skeleton,
  110351. /** defines the mesh attached to the skeleton */
  110352. mesh: AbstractMesh, scene: Scene,
  110353. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110354. autoUpdateBonesMatrices?: boolean,
  110355. /** defines the rendering group id to use with the viewer */
  110356. renderingGroupId?: number);
  110357. /** Gets or sets a boolean indicating if the viewer is enabled */
  110358. isEnabled: boolean;
  110359. private _getBonePosition;
  110360. private _getLinesForBonesWithLength;
  110361. private _getLinesForBonesNoLength;
  110362. /** Update the viewer to sync with current skeleton state */
  110363. update(): void;
  110364. /** Release associated resources */
  110365. dispose(): void;
  110366. }
  110367. }
  110368. declare module BABYLON {
  110369. /**
  110370. * Options to create the null engine
  110371. */
  110372. export class NullEngineOptions {
  110373. /**
  110374. * Render width (Default: 512)
  110375. */
  110376. renderWidth: number;
  110377. /**
  110378. * Render height (Default: 256)
  110379. */
  110380. renderHeight: number;
  110381. /**
  110382. * Texture size (Default: 512)
  110383. */
  110384. textureSize: number;
  110385. /**
  110386. * If delta time between frames should be constant
  110387. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110388. */
  110389. deterministicLockstep: boolean;
  110390. /**
  110391. * Maximum about of steps between frames (Default: 4)
  110392. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110393. */
  110394. lockstepMaxSteps: number;
  110395. }
  110396. /**
  110397. * The null engine class provides support for headless version of babylon.js.
  110398. * This can be used in server side scenario or for testing purposes
  110399. */
  110400. export class NullEngine extends Engine {
  110401. private _options;
  110402. /**
  110403. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110404. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110405. * @returns true if engine is in deterministic lock step mode
  110406. */
  110407. isDeterministicLockStep(): boolean;
  110408. /**
  110409. * Gets the max steps when engine is running in deterministic lock step
  110410. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110411. * @returns the max steps
  110412. */
  110413. getLockstepMaxSteps(): number;
  110414. /**
  110415. * Gets the current hardware scaling level.
  110416. * By default the hardware scaling level is computed from the window device ratio.
  110417. * 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.
  110418. * @returns a number indicating the current hardware scaling level
  110419. */
  110420. getHardwareScalingLevel(): number;
  110421. constructor(options?: NullEngineOptions);
  110422. /**
  110423. * Creates a vertex buffer
  110424. * @param vertices the data for the vertex buffer
  110425. * @returns the new WebGL static buffer
  110426. */
  110427. createVertexBuffer(vertices: FloatArray): DataBuffer;
  110428. /**
  110429. * Creates a new index buffer
  110430. * @param indices defines the content of the index buffer
  110431. * @param updatable defines if the index buffer must be updatable
  110432. * @returns a new webGL buffer
  110433. */
  110434. createIndexBuffer(indices: IndicesArray): DataBuffer;
  110435. /**
  110436. * Clear the current render buffer or the current render target (if any is set up)
  110437. * @param color defines the color to use
  110438. * @param backBuffer defines if the back buffer must be cleared
  110439. * @param depth defines if the depth buffer must be cleared
  110440. * @param stencil defines if the stencil buffer must be cleared
  110441. */
  110442. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110443. /**
  110444. * Gets the current render width
  110445. * @param useScreen defines if screen size must be used (or the current render target if any)
  110446. * @returns a number defining the current render width
  110447. */
  110448. getRenderWidth(useScreen?: boolean): number;
  110449. /**
  110450. * Gets the current render height
  110451. * @param useScreen defines if screen size must be used (or the current render target if any)
  110452. * @returns a number defining the current render height
  110453. */
  110454. getRenderHeight(useScreen?: boolean): number;
  110455. /**
  110456. * Set the WebGL's viewport
  110457. * @param viewport defines the viewport element to be used
  110458. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  110459. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  110460. */
  110461. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  110462. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  110463. /**
  110464. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  110465. * @param pipelineContext defines the pipeline context to use
  110466. * @param uniformsNames defines the list of uniform names
  110467. * @returns an array of webGL uniform locations
  110468. */
  110469. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  110470. /**
  110471. * Gets the lsit of active attributes for a given webGL program
  110472. * @param pipelineContext defines the pipeline context to use
  110473. * @param attributesNames defines the list of attribute names to get
  110474. * @returns an array of indices indicating the offset of each attribute
  110475. */
  110476. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110477. /**
  110478. * Binds an effect to the webGL context
  110479. * @param effect defines the effect to bind
  110480. */
  110481. bindSamplers(effect: Effect): void;
  110482. /**
  110483. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  110484. * @param effect defines the effect to activate
  110485. */
  110486. enableEffect(effect: Effect): void;
  110487. /**
  110488. * Set various states to the webGL context
  110489. * @param culling defines backface culling state
  110490. * @param zOffset defines the value to apply to zOffset (0 by default)
  110491. * @param force defines if states must be applied even if cache is up to date
  110492. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110493. */
  110494. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110495. /**
  110496. * Set the value of an uniform to an array of int32
  110497. * @param uniform defines the webGL uniform location where to store the value
  110498. * @param array defines the array of int32 to store
  110499. */
  110500. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110501. /**
  110502. * Set the value of an uniform to an array of int32 (stored as vec2)
  110503. * @param uniform defines the webGL uniform location where to store the value
  110504. * @param array defines the array of int32 to store
  110505. */
  110506. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110507. /**
  110508. * Set the value of an uniform to an array of int32 (stored as vec3)
  110509. * @param uniform defines the webGL uniform location where to store the value
  110510. * @param array defines the array of int32 to store
  110511. */
  110512. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110513. /**
  110514. * Set the value of an uniform to an array of int32 (stored as vec4)
  110515. * @param uniform defines the webGL uniform location where to store the value
  110516. * @param array defines the array of int32 to store
  110517. */
  110518. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110519. /**
  110520. * Set the value of an uniform to an array of float32
  110521. * @param uniform defines the webGL uniform location where to store the value
  110522. * @param array defines the array of float32 to store
  110523. */
  110524. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110525. /**
  110526. * Set the value of an uniform to an array of float32 (stored as vec2)
  110527. * @param uniform defines the webGL uniform location where to store the value
  110528. * @param array defines the array of float32 to store
  110529. */
  110530. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110531. /**
  110532. * Set the value of an uniform to an array of float32 (stored as vec3)
  110533. * @param uniform defines the webGL uniform location where to store the value
  110534. * @param array defines the array of float32 to store
  110535. */
  110536. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110537. /**
  110538. * Set the value of an uniform to an array of float32 (stored as vec4)
  110539. * @param uniform defines the webGL uniform location where to store the value
  110540. * @param array defines the array of float32 to store
  110541. */
  110542. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110543. /**
  110544. * Set the value of an uniform to an array of number
  110545. * @param uniform defines the webGL uniform location where to store the value
  110546. * @param array defines the array of number to store
  110547. */
  110548. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110549. /**
  110550. * Set the value of an uniform to an array of number (stored as vec2)
  110551. * @param uniform defines the webGL uniform location where to store the value
  110552. * @param array defines the array of number to store
  110553. */
  110554. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110555. /**
  110556. * Set the value of an uniform to an array of number (stored as vec3)
  110557. * @param uniform defines the webGL uniform location where to store the value
  110558. * @param array defines the array of number to store
  110559. */
  110560. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110561. /**
  110562. * Set the value of an uniform to an array of number (stored as vec4)
  110563. * @param uniform defines the webGL uniform location where to store the value
  110564. * @param array defines the array of number to store
  110565. */
  110566. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110567. /**
  110568. * Set the value of an uniform to an array of float32 (stored as matrices)
  110569. * @param uniform defines the webGL uniform location where to store the value
  110570. * @param matrices defines the array of float32 to store
  110571. */
  110572. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110573. /**
  110574. * Set the value of an uniform to a matrix (3x3)
  110575. * @param uniform defines the webGL uniform location where to store the value
  110576. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  110577. */
  110578. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110579. /**
  110580. * Set the value of an uniform to a matrix (2x2)
  110581. * @param uniform defines the webGL uniform location where to store the value
  110582. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  110583. */
  110584. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110585. /**
  110586. * Set the value of an uniform to a number (float)
  110587. * @param uniform defines the webGL uniform location where to store the value
  110588. * @param value defines the float number to store
  110589. */
  110590. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110591. /**
  110592. * Set the value of an uniform to a vec2
  110593. * @param uniform defines the webGL uniform location where to store the value
  110594. * @param x defines the 1st component of the value
  110595. * @param y defines the 2nd component of the value
  110596. */
  110597. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110598. /**
  110599. * Set the value of an uniform to a vec3
  110600. * @param uniform defines the webGL uniform location where to store the value
  110601. * @param x defines the 1st component of the value
  110602. * @param y defines the 2nd component of the value
  110603. * @param z defines the 3rd component of the value
  110604. */
  110605. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110606. /**
  110607. * Set the value of an uniform to a boolean
  110608. * @param uniform defines the webGL uniform location where to store the value
  110609. * @param bool defines the boolean to store
  110610. */
  110611. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110612. /**
  110613. * Set the value of an uniform to a vec4
  110614. * @param uniform defines the webGL uniform location where to store the value
  110615. * @param x defines the 1st component of the value
  110616. * @param y defines the 2nd component of the value
  110617. * @param z defines the 3rd component of the value
  110618. * @param w defines the 4th component of the value
  110619. */
  110620. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110621. /**
  110622. * Sets the current alpha mode
  110623. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  110624. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110625. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110626. */
  110627. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110628. /**
  110629. * Bind webGl buffers directly to the webGL context
  110630. * @param vertexBuffers defines the vertex buffer to bind
  110631. * @param indexBuffer defines the index buffer to bind
  110632. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  110633. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  110634. * @param effect defines the effect associated with the vertex buffer
  110635. */
  110636. bindBuffers(vertexBuffers: {
  110637. [key: string]: VertexBuffer;
  110638. }, indexBuffer: DataBuffer, effect: Effect): void;
  110639. /**
  110640. * Force the entire cache to be cleared
  110641. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  110642. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  110643. */
  110644. wipeCaches(bruteForce?: boolean): void;
  110645. /**
  110646. * Send a draw order
  110647. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  110648. * @param indexStart defines the starting index
  110649. * @param indexCount defines the number of index to draw
  110650. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110651. */
  110652. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  110653. /**
  110654. * Draw a list of indexed primitives
  110655. * @param fillMode defines the primitive to use
  110656. * @param indexStart defines the starting index
  110657. * @param indexCount defines the number of index to draw
  110658. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110659. */
  110660. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110661. /**
  110662. * Draw a list of unindexed primitives
  110663. * @param fillMode defines the primitive to use
  110664. * @param verticesStart defines the index of first vertex to draw
  110665. * @param verticesCount defines the count of vertices to draw
  110666. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110667. */
  110668. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110669. /** @hidden */
  110670. _createTexture(): WebGLTexture;
  110671. /** @hidden */
  110672. _releaseTexture(texture: InternalTexture): void;
  110673. /**
  110674. * Usually called from Texture.ts.
  110675. * Passed information to create a WebGLTexture
  110676. * @param urlArg defines a value which contains one of the following:
  110677. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110678. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110679. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110680. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110681. * @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)
  110682. * @param scene needed for loading to the correct scene
  110683. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  110684. * @param onLoad optional callback to be called upon successful completion
  110685. * @param onError optional callback to be called upon failure
  110686. * @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
  110687. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110688. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110689. * @param forcedExtension defines the extension to use to pick the right loader
  110690. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  110691. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110692. */
  110693. 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;
  110694. /**
  110695. * Creates a new render target texture
  110696. * @param size defines the size of the texture
  110697. * @param options defines the options used to create the texture
  110698. * @returns a new render target texture stored in an InternalTexture
  110699. */
  110700. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110701. /**
  110702. * Update the sampling mode of a given texture
  110703. * @param samplingMode defines the required sampling mode
  110704. * @param texture defines the texture to update
  110705. */
  110706. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110707. /**
  110708. * Binds the frame buffer to the specified texture.
  110709. * @param texture The texture to render to or null for the default canvas
  110710. * @param faceIndex The face of the texture to render to in case of cube texture
  110711. * @param requiredWidth The width of the target to render to
  110712. * @param requiredHeight The height of the target to render to
  110713. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  110714. * @param depthStencilTexture The depth stencil texture to use to render
  110715. * @param lodLevel defines le lod level to bind to the frame buffer
  110716. */
  110717. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110718. /**
  110719. * Unbind the current render target texture from the webGL context
  110720. * @param texture defines the render target texture to unbind
  110721. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110722. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110723. */
  110724. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110725. /**
  110726. * Creates a dynamic vertex buffer
  110727. * @param vertices the data for the dynamic vertex buffer
  110728. * @returns the new WebGL dynamic buffer
  110729. */
  110730. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  110731. /**
  110732. * Update the content of a dynamic texture
  110733. * @param texture defines the texture to update
  110734. * @param canvas defines the canvas containing the source
  110735. * @param invertY defines if data must be stored with Y axis inverted
  110736. * @param premulAlpha defines if alpha is stored as premultiplied
  110737. * @param format defines the format of the data
  110738. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  110739. */
  110740. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  110741. /**
  110742. * Gets a boolean indicating if all created effects are ready
  110743. * @returns true if all effects are ready
  110744. */
  110745. areAllEffectsReady(): boolean;
  110746. /**
  110747. * @hidden
  110748. * Get the current error code of the webGL context
  110749. * @returns the error code
  110750. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  110751. */
  110752. getError(): number;
  110753. /** @hidden */
  110754. _getUnpackAlignement(): number;
  110755. /** @hidden */
  110756. _unpackFlipY(value: boolean): void;
  110757. /**
  110758. * Update a dynamic index buffer
  110759. * @param indexBuffer defines the target index buffer
  110760. * @param indices defines the data to update
  110761. * @param offset defines the offset in the target index buffer where update should start
  110762. */
  110763. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  110764. /**
  110765. * Updates a dynamic vertex buffer.
  110766. * @param vertexBuffer the vertex buffer to update
  110767. * @param vertices the data used to update the vertex buffer
  110768. * @param byteOffset the byte offset of the data (optional)
  110769. * @param byteLength the byte length of the data (optional)
  110770. */
  110771. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  110772. /** @hidden */
  110773. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  110774. /** @hidden */
  110775. _bindTexture(channel: number, texture: InternalTexture): void;
  110776. protected _deleteBuffer(buffer: WebGLBuffer): void;
  110777. /**
  110778. * 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
  110779. */
  110780. releaseEffects(): void;
  110781. displayLoadingUI(): void;
  110782. hideLoadingUI(): void;
  110783. /** @hidden */
  110784. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110785. /** @hidden */
  110786. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110787. /** @hidden */
  110788. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110789. /** @hidden */
  110790. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110791. }
  110792. }
  110793. declare module BABYLON {
  110794. /** @hidden */
  110795. export class _OcclusionDataStorage {
  110796. /** @hidden */
  110797. occlusionInternalRetryCounter: number;
  110798. /** @hidden */
  110799. isOcclusionQueryInProgress: boolean;
  110800. /** @hidden */
  110801. isOccluded: boolean;
  110802. /** @hidden */
  110803. occlusionRetryCount: number;
  110804. /** @hidden */
  110805. occlusionType: number;
  110806. /** @hidden */
  110807. occlusionQueryAlgorithmType: number;
  110808. }
  110809. interface Engine {
  110810. /**
  110811. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  110812. * @return the new query
  110813. */
  110814. createQuery(): WebGLQuery;
  110815. /**
  110816. * Delete and release a webGL query
  110817. * @param query defines the query to delete
  110818. * @return the current engine
  110819. */
  110820. deleteQuery(query: WebGLQuery): Engine;
  110821. /**
  110822. * Check if a given query has resolved and got its value
  110823. * @param query defines the query to check
  110824. * @returns true if the query got its value
  110825. */
  110826. isQueryResultAvailable(query: WebGLQuery): boolean;
  110827. /**
  110828. * Gets the value of a given query
  110829. * @param query defines the query to check
  110830. * @returns the value of the query
  110831. */
  110832. getQueryResult(query: WebGLQuery): number;
  110833. /**
  110834. * Initiates an occlusion query
  110835. * @param algorithmType defines the algorithm to use
  110836. * @param query defines the query to use
  110837. * @returns the current engine
  110838. * @see http://doc.babylonjs.com/features/occlusionquery
  110839. */
  110840. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  110841. /**
  110842. * Ends an occlusion query
  110843. * @see http://doc.babylonjs.com/features/occlusionquery
  110844. * @param algorithmType defines the algorithm to use
  110845. * @returns the current engine
  110846. */
  110847. endOcclusionQuery(algorithmType: number): Engine;
  110848. /**
  110849. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  110850. * Please note that only one query can be issued at a time
  110851. * @returns a time token used to track the time span
  110852. */
  110853. startTimeQuery(): Nullable<_TimeToken>;
  110854. /**
  110855. * Ends a time query
  110856. * @param token defines the token used to measure the time span
  110857. * @returns the time spent (in ns)
  110858. */
  110859. endTimeQuery(token: _TimeToken): int;
  110860. /** @hidden */
  110861. _currentNonTimestampToken: Nullable<_TimeToken>;
  110862. /** @hidden */
  110863. _createTimeQuery(): WebGLQuery;
  110864. /** @hidden */
  110865. _deleteTimeQuery(query: WebGLQuery): void;
  110866. /** @hidden */
  110867. _getGlAlgorithmType(algorithmType: number): number;
  110868. /** @hidden */
  110869. _getTimeQueryResult(query: WebGLQuery): any;
  110870. /** @hidden */
  110871. _getTimeQueryAvailability(query: WebGLQuery): any;
  110872. }
  110873. interface AbstractMesh {
  110874. /**
  110875. * Backing filed
  110876. * @hidden
  110877. */
  110878. __occlusionDataStorage: _OcclusionDataStorage;
  110879. /**
  110880. * Access property
  110881. * @hidden
  110882. */
  110883. _occlusionDataStorage: _OcclusionDataStorage;
  110884. /**
  110885. * 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.
  110886. * The default value is -1 which means don't break the query and wait till the result
  110887. * @see http://doc.babylonjs.com/features/occlusionquery
  110888. */
  110889. occlusionRetryCount: number;
  110890. /**
  110891. * 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:
  110892. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  110893. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  110894. * * 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.
  110895. * @see http://doc.babylonjs.com/features/occlusionquery
  110896. */
  110897. occlusionType: number;
  110898. /**
  110899. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  110900. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  110901. * * 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.
  110902. * @see http://doc.babylonjs.com/features/occlusionquery
  110903. */
  110904. occlusionQueryAlgorithmType: number;
  110905. /**
  110906. * 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
  110907. * @see http://doc.babylonjs.com/features/occlusionquery
  110908. */
  110909. isOccluded: boolean;
  110910. /**
  110911. * Flag to check the progress status of the query
  110912. * @see http://doc.babylonjs.com/features/occlusionquery
  110913. */
  110914. isOcclusionQueryInProgress: boolean;
  110915. }
  110916. }
  110917. declare module BABYLON {
  110918. /** @hidden */
  110919. export var _forceTransformFeedbackToBundle: boolean;
  110920. interface Engine {
  110921. /**
  110922. * Creates a webGL transform feedback object
  110923. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  110924. * @returns the webGL transform feedback object
  110925. */
  110926. createTransformFeedback(): WebGLTransformFeedback;
  110927. /**
  110928. * Delete a webGL transform feedback object
  110929. * @param value defines the webGL transform feedback object to delete
  110930. */
  110931. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  110932. /**
  110933. * Bind a webGL transform feedback object to the webgl context
  110934. * @param value defines the webGL transform feedback object to bind
  110935. */
  110936. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  110937. /**
  110938. * Begins a transform feedback operation
  110939. * @param usePoints defines if points or triangles must be used
  110940. */
  110941. beginTransformFeedback(usePoints: boolean): void;
  110942. /**
  110943. * Ends a transform feedback operation
  110944. */
  110945. endTransformFeedback(): void;
  110946. /**
  110947. * Specify the varyings to use with transform feedback
  110948. * @param program defines the associated webGL program
  110949. * @param value defines the list of strings representing the varying names
  110950. */
  110951. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  110952. /**
  110953. * Bind a webGL buffer for a transform feedback operation
  110954. * @param value defines the webGL buffer to bind
  110955. */
  110956. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  110957. }
  110958. }
  110959. declare module BABYLON {
  110960. /**
  110961. * Creation options of the multi render target texture.
  110962. */
  110963. export interface IMultiRenderTargetOptions {
  110964. /**
  110965. * Define if the texture needs to create mip maps after render.
  110966. */
  110967. generateMipMaps?: boolean;
  110968. /**
  110969. * Define the types of all the draw buffers we want to create
  110970. */
  110971. types?: number[];
  110972. /**
  110973. * Define the sampling modes of all the draw buffers we want to create
  110974. */
  110975. samplingModes?: number[];
  110976. /**
  110977. * Define if a depth buffer is required
  110978. */
  110979. generateDepthBuffer?: boolean;
  110980. /**
  110981. * Define if a stencil buffer is required
  110982. */
  110983. generateStencilBuffer?: boolean;
  110984. /**
  110985. * Define if a depth texture is required instead of a depth buffer
  110986. */
  110987. generateDepthTexture?: boolean;
  110988. /**
  110989. * Define the number of desired draw buffers
  110990. */
  110991. textureCount?: number;
  110992. /**
  110993. * Define if aspect ratio should be adapted to the texture or stay the scene one
  110994. */
  110995. doNotChangeAspectRatio?: boolean;
  110996. /**
  110997. * Define the default type of the buffers we are creating
  110998. */
  110999. defaultType?: number;
  111000. }
  111001. /**
  111002. * A multi render target, like a render target provides the ability to render to a texture.
  111003. * Unlike the render target, it can render to several draw buffers in one draw.
  111004. * This is specially interesting in deferred rendering or for any effects requiring more than
  111005. * just one color from a single pass.
  111006. */
  111007. export class MultiRenderTarget extends RenderTargetTexture {
  111008. private _internalTextures;
  111009. private _textures;
  111010. private _multiRenderTargetOptions;
  111011. /**
  111012. * Get if draw buffers are currently supported by the used hardware and browser.
  111013. */
  111014. readonly isSupported: boolean;
  111015. /**
  111016. * Get the list of textures generated by the multi render target.
  111017. */
  111018. readonly textures: Texture[];
  111019. /**
  111020. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  111021. */
  111022. readonly depthTexture: Texture;
  111023. /**
  111024. * Set the wrapping mode on U of all the textures we are rendering to.
  111025. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111026. */
  111027. wrapU: number;
  111028. /**
  111029. * Set the wrapping mode on V of all the textures we are rendering to.
  111030. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111031. */
  111032. wrapV: number;
  111033. /**
  111034. * Instantiate a new multi render target texture.
  111035. * A multi render target, like a render target provides the ability to render to a texture.
  111036. * Unlike the render target, it can render to several draw buffers in one draw.
  111037. * This is specially interesting in deferred rendering or for any effects requiring more than
  111038. * just one color from a single pass.
  111039. * @param name Define the name of the texture
  111040. * @param size Define the size of the buffers to render to
  111041. * @param count Define the number of target we are rendering into
  111042. * @param scene Define the scene the texture belongs to
  111043. * @param options Define the options used to create the multi render target
  111044. */
  111045. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  111046. /** @hidden */
  111047. _rebuild(): void;
  111048. private _createInternalTextures;
  111049. private _createTextures;
  111050. /**
  111051. * Define the number of samples used if MSAA is enabled.
  111052. */
  111053. samples: number;
  111054. /**
  111055. * Resize all the textures in the multi render target.
  111056. * Be carrefull as it will recreate all the data in the new texture.
  111057. * @param size Define the new size
  111058. */
  111059. resize(size: any): void;
  111060. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  111061. /**
  111062. * Dispose the render targets and their associated resources
  111063. */
  111064. dispose(): void;
  111065. /**
  111066. * Release all the underlying texture used as draw buffers.
  111067. */
  111068. releaseInternalTextures(): void;
  111069. }
  111070. }
  111071. declare module BABYLON {
  111072. interface ThinEngine {
  111073. /**
  111074. * Unbind a list of render target textures from the webGL context
  111075. * This is used only when drawBuffer extension or webGL2 are active
  111076. * @param textures defines the render target textures to unbind
  111077. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111078. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111079. */
  111080. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  111081. /**
  111082. * Create a multi render target texture
  111083. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  111084. * @param size defines the size of the texture
  111085. * @param options defines the creation options
  111086. * @returns the cube texture as an InternalTexture
  111087. */
  111088. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  111089. /**
  111090. * Update the sample count for a given multiple render target texture
  111091. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  111092. * @param textures defines the textures to update
  111093. * @param samples defines the sample count to set
  111094. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  111095. */
  111096. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  111097. }
  111098. }
  111099. declare module BABYLON {
  111100. /**
  111101. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  111102. */
  111103. export interface CubeMapInfo {
  111104. /**
  111105. * The pixel array for the front face.
  111106. * This is stored in format, left to right, up to down format.
  111107. */
  111108. front: Nullable<ArrayBufferView>;
  111109. /**
  111110. * The pixel array for the back face.
  111111. * This is stored in format, left to right, up to down format.
  111112. */
  111113. back: Nullable<ArrayBufferView>;
  111114. /**
  111115. * The pixel array for the left face.
  111116. * This is stored in format, left to right, up to down format.
  111117. */
  111118. left: Nullable<ArrayBufferView>;
  111119. /**
  111120. * The pixel array for the right face.
  111121. * This is stored in format, left to right, up to down format.
  111122. */
  111123. right: Nullable<ArrayBufferView>;
  111124. /**
  111125. * The pixel array for the up face.
  111126. * This is stored in format, left to right, up to down format.
  111127. */
  111128. up: Nullable<ArrayBufferView>;
  111129. /**
  111130. * The pixel array for the down face.
  111131. * This is stored in format, left to right, up to down format.
  111132. */
  111133. down: Nullable<ArrayBufferView>;
  111134. /**
  111135. * The size of the cubemap stored.
  111136. *
  111137. * Each faces will be size * size pixels.
  111138. */
  111139. size: number;
  111140. /**
  111141. * The format of the texture.
  111142. *
  111143. * RGBA, RGB.
  111144. */
  111145. format: number;
  111146. /**
  111147. * The type of the texture data.
  111148. *
  111149. * UNSIGNED_INT, FLOAT.
  111150. */
  111151. type: number;
  111152. /**
  111153. * Specifies whether the texture is in gamma space.
  111154. */
  111155. gammaSpace: boolean;
  111156. }
  111157. /**
  111158. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  111159. */
  111160. export class PanoramaToCubeMapTools {
  111161. private static FACE_FRONT;
  111162. private static FACE_BACK;
  111163. private static FACE_RIGHT;
  111164. private static FACE_LEFT;
  111165. private static FACE_DOWN;
  111166. private static FACE_UP;
  111167. /**
  111168. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  111169. *
  111170. * @param float32Array The source data.
  111171. * @param inputWidth The width of the input panorama.
  111172. * @param inputHeight The height of the input panorama.
  111173. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  111174. * @return The cubemap data
  111175. */
  111176. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  111177. private static CreateCubemapTexture;
  111178. private static CalcProjectionSpherical;
  111179. }
  111180. }
  111181. declare module BABYLON {
  111182. /**
  111183. * Helper class dealing with the extraction of spherical polynomial dataArray
  111184. * from a cube map.
  111185. */
  111186. export class CubeMapToSphericalPolynomialTools {
  111187. private static FileFaces;
  111188. /**
  111189. * Converts a texture to the according Spherical Polynomial data.
  111190. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111191. *
  111192. * @param texture The texture to extract the information from.
  111193. * @return The Spherical Polynomial data.
  111194. */
  111195. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  111196. /**
  111197. * Converts a cubemap to the according Spherical Polynomial data.
  111198. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111199. *
  111200. * @param cubeInfo The Cube map to extract the information from.
  111201. * @return The Spherical Polynomial data.
  111202. */
  111203. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  111204. }
  111205. }
  111206. declare module BABYLON {
  111207. interface BaseTexture {
  111208. /**
  111209. * Get the polynomial representation of the texture data.
  111210. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  111211. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  111212. */
  111213. sphericalPolynomial: Nullable<SphericalPolynomial>;
  111214. }
  111215. }
  111216. declare module BABYLON {
  111217. /** @hidden */
  111218. export var rgbdEncodePixelShader: {
  111219. name: string;
  111220. shader: string;
  111221. };
  111222. }
  111223. declare module BABYLON {
  111224. /** @hidden */
  111225. export var rgbdDecodePixelShader: {
  111226. name: string;
  111227. shader: string;
  111228. };
  111229. }
  111230. declare module BABYLON {
  111231. /**
  111232. * Raw texture data and descriptor sufficient for WebGL texture upload
  111233. */
  111234. export interface EnvironmentTextureInfo {
  111235. /**
  111236. * Version of the environment map
  111237. */
  111238. version: number;
  111239. /**
  111240. * Width of image
  111241. */
  111242. width: number;
  111243. /**
  111244. * Irradiance information stored in the file.
  111245. */
  111246. irradiance: any;
  111247. /**
  111248. * Specular information stored in the file.
  111249. */
  111250. specular: any;
  111251. }
  111252. /**
  111253. * Defines One Image in the file. It requires only the position in the file
  111254. * as well as the length.
  111255. */
  111256. interface BufferImageData {
  111257. /**
  111258. * Length of the image data.
  111259. */
  111260. length: number;
  111261. /**
  111262. * Position of the data from the null terminator delimiting the end of the JSON.
  111263. */
  111264. position: number;
  111265. }
  111266. /**
  111267. * Defines the specular data enclosed in the file.
  111268. * This corresponds to the version 1 of the data.
  111269. */
  111270. export interface EnvironmentTextureSpecularInfoV1 {
  111271. /**
  111272. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  111273. */
  111274. specularDataPosition?: number;
  111275. /**
  111276. * This contains all the images data needed to reconstruct the cubemap.
  111277. */
  111278. mipmaps: Array<BufferImageData>;
  111279. /**
  111280. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  111281. */
  111282. lodGenerationScale: number;
  111283. }
  111284. /**
  111285. * Sets of helpers addressing the serialization and deserialization of environment texture
  111286. * stored in a BabylonJS env file.
  111287. * Those files are usually stored as .env files.
  111288. */
  111289. export class EnvironmentTextureTools {
  111290. /**
  111291. * Magic number identifying the env file.
  111292. */
  111293. private static _MagicBytes;
  111294. /**
  111295. * Gets the environment info from an env file.
  111296. * @param data The array buffer containing the .env bytes.
  111297. * @returns the environment file info (the json header) if successfully parsed.
  111298. */
  111299. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111300. /**
  111301. * Creates an environment texture from a loaded cube texture.
  111302. * @param texture defines the cube texture to convert in env file
  111303. * @return a promise containing the environment data if succesfull.
  111304. */
  111305. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111306. /**
  111307. * Creates a JSON representation of the spherical data.
  111308. * @param texture defines the texture containing the polynomials
  111309. * @return the JSON representation of the spherical info
  111310. */
  111311. private static _CreateEnvTextureIrradiance;
  111312. /**
  111313. * Creates the ArrayBufferViews used for initializing environment texture image data.
  111314. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  111315. * @param info parameters that determine what views will be created for accessing the underlying buffer
  111316. * @return the views described by info providing access to the underlying buffer
  111317. */
  111318. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  111319. /**
  111320. * Uploads the texture info contained in the env file to the GPU.
  111321. * @param texture defines the internal texture to upload to
  111322. * @param arrayBuffer defines the buffer cotaining the data to load
  111323. * @param info defines the texture info retrieved through the GetEnvInfo method
  111324. * @returns a promise
  111325. */
  111326. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111327. /**
  111328. * Uploads the levels of image data to the GPU.
  111329. * @param texture defines the internal texture to upload to
  111330. * @param imageData defines the array buffer views of image data [mipmap][face]
  111331. * @returns a promise
  111332. */
  111333. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111334. /**
  111335. * Uploads spherical polynomials information to the texture.
  111336. * @param texture defines the texture we are trying to upload the information to
  111337. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111338. */
  111339. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111340. /** @hidden */
  111341. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111342. }
  111343. }
  111344. declare module BABYLON {
  111345. /**
  111346. * Contains position and normal vectors for a vertex
  111347. */
  111348. export class PositionNormalVertex {
  111349. /** the position of the vertex (defaut: 0,0,0) */
  111350. position: Vector3;
  111351. /** the normal of the vertex (defaut: 0,1,0) */
  111352. normal: Vector3;
  111353. /**
  111354. * Creates a PositionNormalVertex
  111355. * @param position the position of the vertex (defaut: 0,0,0)
  111356. * @param normal the normal of the vertex (defaut: 0,1,0)
  111357. */
  111358. constructor(
  111359. /** the position of the vertex (defaut: 0,0,0) */
  111360. position?: Vector3,
  111361. /** the normal of the vertex (defaut: 0,1,0) */
  111362. normal?: Vector3);
  111363. /**
  111364. * Clones the PositionNormalVertex
  111365. * @returns the cloned PositionNormalVertex
  111366. */
  111367. clone(): PositionNormalVertex;
  111368. }
  111369. /**
  111370. * Contains position, normal and uv vectors for a vertex
  111371. */
  111372. export class PositionNormalTextureVertex {
  111373. /** the position of the vertex (defaut: 0,0,0) */
  111374. position: Vector3;
  111375. /** the normal of the vertex (defaut: 0,1,0) */
  111376. normal: Vector3;
  111377. /** the uv of the vertex (default: 0,0) */
  111378. uv: Vector2;
  111379. /**
  111380. * Creates a PositionNormalTextureVertex
  111381. * @param position the position of the vertex (defaut: 0,0,0)
  111382. * @param normal the normal of the vertex (defaut: 0,1,0)
  111383. * @param uv the uv of the vertex (default: 0,0)
  111384. */
  111385. constructor(
  111386. /** the position of the vertex (defaut: 0,0,0) */
  111387. position?: Vector3,
  111388. /** the normal of the vertex (defaut: 0,1,0) */
  111389. normal?: Vector3,
  111390. /** the uv of the vertex (default: 0,0) */
  111391. uv?: Vector2);
  111392. /**
  111393. * Clones the PositionNormalTextureVertex
  111394. * @returns the cloned PositionNormalTextureVertex
  111395. */
  111396. clone(): PositionNormalTextureVertex;
  111397. }
  111398. }
  111399. declare module BABYLON {
  111400. /** @hidden */
  111401. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  111402. private _genericAttributeLocation;
  111403. private _varyingLocationCount;
  111404. private _varyingLocationMap;
  111405. private _replacements;
  111406. private _textureCount;
  111407. private _uniforms;
  111408. lineProcessor(line: string): string;
  111409. attributeProcessor(attribute: string): string;
  111410. varyingProcessor(varying: string, isFragment: boolean): string;
  111411. uniformProcessor(uniform: string): string;
  111412. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  111413. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111414. }
  111415. }
  111416. declare module BABYLON {
  111417. /**
  111418. * Container for accessors for natively-stored mesh data buffers.
  111419. */
  111420. class NativeDataBuffer extends DataBuffer {
  111421. /**
  111422. * Accessor value used to identify/retrieve a natively-stored index buffer.
  111423. */
  111424. nativeIndexBuffer?: any;
  111425. /**
  111426. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  111427. */
  111428. nativeVertexBuffer?: any;
  111429. }
  111430. /** @hidden */
  111431. export class NativeEngine extends Engine {
  111432. private readonly _native;
  111433. getHardwareScalingLevel(): number;
  111434. constructor();
  111435. /**
  111436. * Can be used to override the current requestAnimationFrame requester.
  111437. * @hidden
  111438. */
  111439. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  111440. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111441. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  111442. createVertexBuffer(data: DataArray): NativeDataBuffer;
  111443. recordVertexArrayObject(vertexBuffers: {
  111444. [key: string]: VertexBuffer;
  111445. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111446. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111447. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111448. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111449. /**
  111450. * Draw a list of indexed primitives
  111451. * @param fillMode defines the primitive to use
  111452. * @param indexStart defines the starting index
  111453. * @param indexCount defines the number of index to draw
  111454. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111455. */
  111456. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111457. /**
  111458. * Draw a list of unindexed primitives
  111459. * @param fillMode defines the primitive to use
  111460. * @param verticesStart defines the index of first vertex to draw
  111461. * @param verticesCount defines the count of vertices to draw
  111462. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111463. */
  111464. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111465. createPipelineContext(): IPipelineContext;
  111466. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111467. /** @hidden */
  111468. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111469. /** @hidden */
  111470. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111471. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111472. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111473. protected _setProgram(program: WebGLProgram): void;
  111474. _releaseEffect(effect: Effect): void;
  111475. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111476. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  111477. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  111478. bindSamplers(effect: Effect): void;
  111479. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  111480. getRenderWidth(useScreen?: boolean): number;
  111481. getRenderHeight(useScreen?: boolean): number;
  111482. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  111483. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111484. /**
  111485. * Set the z offset to apply to current rendering
  111486. * @param value defines the offset to apply
  111487. */
  111488. setZOffset(value: number): void;
  111489. /**
  111490. * Gets the current value of the zOffset
  111491. * @returns the current zOffset state
  111492. */
  111493. getZOffset(): number;
  111494. /**
  111495. * Enable or disable depth buffering
  111496. * @param enable defines the state to set
  111497. */
  111498. setDepthBuffer(enable: boolean): void;
  111499. /**
  111500. * Gets a boolean indicating if depth writing is enabled
  111501. * @returns the current depth writing state
  111502. */
  111503. getDepthWrite(): boolean;
  111504. /**
  111505. * Enable or disable depth writing
  111506. * @param enable defines the state to set
  111507. */
  111508. setDepthWrite(enable: boolean): void;
  111509. /**
  111510. * Enable or disable color writing
  111511. * @param enable defines the state to set
  111512. */
  111513. setColorWrite(enable: boolean): void;
  111514. /**
  111515. * Gets a boolean indicating if color writing is enabled
  111516. * @returns the current color writing state
  111517. */
  111518. getColorWrite(): boolean;
  111519. /**
  111520. * Sets alpha constants used by some alpha blending modes
  111521. * @param r defines the red component
  111522. * @param g defines the green component
  111523. * @param b defines the blue component
  111524. * @param a defines the alpha component
  111525. */
  111526. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  111527. /**
  111528. * Sets the current alpha mode
  111529. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  111530. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111531. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111532. */
  111533. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111534. /**
  111535. * Gets the current alpha mode
  111536. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111537. * @returns the current alpha mode
  111538. */
  111539. getAlphaMode(): number;
  111540. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111541. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111542. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111543. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111544. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111545. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111546. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111547. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111548. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111549. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111550. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111551. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111552. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111553. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111554. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111555. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111556. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111557. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111558. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111559. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111560. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  111561. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  111562. wipeCaches(bruteForce?: boolean): void;
  111563. _createTexture(): WebGLTexture;
  111564. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  111565. /**
  111566. * Usually called from BABYLON.Texture.ts.
  111567. * Passed information to create a WebGLTexture
  111568. * @param urlArg defines a value which contains one of the following:
  111569. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111570. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111571. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111572. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111573. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  111574. * @param scene needed for loading to the correct scene
  111575. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  111576. * @param onLoad optional callback to be called upon successful completion
  111577. * @param onError optional callback to be called upon failure
  111578. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  111579. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111580. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111581. * @param forcedExtension defines the extension to use to pick the right loader
  111582. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111583. */
  111584. 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;
  111585. /**
  111586. * Creates a cube texture
  111587. * @param rootUrl defines the url where the files to load is located
  111588. * @param scene defines the current scene
  111589. * @param files defines the list of files to load (1 per face)
  111590. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  111591. * @param onLoad defines an optional callback raised when the texture is loaded
  111592. * @param onError defines an optional callback raised if there is an issue to load the texture
  111593. * @param format defines the format of the data
  111594. * @param forcedExtension defines the extension to use to pick the right loader
  111595. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  111596. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  111597. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  111598. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  111599. * @returns the cube texture as an InternalTexture
  111600. */
  111601. 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;
  111602. private _getSamplingFilter;
  111603. private static _GetNativeTextureFormat;
  111604. createRenderTargetTexture(size: number | {
  111605. width: number;
  111606. height: number;
  111607. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111608. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111609. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111610. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111611. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111612. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  111613. /**
  111614. * Updates a dynamic vertex buffer.
  111615. * @param vertexBuffer the vertex buffer to update
  111616. * @param data the data used to update the vertex buffer
  111617. * @param byteOffset the byte offset of the data (optional)
  111618. * @param byteLength the byte length of the data (optional)
  111619. */
  111620. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  111621. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  111622. private _updateAnisotropicLevel;
  111623. private _getAddressMode;
  111624. /** @hidden */
  111625. _bindTexture(channel: number, texture: InternalTexture): void;
  111626. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  111627. releaseEffects(): void;
  111628. /** @hidden */
  111629. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111630. /** @hidden */
  111631. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111632. /** @hidden */
  111633. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111634. /** @hidden */
  111635. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111636. }
  111637. }
  111638. declare module BABYLON {
  111639. /**
  111640. * Gather the list of clipboard event types as constants.
  111641. */
  111642. export class ClipboardEventTypes {
  111643. /**
  111644. * The clipboard event is fired when a copy command is active (pressed).
  111645. */
  111646. static readonly COPY: number;
  111647. /**
  111648. * The clipboard event is fired when a cut command is active (pressed).
  111649. */
  111650. static readonly CUT: number;
  111651. /**
  111652. * The clipboard event is fired when a paste command is active (pressed).
  111653. */
  111654. static readonly PASTE: number;
  111655. }
  111656. /**
  111657. * This class is used to store clipboard related info for the onClipboardObservable event.
  111658. */
  111659. export class ClipboardInfo {
  111660. /**
  111661. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111662. */
  111663. type: number;
  111664. /**
  111665. * Defines the related dom event
  111666. */
  111667. event: ClipboardEvent;
  111668. /**
  111669. *Creates an instance of ClipboardInfo.
  111670. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  111671. * @param event Defines the related dom event
  111672. */
  111673. constructor(
  111674. /**
  111675. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111676. */
  111677. type: number,
  111678. /**
  111679. * Defines the related dom event
  111680. */
  111681. event: ClipboardEvent);
  111682. /**
  111683. * Get the clipboard event's type from the keycode.
  111684. * @param keyCode Defines the keyCode for the current keyboard event.
  111685. * @return {number}
  111686. */
  111687. static GetTypeFromCharacter(keyCode: number): number;
  111688. }
  111689. }
  111690. declare module BABYLON {
  111691. /**
  111692. * Google Daydream controller
  111693. */
  111694. export class DaydreamController extends WebVRController {
  111695. /**
  111696. * Base Url for the controller model.
  111697. */
  111698. static MODEL_BASE_URL: string;
  111699. /**
  111700. * File name for the controller model.
  111701. */
  111702. static MODEL_FILENAME: string;
  111703. /**
  111704. * Gamepad Id prefix used to identify Daydream Controller.
  111705. */
  111706. static readonly GAMEPAD_ID_PREFIX: string;
  111707. /**
  111708. * Creates a new DaydreamController from a gamepad
  111709. * @param vrGamepad the gamepad that the controller should be created from
  111710. */
  111711. constructor(vrGamepad: any);
  111712. /**
  111713. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111714. * @param scene scene in which to add meshes
  111715. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111716. */
  111717. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111718. /**
  111719. * Called once for each button that changed state since the last frame
  111720. * @param buttonIdx Which button index changed
  111721. * @param state New state of the button
  111722. * @param changes Which properties on the state changed since last frame
  111723. */
  111724. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111725. }
  111726. }
  111727. declare module BABYLON {
  111728. /**
  111729. * Gear VR Controller
  111730. */
  111731. export class GearVRController extends WebVRController {
  111732. /**
  111733. * Base Url for the controller model.
  111734. */
  111735. static MODEL_BASE_URL: string;
  111736. /**
  111737. * File name for the controller model.
  111738. */
  111739. static MODEL_FILENAME: string;
  111740. /**
  111741. * Gamepad Id prefix used to identify this controller.
  111742. */
  111743. static readonly GAMEPAD_ID_PREFIX: string;
  111744. private readonly _buttonIndexToObservableNameMap;
  111745. /**
  111746. * Creates a new GearVRController from a gamepad
  111747. * @param vrGamepad the gamepad that the controller should be created from
  111748. */
  111749. constructor(vrGamepad: any);
  111750. /**
  111751. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111752. * @param scene scene in which to add meshes
  111753. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111754. */
  111755. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111756. /**
  111757. * Called once for each button that changed state since the last frame
  111758. * @param buttonIdx Which button index changed
  111759. * @param state New state of the button
  111760. * @param changes Which properties on the state changed since last frame
  111761. */
  111762. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111763. }
  111764. }
  111765. declare module BABYLON {
  111766. /**
  111767. * Class containing static functions to help procedurally build meshes
  111768. */
  111769. export class PolyhedronBuilder {
  111770. /**
  111771. * Creates a polyhedron mesh
  111772. * * 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
  111773. * * The parameter `size` (positive float, default 1) sets the polygon size
  111774. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  111775. * * 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`
  111776. * * 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
  111777. * * 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)`)
  111778. * * 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
  111779. * * 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
  111780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111781. * * 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
  111782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111783. * @param name defines the name of the mesh
  111784. * @param options defines the options used to create the mesh
  111785. * @param scene defines the hosting scene
  111786. * @returns the polyhedron mesh
  111787. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  111788. */
  111789. static CreatePolyhedron(name: string, options: {
  111790. type?: number;
  111791. size?: number;
  111792. sizeX?: number;
  111793. sizeY?: number;
  111794. sizeZ?: number;
  111795. custom?: any;
  111796. faceUV?: Vector4[];
  111797. faceColors?: Color4[];
  111798. flat?: boolean;
  111799. updatable?: boolean;
  111800. sideOrientation?: number;
  111801. frontUVs?: Vector4;
  111802. backUVs?: Vector4;
  111803. }, scene?: Nullable<Scene>): Mesh;
  111804. }
  111805. }
  111806. declare module BABYLON {
  111807. /**
  111808. * Gizmo that enables scaling a mesh along 3 axis
  111809. */
  111810. export class ScaleGizmo extends Gizmo {
  111811. /**
  111812. * Internal gizmo used for interactions on the x axis
  111813. */
  111814. xGizmo: AxisScaleGizmo;
  111815. /**
  111816. * Internal gizmo used for interactions on the y axis
  111817. */
  111818. yGizmo: AxisScaleGizmo;
  111819. /**
  111820. * Internal gizmo used for interactions on the z axis
  111821. */
  111822. zGizmo: AxisScaleGizmo;
  111823. /**
  111824. * Internal gizmo used to scale all axis equally
  111825. */
  111826. uniformScaleGizmo: AxisScaleGizmo;
  111827. private _meshAttached;
  111828. private _updateGizmoRotationToMatchAttachedMesh;
  111829. private _snapDistance;
  111830. private _scaleRatio;
  111831. private _uniformScalingMesh;
  111832. private _octahedron;
  111833. /** Fires an event when any of it's sub gizmos are dragged */
  111834. onDragStartObservable: Observable<unknown>;
  111835. /** Fires an event when any of it's sub gizmos are released from dragging */
  111836. onDragEndObservable: Observable<unknown>;
  111837. attachedMesh: Nullable<AbstractMesh>;
  111838. /**
  111839. * Creates a ScaleGizmo
  111840. * @param gizmoLayer The utility layer the gizmo will be added to
  111841. */
  111842. constructor(gizmoLayer?: UtilityLayerRenderer);
  111843. updateGizmoRotationToMatchAttachedMesh: boolean;
  111844. /**
  111845. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111846. */
  111847. snapDistance: number;
  111848. /**
  111849. * Ratio for the scale of the gizmo (Default: 1)
  111850. */
  111851. scaleRatio: number;
  111852. /**
  111853. * Disposes of the gizmo
  111854. */
  111855. dispose(): void;
  111856. }
  111857. }
  111858. declare module BABYLON {
  111859. /**
  111860. * Single axis scale gizmo
  111861. */
  111862. export class AxisScaleGizmo extends Gizmo {
  111863. /**
  111864. * Drag behavior responsible for the gizmos dragging interactions
  111865. */
  111866. dragBehavior: PointerDragBehavior;
  111867. private _pointerObserver;
  111868. /**
  111869. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111870. */
  111871. snapDistance: number;
  111872. /**
  111873. * Event that fires each time the gizmo snaps to a new location.
  111874. * * snapDistance is the the change in distance
  111875. */
  111876. onSnapObservable: Observable<{
  111877. snapDistance: number;
  111878. }>;
  111879. /**
  111880. * If the scaling operation should be done on all axis (default: false)
  111881. */
  111882. uniformScaling: boolean;
  111883. private _isEnabled;
  111884. private _parent;
  111885. private _arrow;
  111886. private _coloredMaterial;
  111887. private _hoverMaterial;
  111888. /**
  111889. * Creates an AxisScaleGizmo
  111890. * @param gizmoLayer The utility layer the gizmo will be added to
  111891. * @param dragAxis The axis which the gizmo will be able to scale on
  111892. * @param color The color of the gizmo
  111893. */
  111894. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  111895. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111896. /**
  111897. * If the gizmo is enabled
  111898. */
  111899. isEnabled: boolean;
  111900. /**
  111901. * Disposes of the gizmo
  111902. */
  111903. dispose(): void;
  111904. /**
  111905. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111906. * @param mesh The mesh to replace the default mesh of the gizmo
  111907. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  111908. */
  111909. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  111910. }
  111911. }
  111912. declare module BABYLON {
  111913. /**
  111914. * Bounding box gizmo
  111915. */
  111916. export class BoundingBoxGizmo extends Gizmo {
  111917. private _lineBoundingBox;
  111918. private _rotateSpheresParent;
  111919. private _scaleBoxesParent;
  111920. private _boundingDimensions;
  111921. private _renderObserver;
  111922. private _pointerObserver;
  111923. private _scaleDragSpeed;
  111924. private _tmpQuaternion;
  111925. private _tmpVector;
  111926. private _tmpRotationMatrix;
  111927. /**
  111928. * 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)
  111929. */
  111930. ignoreChildren: boolean;
  111931. /**
  111932. * 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)
  111933. */
  111934. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  111935. /**
  111936. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  111937. */
  111938. rotationSphereSize: number;
  111939. /**
  111940. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  111941. */
  111942. scaleBoxSize: number;
  111943. /**
  111944. * 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)
  111945. */
  111946. fixedDragMeshScreenSize: boolean;
  111947. /**
  111948. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  111949. */
  111950. fixedDragMeshScreenSizeDistanceFactor: number;
  111951. /**
  111952. * Fired when a rotation sphere or scale box is dragged
  111953. */
  111954. onDragStartObservable: Observable<{}>;
  111955. /**
  111956. * Fired when a scale box is dragged
  111957. */
  111958. onScaleBoxDragObservable: Observable<{}>;
  111959. /**
  111960. * Fired when a scale box drag is ended
  111961. */
  111962. onScaleBoxDragEndObservable: Observable<{}>;
  111963. /**
  111964. * Fired when a rotation sphere is dragged
  111965. */
  111966. onRotationSphereDragObservable: Observable<{}>;
  111967. /**
  111968. * Fired when a rotation sphere drag is ended
  111969. */
  111970. onRotationSphereDragEndObservable: Observable<{}>;
  111971. /**
  111972. * 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)
  111973. */
  111974. scalePivot: Nullable<Vector3>;
  111975. /**
  111976. * Mesh used as a pivot to rotate the attached mesh
  111977. */
  111978. private _anchorMesh;
  111979. private _existingMeshScale;
  111980. private _dragMesh;
  111981. private pointerDragBehavior;
  111982. private coloredMaterial;
  111983. private hoverColoredMaterial;
  111984. /**
  111985. * Sets the color of the bounding box gizmo
  111986. * @param color the color to set
  111987. */
  111988. setColor(color: Color3): void;
  111989. /**
  111990. * Creates an BoundingBoxGizmo
  111991. * @param gizmoLayer The utility layer the gizmo will be added to
  111992. * @param color The color of the gizmo
  111993. */
  111994. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  111995. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111996. private _selectNode;
  111997. /**
  111998. * Updates the bounding box information for the Gizmo
  111999. */
  112000. updateBoundingBox(): void;
  112001. private _updateRotationSpheres;
  112002. private _updateScaleBoxes;
  112003. /**
  112004. * Enables rotation on the specified axis and disables rotation on the others
  112005. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  112006. */
  112007. setEnabledRotationAxis(axis: string): void;
  112008. /**
  112009. * Enables/disables scaling
  112010. * @param enable if scaling should be enabled
  112011. */
  112012. setEnabledScaling(enable: boolean): void;
  112013. private _updateDummy;
  112014. /**
  112015. * Enables a pointer drag behavior on the bounding box of the gizmo
  112016. */
  112017. enableDragBehavior(): void;
  112018. /**
  112019. * Disposes of the gizmo
  112020. */
  112021. dispose(): void;
  112022. /**
  112023. * 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)
  112024. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  112025. * @returns the bounding box mesh with the passed in mesh as a child
  112026. */
  112027. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  112028. /**
  112029. * CustomMeshes are not supported by this gizmo
  112030. * @param mesh The mesh to replace the default mesh of the gizmo
  112031. */
  112032. setCustomMesh(mesh: Mesh): void;
  112033. }
  112034. }
  112035. declare module BABYLON {
  112036. /**
  112037. * Single plane rotation gizmo
  112038. */
  112039. export class PlaneRotationGizmo extends Gizmo {
  112040. /**
  112041. * Drag behavior responsible for the gizmos dragging interactions
  112042. */
  112043. dragBehavior: PointerDragBehavior;
  112044. private _pointerObserver;
  112045. /**
  112046. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  112047. */
  112048. snapDistance: number;
  112049. /**
  112050. * Event that fires each time the gizmo snaps to a new location.
  112051. * * snapDistance is the the change in distance
  112052. */
  112053. onSnapObservable: Observable<{
  112054. snapDistance: number;
  112055. }>;
  112056. private _isEnabled;
  112057. private _parent;
  112058. /**
  112059. * Creates a PlaneRotationGizmo
  112060. * @param gizmoLayer The utility layer the gizmo will be added to
  112061. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  112062. * @param color The color of the gizmo
  112063. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112064. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112065. */
  112066. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  112067. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112068. /**
  112069. * If the gizmo is enabled
  112070. */
  112071. isEnabled: boolean;
  112072. /**
  112073. * Disposes of the gizmo
  112074. */
  112075. dispose(): void;
  112076. }
  112077. }
  112078. declare module BABYLON {
  112079. /**
  112080. * Gizmo that enables rotating a mesh along 3 axis
  112081. */
  112082. export class RotationGizmo extends Gizmo {
  112083. /**
  112084. * Internal gizmo used for interactions on the x axis
  112085. */
  112086. xGizmo: PlaneRotationGizmo;
  112087. /**
  112088. * Internal gizmo used for interactions on the y axis
  112089. */
  112090. yGizmo: PlaneRotationGizmo;
  112091. /**
  112092. * Internal gizmo used for interactions on the z axis
  112093. */
  112094. zGizmo: PlaneRotationGizmo;
  112095. /** Fires an event when any of it's sub gizmos are dragged */
  112096. onDragStartObservable: Observable<unknown>;
  112097. /** Fires an event when any of it's sub gizmos are released from dragging */
  112098. onDragEndObservable: Observable<unknown>;
  112099. private _meshAttached;
  112100. attachedMesh: Nullable<AbstractMesh>;
  112101. /**
  112102. * Creates a RotationGizmo
  112103. * @param gizmoLayer The utility layer the gizmo will be added to
  112104. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112105. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112106. */
  112107. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  112108. updateGizmoRotationToMatchAttachedMesh: boolean;
  112109. /**
  112110. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112111. */
  112112. snapDistance: number;
  112113. /**
  112114. * Ratio for the scale of the gizmo (Default: 1)
  112115. */
  112116. scaleRatio: number;
  112117. /**
  112118. * Disposes of the gizmo
  112119. */
  112120. dispose(): void;
  112121. /**
  112122. * CustomMeshes are not supported by this gizmo
  112123. * @param mesh The mesh to replace the default mesh of the gizmo
  112124. */
  112125. setCustomMesh(mesh: Mesh): void;
  112126. }
  112127. }
  112128. declare module BABYLON {
  112129. /**
  112130. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  112131. */
  112132. export class GizmoManager implements IDisposable {
  112133. private scene;
  112134. /**
  112135. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  112136. */
  112137. gizmos: {
  112138. positionGizmo: Nullable<PositionGizmo>;
  112139. rotationGizmo: Nullable<RotationGizmo>;
  112140. scaleGizmo: Nullable<ScaleGizmo>;
  112141. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  112142. };
  112143. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  112144. clearGizmoOnEmptyPointerEvent: boolean;
  112145. /** Fires an event when the manager is attached to a mesh */
  112146. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  112147. private _gizmosEnabled;
  112148. private _pointerObserver;
  112149. private _attachedMesh;
  112150. private _boundingBoxColor;
  112151. private _defaultUtilityLayer;
  112152. private _defaultKeepDepthUtilityLayer;
  112153. /**
  112154. * When bounding box gizmo is enabled, this can be used to track drag/end events
  112155. */
  112156. boundingBoxDragBehavior: SixDofDragBehavior;
  112157. /**
  112158. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  112159. */
  112160. attachableMeshes: Nullable<Array<AbstractMesh>>;
  112161. /**
  112162. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  112163. */
  112164. usePointerToAttachGizmos: boolean;
  112165. /**
  112166. * Utility layer that the bounding box gizmo belongs to
  112167. */
  112168. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  112169. /**
  112170. * Utility layer that all gizmos besides bounding box belong to
  112171. */
  112172. readonly utilityLayer: UtilityLayerRenderer;
  112173. /**
  112174. * Instatiates a gizmo manager
  112175. * @param scene the scene to overlay the gizmos on top of
  112176. */
  112177. constructor(scene: Scene);
  112178. /**
  112179. * Attaches a set of gizmos to the specified mesh
  112180. * @param mesh The mesh the gizmo's should be attached to
  112181. */
  112182. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112183. /**
  112184. * If the position gizmo is enabled
  112185. */
  112186. positionGizmoEnabled: boolean;
  112187. /**
  112188. * If the rotation gizmo is enabled
  112189. */
  112190. rotationGizmoEnabled: boolean;
  112191. /**
  112192. * If the scale gizmo is enabled
  112193. */
  112194. scaleGizmoEnabled: boolean;
  112195. /**
  112196. * If the boundingBox gizmo is enabled
  112197. */
  112198. boundingBoxGizmoEnabled: boolean;
  112199. /**
  112200. * Disposes of the gizmo manager
  112201. */
  112202. dispose(): void;
  112203. }
  112204. }
  112205. declare module BABYLON {
  112206. /**
  112207. * A directional light is defined by a direction (what a surprise!).
  112208. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  112209. * 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.
  112210. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112211. */
  112212. export class DirectionalLight extends ShadowLight {
  112213. private _shadowFrustumSize;
  112214. /**
  112215. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  112216. */
  112217. /**
  112218. * Specifies a fix frustum size for the shadow generation.
  112219. */
  112220. shadowFrustumSize: number;
  112221. private _shadowOrthoScale;
  112222. /**
  112223. * Gets the shadow projection scale against the optimal computed one.
  112224. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112225. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112226. */
  112227. /**
  112228. * Sets the shadow projection scale against the optimal computed one.
  112229. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112230. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112231. */
  112232. shadowOrthoScale: number;
  112233. /**
  112234. * Automatically compute the projection matrix to best fit (including all the casters)
  112235. * on each frame.
  112236. */
  112237. autoUpdateExtends: boolean;
  112238. private _orthoLeft;
  112239. private _orthoRight;
  112240. private _orthoTop;
  112241. private _orthoBottom;
  112242. /**
  112243. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  112244. * The directional light is emitted from everywhere in the given direction.
  112245. * It can cast shadows.
  112246. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112247. * @param name The friendly name of the light
  112248. * @param direction The direction of the light
  112249. * @param scene The scene the light belongs to
  112250. */
  112251. constructor(name: string, direction: Vector3, scene: Scene);
  112252. /**
  112253. * Returns the string "DirectionalLight".
  112254. * @return The class name
  112255. */
  112256. getClassName(): string;
  112257. /**
  112258. * Returns the integer 1.
  112259. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112260. */
  112261. getTypeID(): number;
  112262. /**
  112263. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  112264. * Returns the DirectionalLight Shadow projection matrix.
  112265. */
  112266. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112267. /**
  112268. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  112269. * Returns the DirectionalLight Shadow projection matrix.
  112270. */
  112271. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  112272. /**
  112273. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  112274. * Returns the DirectionalLight Shadow projection matrix.
  112275. */
  112276. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112277. protected _buildUniformLayout(): void;
  112278. /**
  112279. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  112280. * @param effect The effect to update
  112281. * @param lightIndex The index of the light in the effect to update
  112282. * @returns The directional light
  112283. */
  112284. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  112285. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  112286. /**
  112287. * Gets the minZ used for shadow according to both the scene and the light.
  112288. *
  112289. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112290. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112291. * @param activeCamera The camera we are returning the min for
  112292. * @returns the depth min z
  112293. */
  112294. getDepthMinZ(activeCamera: Camera): number;
  112295. /**
  112296. * Gets the maxZ used for shadow according to both the scene and the light.
  112297. *
  112298. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112299. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112300. * @param activeCamera The camera we are returning the max for
  112301. * @returns the depth max z
  112302. */
  112303. getDepthMaxZ(activeCamera: Camera): number;
  112304. /**
  112305. * Prepares the list of defines specific to the light type.
  112306. * @param defines the list of defines
  112307. * @param lightIndex defines the index of the light for the effect
  112308. */
  112309. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112310. }
  112311. }
  112312. declare module BABYLON {
  112313. /**
  112314. * Class containing static functions to help procedurally build meshes
  112315. */
  112316. export class HemisphereBuilder {
  112317. /**
  112318. * Creates a hemisphere mesh
  112319. * @param name defines the name of the mesh
  112320. * @param options defines the options used to create the mesh
  112321. * @param scene defines the hosting scene
  112322. * @returns the hemisphere mesh
  112323. */
  112324. static CreateHemisphere(name: string, options: {
  112325. segments?: number;
  112326. diameter?: number;
  112327. sideOrientation?: number;
  112328. }, scene: any): Mesh;
  112329. }
  112330. }
  112331. declare module BABYLON {
  112332. /**
  112333. * A spot light is defined by a position, a direction, an angle, and an exponent.
  112334. * These values define a cone of light starting from the position, emitting toward the direction.
  112335. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  112336. * and the exponent defines the speed of the decay of the light with distance (reach).
  112337. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112338. */
  112339. export class SpotLight extends ShadowLight {
  112340. private _angle;
  112341. private _innerAngle;
  112342. private _cosHalfAngle;
  112343. private _lightAngleScale;
  112344. private _lightAngleOffset;
  112345. /**
  112346. * Gets the cone angle of the spot light in Radians.
  112347. */
  112348. /**
  112349. * Sets the cone angle of the spot light in Radians.
  112350. */
  112351. angle: number;
  112352. /**
  112353. * Only used in gltf falloff mode, this defines the angle where
  112354. * the directional falloff will start before cutting at angle which could be seen
  112355. * as outer angle.
  112356. */
  112357. /**
  112358. * Only used in gltf falloff mode, this defines the angle where
  112359. * the directional falloff will start before cutting at angle which could be seen
  112360. * as outer angle.
  112361. */
  112362. innerAngle: number;
  112363. private _shadowAngleScale;
  112364. /**
  112365. * Allows scaling the angle of the light for shadow generation only.
  112366. */
  112367. /**
  112368. * Allows scaling the angle of the light for shadow generation only.
  112369. */
  112370. shadowAngleScale: number;
  112371. /**
  112372. * The light decay speed with the distance from the emission spot.
  112373. */
  112374. exponent: number;
  112375. private _projectionTextureMatrix;
  112376. /**
  112377. * Allows reading the projecton texture
  112378. */
  112379. readonly projectionTextureMatrix: Matrix;
  112380. protected _projectionTextureLightNear: number;
  112381. /**
  112382. * Gets the near clip of the Spotlight for texture projection.
  112383. */
  112384. /**
  112385. * Sets the near clip of the Spotlight for texture projection.
  112386. */
  112387. projectionTextureLightNear: number;
  112388. protected _projectionTextureLightFar: number;
  112389. /**
  112390. * Gets the far clip of the Spotlight for texture projection.
  112391. */
  112392. /**
  112393. * Sets the far clip of the Spotlight for texture projection.
  112394. */
  112395. projectionTextureLightFar: number;
  112396. protected _projectionTextureUpDirection: Vector3;
  112397. /**
  112398. * Gets the Up vector of the Spotlight for texture projection.
  112399. */
  112400. /**
  112401. * Sets the Up vector of the Spotlight for texture projection.
  112402. */
  112403. projectionTextureUpDirection: Vector3;
  112404. private _projectionTexture;
  112405. /**
  112406. * Gets the projection texture of the light.
  112407. */
  112408. /**
  112409. * Sets the projection texture of the light.
  112410. */
  112411. projectionTexture: Nullable<BaseTexture>;
  112412. private _projectionTextureViewLightDirty;
  112413. private _projectionTextureProjectionLightDirty;
  112414. private _projectionTextureDirty;
  112415. private _projectionTextureViewTargetVector;
  112416. private _projectionTextureViewLightMatrix;
  112417. private _projectionTextureProjectionLightMatrix;
  112418. private _projectionTextureScalingMatrix;
  112419. /**
  112420. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  112421. * It can cast shadows.
  112422. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112423. * @param name The light friendly name
  112424. * @param position The position of the spot light in the scene
  112425. * @param direction The direction of the light in the scene
  112426. * @param angle The cone angle of the light in Radians
  112427. * @param exponent The light decay speed with the distance from the emission spot
  112428. * @param scene The scene the lights belongs to
  112429. */
  112430. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  112431. /**
  112432. * Returns the string "SpotLight".
  112433. * @returns the class name
  112434. */
  112435. getClassName(): string;
  112436. /**
  112437. * Returns the integer 2.
  112438. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112439. */
  112440. getTypeID(): number;
  112441. /**
  112442. * Overrides the direction setter to recompute the projection texture view light Matrix.
  112443. */
  112444. protected _setDirection(value: Vector3): void;
  112445. /**
  112446. * Overrides the position setter to recompute the projection texture view light Matrix.
  112447. */
  112448. protected _setPosition(value: Vector3): void;
  112449. /**
  112450. * 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.
  112451. * Returns the SpotLight.
  112452. */
  112453. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112454. protected _computeProjectionTextureViewLightMatrix(): void;
  112455. protected _computeProjectionTextureProjectionLightMatrix(): void;
  112456. /**
  112457. * Main function for light texture projection matrix computing.
  112458. */
  112459. protected _computeProjectionTextureMatrix(): void;
  112460. protected _buildUniformLayout(): void;
  112461. private _computeAngleValues;
  112462. /**
  112463. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  112464. * @param effect The effect to update
  112465. * @param lightIndex The index of the light in the effect to update
  112466. * @returns The spot light
  112467. */
  112468. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  112469. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  112470. /**
  112471. * Disposes the light and the associated resources.
  112472. */
  112473. dispose(): void;
  112474. /**
  112475. * Prepares the list of defines specific to the light type.
  112476. * @param defines the list of defines
  112477. * @param lightIndex defines the index of the light for the effect
  112478. */
  112479. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112480. }
  112481. }
  112482. declare module BABYLON {
  112483. /**
  112484. * Gizmo that enables viewing a light
  112485. */
  112486. export class LightGizmo extends Gizmo {
  112487. private _lightMesh;
  112488. private _material;
  112489. private cachedPosition;
  112490. private cachedForward;
  112491. /**
  112492. * Creates a LightGizmo
  112493. * @param gizmoLayer The utility layer the gizmo will be added to
  112494. */
  112495. constructor(gizmoLayer?: UtilityLayerRenderer);
  112496. private _light;
  112497. /**
  112498. * The light that the gizmo is attached to
  112499. */
  112500. light: Nullable<Light>;
  112501. /**
  112502. * Gets the material used to render the light gizmo
  112503. */
  112504. readonly material: StandardMaterial;
  112505. /**
  112506. * @hidden
  112507. * Updates the gizmo to match the attached mesh's position/rotation
  112508. */
  112509. protected _update(): void;
  112510. private static _Scale;
  112511. /**
  112512. * Creates the lines for a light mesh
  112513. */
  112514. private static _createLightLines;
  112515. /**
  112516. * Disposes of the light gizmo
  112517. */
  112518. dispose(): void;
  112519. private static _CreateHemisphericLightMesh;
  112520. private static _CreatePointLightMesh;
  112521. private static _CreateSpotLightMesh;
  112522. private static _CreateDirectionalLightMesh;
  112523. }
  112524. }
  112525. declare module BABYLON {
  112526. /** @hidden */
  112527. export var backgroundFragmentDeclaration: {
  112528. name: string;
  112529. shader: string;
  112530. };
  112531. }
  112532. declare module BABYLON {
  112533. /** @hidden */
  112534. export var backgroundUboDeclaration: {
  112535. name: string;
  112536. shader: string;
  112537. };
  112538. }
  112539. declare module BABYLON {
  112540. /** @hidden */
  112541. export var backgroundPixelShader: {
  112542. name: string;
  112543. shader: string;
  112544. };
  112545. }
  112546. declare module BABYLON {
  112547. /** @hidden */
  112548. export var backgroundVertexDeclaration: {
  112549. name: string;
  112550. shader: string;
  112551. };
  112552. }
  112553. declare module BABYLON {
  112554. /** @hidden */
  112555. export var backgroundVertexShader: {
  112556. name: string;
  112557. shader: string;
  112558. };
  112559. }
  112560. declare module BABYLON {
  112561. /**
  112562. * Background material used to create an efficient environement around your scene.
  112563. */
  112564. export class BackgroundMaterial extends PushMaterial {
  112565. /**
  112566. * Standard reflectance value at parallel view angle.
  112567. */
  112568. static StandardReflectance0: number;
  112569. /**
  112570. * Standard reflectance value at grazing angle.
  112571. */
  112572. static StandardReflectance90: number;
  112573. protected _primaryColor: Color3;
  112574. /**
  112575. * Key light Color (multiply against the environement texture)
  112576. */
  112577. primaryColor: Color3;
  112578. protected __perceptualColor: Nullable<Color3>;
  112579. /**
  112580. * Experimental Internal Use Only.
  112581. *
  112582. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  112583. * This acts as a helper to set the primary color to a more "human friendly" value.
  112584. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  112585. * output color as close as possible from the chosen value.
  112586. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  112587. * part of lighting setup.)
  112588. */
  112589. _perceptualColor: Nullable<Color3>;
  112590. protected _primaryColorShadowLevel: float;
  112591. /**
  112592. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  112593. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  112594. */
  112595. primaryColorShadowLevel: float;
  112596. protected _primaryColorHighlightLevel: float;
  112597. /**
  112598. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  112599. * The primary color is used at the level chosen to define what the white area would look.
  112600. */
  112601. primaryColorHighlightLevel: float;
  112602. protected _reflectionTexture: Nullable<BaseTexture>;
  112603. /**
  112604. * Reflection Texture used in the material.
  112605. * Should be author in a specific way for the best result (refer to the documentation).
  112606. */
  112607. reflectionTexture: Nullable<BaseTexture>;
  112608. protected _reflectionBlur: float;
  112609. /**
  112610. * Reflection Texture level of blur.
  112611. *
  112612. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  112613. * texture twice.
  112614. */
  112615. reflectionBlur: float;
  112616. protected _diffuseTexture: Nullable<BaseTexture>;
  112617. /**
  112618. * Diffuse Texture used in the material.
  112619. * Should be author in a specific way for the best result (refer to the documentation).
  112620. */
  112621. diffuseTexture: Nullable<BaseTexture>;
  112622. protected _shadowLights: Nullable<IShadowLight[]>;
  112623. /**
  112624. * Specify the list of lights casting shadow on the material.
  112625. * All scene shadow lights will be included if null.
  112626. */
  112627. shadowLights: Nullable<IShadowLight[]>;
  112628. protected _shadowLevel: float;
  112629. /**
  112630. * Helps adjusting the shadow to a softer level if required.
  112631. * 0 means black shadows and 1 means no shadows.
  112632. */
  112633. shadowLevel: float;
  112634. protected _sceneCenter: Vector3;
  112635. /**
  112636. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  112637. * It is usually zero but might be interesting to modify according to your setup.
  112638. */
  112639. sceneCenter: Vector3;
  112640. protected _opacityFresnel: boolean;
  112641. /**
  112642. * This helps specifying that the material is falling off to the sky box at grazing angle.
  112643. * This helps ensuring a nice transition when the camera goes under the ground.
  112644. */
  112645. opacityFresnel: boolean;
  112646. protected _reflectionFresnel: boolean;
  112647. /**
  112648. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  112649. * This helps adding a mirror texture on the ground.
  112650. */
  112651. reflectionFresnel: boolean;
  112652. protected _reflectionFalloffDistance: number;
  112653. /**
  112654. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  112655. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  112656. */
  112657. reflectionFalloffDistance: number;
  112658. protected _reflectionAmount: number;
  112659. /**
  112660. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  112661. */
  112662. reflectionAmount: number;
  112663. protected _reflectionReflectance0: number;
  112664. /**
  112665. * This specifies the weight of the reflection at grazing angle.
  112666. */
  112667. reflectionReflectance0: number;
  112668. protected _reflectionReflectance90: number;
  112669. /**
  112670. * This specifies the weight of the reflection at a perpendicular point of view.
  112671. */
  112672. reflectionReflectance90: number;
  112673. /**
  112674. * Sets the reflection reflectance fresnel values according to the default standard
  112675. * empirically know to work well :-)
  112676. */
  112677. reflectionStandardFresnelWeight: number;
  112678. protected _useRGBColor: boolean;
  112679. /**
  112680. * Helps to directly use the maps channels instead of their level.
  112681. */
  112682. useRGBColor: boolean;
  112683. protected _enableNoise: boolean;
  112684. /**
  112685. * This helps reducing the banding effect that could occur on the background.
  112686. */
  112687. enableNoise: boolean;
  112688. /**
  112689. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112690. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  112691. * Recommended to be keep at 1.0 except for special cases.
  112692. */
  112693. fovMultiplier: number;
  112694. private _fovMultiplier;
  112695. /**
  112696. * Enable the FOV adjustment feature controlled by fovMultiplier.
  112697. */
  112698. useEquirectangularFOV: boolean;
  112699. private _maxSimultaneousLights;
  112700. /**
  112701. * Number of Simultaneous lights allowed on the material.
  112702. */
  112703. maxSimultaneousLights: int;
  112704. /**
  112705. * Default configuration related to image processing available in the Background Material.
  112706. */
  112707. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112708. /**
  112709. * Keep track of the image processing observer to allow dispose and replace.
  112710. */
  112711. private _imageProcessingObserver;
  112712. /**
  112713. * Attaches a new image processing configuration to the PBR Material.
  112714. * @param configuration (if null the scene configuration will be use)
  112715. */
  112716. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112717. /**
  112718. * Gets the image processing configuration used either in this material.
  112719. */
  112720. /**
  112721. * Sets the Default image processing configuration used either in the this material.
  112722. *
  112723. * If sets to null, the scene one is in use.
  112724. */
  112725. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  112726. /**
  112727. * Gets wether the color curves effect is enabled.
  112728. */
  112729. /**
  112730. * Sets wether the color curves effect is enabled.
  112731. */
  112732. cameraColorCurvesEnabled: boolean;
  112733. /**
  112734. * Gets wether the color grading effect is enabled.
  112735. */
  112736. /**
  112737. * Gets wether the color grading effect is enabled.
  112738. */
  112739. cameraColorGradingEnabled: boolean;
  112740. /**
  112741. * Gets wether tonemapping is enabled or not.
  112742. */
  112743. /**
  112744. * Sets wether tonemapping is enabled or not
  112745. */
  112746. cameraToneMappingEnabled: boolean;
  112747. /**
  112748. * The camera exposure used on this material.
  112749. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112750. * This corresponds to a photographic exposure.
  112751. */
  112752. /**
  112753. * The camera exposure used on this material.
  112754. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112755. * This corresponds to a photographic exposure.
  112756. */
  112757. cameraExposure: float;
  112758. /**
  112759. * Gets The camera contrast used on this material.
  112760. */
  112761. /**
  112762. * Sets The camera contrast used on this material.
  112763. */
  112764. cameraContrast: float;
  112765. /**
  112766. * Gets the Color Grading 2D Lookup Texture.
  112767. */
  112768. /**
  112769. * Sets the Color Grading 2D Lookup Texture.
  112770. */
  112771. cameraColorGradingTexture: Nullable<BaseTexture>;
  112772. /**
  112773. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112774. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112775. * 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;
  112776. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112777. */
  112778. /**
  112779. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112780. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112781. * 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;
  112782. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112783. */
  112784. cameraColorCurves: Nullable<ColorCurves>;
  112785. /**
  112786. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  112787. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  112788. */
  112789. switchToBGR: boolean;
  112790. private _renderTargets;
  112791. private _reflectionControls;
  112792. private _white;
  112793. private _primaryShadowColor;
  112794. private _primaryHighlightColor;
  112795. /**
  112796. * Instantiates a Background Material in the given scene
  112797. * @param name The friendly name of the material
  112798. * @param scene The scene to add the material to
  112799. */
  112800. constructor(name: string, scene: Scene);
  112801. /**
  112802. * Gets a boolean indicating that current material needs to register RTT
  112803. */
  112804. readonly hasRenderTargetTextures: boolean;
  112805. /**
  112806. * The entire material has been created in order to prevent overdraw.
  112807. * @returns false
  112808. */
  112809. needAlphaTesting(): boolean;
  112810. /**
  112811. * The entire material has been created in order to prevent overdraw.
  112812. * @returns true if blending is enable
  112813. */
  112814. needAlphaBlending(): boolean;
  112815. /**
  112816. * Checks wether the material is ready to be rendered for a given mesh.
  112817. * @param mesh The mesh to render
  112818. * @param subMesh The submesh to check against
  112819. * @param useInstances Specify wether or not the material is used with instances
  112820. * @returns true if all the dependencies are ready (Textures, Effects...)
  112821. */
  112822. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112823. /**
  112824. * Compute the primary color according to the chosen perceptual color.
  112825. */
  112826. private _computePrimaryColorFromPerceptualColor;
  112827. /**
  112828. * Compute the highlights and shadow colors according to their chosen levels.
  112829. */
  112830. private _computePrimaryColors;
  112831. /**
  112832. * Build the uniform buffer used in the material.
  112833. */
  112834. buildUniformLayout(): void;
  112835. /**
  112836. * Unbind the material.
  112837. */
  112838. unbind(): void;
  112839. /**
  112840. * Bind only the world matrix to the material.
  112841. * @param world The world matrix to bind.
  112842. */
  112843. bindOnlyWorldMatrix(world: Matrix): void;
  112844. /**
  112845. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  112846. * @param world The world matrix to bind.
  112847. * @param subMesh The submesh to bind for.
  112848. */
  112849. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112850. /**
  112851. * Checks to see if a texture is used in the material.
  112852. * @param texture - Base texture to use.
  112853. * @returns - Boolean specifying if a texture is used in the material.
  112854. */
  112855. hasTexture(texture: BaseTexture): boolean;
  112856. /**
  112857. * Dispose the material.
  112858. * @param forceDisposeEffect Force disposal of the associated effect.
  112859. * @param forceDisposeTextures Force disposal of the associated textures.
  112860. */
  112861. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112862. /**
  112863. * Clones the material.
  112864. * @param name The cloned name.
  112865. * @returns The cloned material.
  112866. */
  112867. clone(name: string): BackgroundMaterial;
  112868. /**
  112869. * Serializes the current material to its JSON representation.
  112870. * @returns The JSON representation.
  112871. */
  112872. serialize(): any;
  112873. /**
  112874. * Gets the class name of the material
  112875. * @returns "BackgroundMaterial"
  112876. */
  112877. getClassName(): string;
  112878. /**
  112879. * Parse a JSON input to create back a background material.
  112880. * @param source The JSON data to parse
  112881. * @param scene The scene to create the parsed material in
  112882. * @param rootUrl The root url of the assets the material depends upon
  112883. * @returns the instantiated BackgroundMaterial.
  112884. */
  112885. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  112886. }
  112887. }
  112888. declare module BABYLON {
  112889. /**
  112890. * Represents the different options available during the creation of
  112891. * a Environment helper.
  112892. *
  112893. * This can control the default ground, skybox and image processing setup of your scene.
  112894. */
  112895. export interface IEnvironmentHelperOptions {
  112896. /**
  112897. * Specifies wether or not to create a ground.
  112898. * True by default.
  112899. */
  112900. createGround: boolean;
  112901. /**
  112902. * Specifies the ground size.
  112903. * 15 by default.
  112904. */
  112905. groundSize: number;
  112906. /**
  112907. * The texture used on the ground for the main color.
  112908. * Comes from the BabylonJS CDN by default.
  112909. *
  112910. * Remarks: Can be either a texture or a url.
  112911. */
  112912. groundTexture: string | BaseTexture;
  112913. /**
  112914. * The color mixed in the ground texture by default.
  112915. * BabylonJS clearColor by default.
  112916. */
  112917. groundColor: Color3;
  112918. /**
  112919. * Specifies the ground opacity.
  112920. * 1 by default.
  112921. */
  112922. groundOpacity: number;
  112923. /**
  112924. * Enables the ground to receive shadows.
  112925. * True by default.
  112926. */
  112927. enableGroundShadow: boolean;
  112928. /**
  112929. * Helps preventing the shadow to be fully black on the ground.
  112930. * 0.5 by default.
  112931. */
  112932. groundShadowLevel: number;
  112933. /**
  112934. * Creates a mirror texture attach to the ground.
  112935. * false by default.
  112936. */
  112937. enableGroundMirror: boolean;
  112938. /**
  112939. * Specifies the ground mirror size ratio.
  112940. * 0.3 by default as the default kernel is 64.
  112941. */
  112942. groundMirrorSizeRatio: number;
  112943. /**
  112944. * Specifies the ground mirror blur kernel size.
  112945. * 64 by default.
  112946. */
  112947. groundMirrorBlurKernel: number;
  112948. /**
  112949. * Specifies the ground mirror visibility amount.
  112950. * 1 by default
  112951. */
  112952. groundMirrorAmount: number;
  112953. /**
  112954. * Specifies the ground mirror reflectance weight.
  112955. * This uses the standard weight of the background material to setup the fresnel effect
  112956. * of the mirror.
  112957. * 1 by default.
  112958. */
  112959. groundMirrorFresnelWeight: number;
  112960. /**
  112961. * Specifies the ground mirror Falloff distance.
  112962. * This can helps reducing the size of the reflection.
  112963. * 0 by Default.
  112964. */
  112965. groundMirrorFallOffDistance: number;
  112966. /**
  112967. * Specifies the ground mirror texture type.
  112968. * Unsigned Int by Default.
  112969. */
  112970. groundMirrorTextureType: number;
  112971. /**
  112972. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  112973. * the shown objects.
  112974. */
  112975. groundYBias: number;
  112976. /**
  112977. * Specifies wether or not to create a skybox.
  112978. * True by default.
  112979. */
  112980. createSkybox: boolean;
  112981. /**
  112982. * Specifies the skybox size.
  112983. * 20 by default.
  112984. */
  112985. skyboxSize: number;
  112986. /**
  112987. * The texture used on the skybox for the main color.
  112988. * Comes from the BabylonJS CDN by default.
  112989. *
  112990. * Remarks: Can be either a texture or a url.
  112991. */
  112992. skyboxTexture: string | BaseTexture;
  112993. /**
  112994. * The color mixed in the skybox texture by default.
  112995. * BabylonJS clearColor by default.
  112996. */
  112997. skyboxColor: Color3;
  112998. /**
  112999. * The background rotation around the Y axis of the scene.
  113000. * This helps aligning the key lights of your scene with the background.
  113001. * 0 by default.
  113002. */
  113003. backgroundYRotation: number;
  113004. /**
  113005. * Compute automatically the size of the elements to best fit with the scene.
  113006. */
  113007. sizeAuto: boolean;
  113008. /**
  113009. * Default position of the rootMesh if autoSize is not true.
  113010. */
  113011. rootPosition: Vector3;
  113012. /**
  113013. * Sets up the image processing in the scene.
  113014. * true by default.
  113015. */
  113016. setupImageProcessing: boolean;
  113017. /**
  113018. * The texture used as your environment texture in the scene.
  113019. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  113020. *
  113021. * Remarks: Can be either a texture or a url.
  113022. */
  113023. environmentTexture: string | BaseTexture;
  113024. /**
  113025. * The value of the exposure to apply to the scene.
  113026. * 0.6 by default if setupImageProcessing is true.
  113027. */
  113028. cameraExposure: number;
  113029. /**
  113030. * The value of the contrast to apply to the scene.
  113031. * 1.6 by default if setupImageProcessing is true.
  113032. */
  113033. cameraContrast: number;
  113034. /**
  113035. * Specifies wether or not tonemapping should be enabled in the scene.
  113036. * true by default if setupImageProcessing is true.
  113037. */
  113038. toneMappingEnabled: boolean;
  113039. }
  113040. /**
  113041. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  113042. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  113043. * It also helps with the default setup of your imageProcessing configuration.
  113044. */
  113045. export class EnvironmentHelper {
  113046. /**
  113047. * Default ground texture URL.
  113048. */
  113049. private static _groundTextureCDNUrl;
  113050. /**
  113051. * Default skybox texture URL.
  113052. */
  113053. private static _skyboxTextureCDNUrl;
  113054. /**
  113055. * Default environment texture URL.
  113056. */
  113057. private static _environmentTextureCDNUrl;
  113058. /**
  113059. * Creates the default options for the helper.
  113060. */
  113061. private static _getDefaultOptions;
  113062. private _rootMesh;
  113063. /**
  113064. * Gets the root mesh created by the helper.
  113065. */
  113066. readonly rootMesh: Mesh;
  113067. private _skybox;
  113068. /**
  113069. * Gets the skybox created by the helper.
  113070. */
  113071. readonly skybox: Nullable<Mesh>;
  113072. private _skyboxTexture;
  113073. /**
  113074. * Gets the skybox texture created by the helper.
  113075. */
  113076. readonly skyboxTexture: Nullable<BaseTexture>;
  113077. private _skyboxMaterial;
  113078. /**
  113079. * Gets the skybox material created by the helper.
  113080. */
  113081. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  113082. private _ground;
  113083. /**
  113084. * Gets the ground mesh created by the helper.
  113085. */
  113086. readonly ground: Nullable<Mesh>;
  113087. private _groundTexture;
  113088. /**
  113089. * Gets the ground texture created by the helper.
  113090. */
  113091. readonly groundTexture: Nullable<BaseTexture>;
  113092. private _groundMirror;
  113093. /**
  113094. * Gets the ground mirror created by the helper.
  113095. */
  113096. readonly groundMirror: Nullable<MirrorTexture>;
  113097. /**
  113098. * Gets the ground mirror render list to helps pushing the meshes
  113099. * you wish in the ground reflection.
  113100. */
  113101. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  113102. private _groundMaterial;
  113103. /**
  113104. * Gets the ground material created by the helper.
  113105. */
  113106. readonly groundMaterial: Nullable<BackgroundMaterial>;
  113107. /**
  113108. * Stores the creation options.
  113109. */
  113110. private readonly _scene;
  113111. private _options;
  113112. /**
  113113. * This observable will be notified with any error during the creation of the environment,
  113114. * mainly texture creation errors.
  113115. */
  113116. onErrorObservable: Observable<{
  113117. message?: string;
  113118. exception?: any;
  113119. }>;
  113120. /**
  113121. * constructor
  113122. * @param options Defines the options we want to customize the helper
  113123. * @param scene The scene to add the material to
  113124. */
  113125. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  113126. /**
  113127. * Updates the background according to the new options
  113128. * @param options
  113129. */
  113130. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  113131. /**
  113132. * Sets the primary color of all the available elements.
  113133. * @param color the main color to affect to the ground and the background
  113134. */
  113135. setMainColor(color: Color3): void;
  113136. /**
  113137. * Setup the image processing according to the specified options.
  113138. */
  113139. private _setupImageProcessing;
  113140. /**
  113141. * Setup the environment texture according to the specified options.
  113142. */
  113143. private _setupEnvironmentTexture;
  113144. /**
  113145. * Setup the background according to the specified options.
  113146. */
  113147. private _setupBackground;
  113148. /**
  113149. * Get the scene sizes according to the setup.
  113150. */
  113151. private _getSceneSize;
  113152. /**
  113153. * Setup the ground according to the specified options.
  113154. */
  113155. private _setupGround;
  113156. /**
  113157. * Setup the ground material according to the specified options.
  113158. */
  113159. private _setupGroundMaterial;
  113160. /**
  113161. * Setup the ground diffuse texture according to the specified options.
  113162. */
  113163. private _setupGroundDiffuseTexture;
  113164. /**
  113165. * Setup the ground mirror texture according to the specified options.
  113166. */
  113167. private _setupGroundMirrorTexture;
  113168. /**
  113169. * Setup the ground to receive the mirror texture.
  113170. */
  113171. private _setupMirrorInGroundMaterial;
  113172. /**
  113173. * Setup the skybox according to the specified options.
  113174. */
  113175. private _setupSkybox;
  113176. /**
  113177. * Setup the skybox material according to the specified options.
  113178. */
  113179. private _setupSkyboxMaterial;
  113180. /**
  113181. * Setup the skybox reflection texture according to the specified options.
  113182. */
  113183. private _setupSkyboxReflectionTexture;
  113184. private _errorHandler;
  113185. /**
  113186. * Dispose all the elements created by the Helper.
  113187. */
  113188. dispose(): void;
  113189. }
  113190. }
  113191. declare module BABYLON {
  113192. /**
  113193. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  113194. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  113195. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  113196. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113197. */
  113198. export class PhotoDome extends TransformNode {
  113199. /**
  113200. * Define the image as a Monoscopic panoramic 360 image.
  113201. */
  113202. static readonly MODE_MONOSCOPIC: number;
  113203. /**
  113204. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113205. */
  113206. static readonly MODE_TOPBOTTOM: number;
  113207. /**
  113208. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113209. */
  113210. static readonly MODE_SIDEBYSIDE: number;
  113211. private _useDirectMapping;
  113212. /**
  113213. * The texture being displayed on the sphere
  113214. */
  113215. protected _photoTexture: Texture;
  113216. /**
  113217. * Gets or sets the texture being displayed on the sphere
  113218. */
  113219. photoTexture: Texture;
  113220. /**
  113221. * Observable raised when an error occured while loading the 360 image
  113222. */
  113223. onLoadErrorObservable: Observable<string>;
  113224. /**
  113225. * The skybox material
  113226. */
  113227. protected _material: BackgroundMaterial;
  113228. /**
  113229. * The surface used for the skybox
  113230. */
  113231. protected _mesh: Mesh;
  113232. /**
  113233. * Gets the mesh used for the skybox.
  113234. */
  113235. readonly mesh: Mesh;
  113236. /**
  113237. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113238. * Also see the options.resolution property.
  113239. */
  113240. fovMultiplier: number;
  113241. private _imageMode;
  113242. /**
  113243. * Gets or set the current video mode for the video. It can be:
  113244. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  113245. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113246. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113247. */
  113248. imageMode: number;
  113249. /**
  113250. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  113251. * @param name Element's name, child elements will append suffixes for their own names.
  113252. * @param urlsOfPhoto defines the url of the photo to display
  113253. * @param options defines an object containing optional or exposed sub element properties
  113254. * @param onError defines a callback called when an error occured while loading the texture
  113255. */
  113256. constructor(name: string, urlOfPhoto: string, options: {
  113257. resolution?: number;
  113258. size?: number;
  113259. useDirectMapping?: boolean;
  113260. faceForward?: boolean;
  113261. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  113262. private _onBeforeCameraRenderObserver;
  113263. private _changeImageMode;
  113264. /**
  113265. * Releases resources associated with this node.
  113266. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113267. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113268. */
  113269. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113270. }
  113271. }
  113272. declare module BABYLON {
  113273. /**
  113274. * Class used to host RGBD texture specific utilities
  113275. */
  113276. export class RGBDTextureTools {
  113277. /**
  113278. * Expand the RGBD Texture from RGBD to Half Float if possible.
  113279. * @param texture the texture to expand.
  113280. */
  113281. static ExpandRGBDTexture(texture: Texture): void;
  113282. }
  113283. }
  113284. declare module BABYLON {
  113285. /**
  113286. * Class used to host texture specific utilities
  113287. */
  113288. export class BRDFTextureTools {
  113289. /**
  113290. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  113291. * @param scene defines the hosting scene
  113292. * @returns the environment BRDF texture
  113293. */
  113294. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  113295. private static _environmentBRDFBase64Texture;
  113296. }
  113297. }
  113298. declare module BABYLON {
  113299. /**
  113300. * @hidden
  113301. */
  113302. export interface IMaterialClearCoatDefines {
  113303. CLEARCOAT: boolean;
  113304. CLEARCOAT_DEFAULTIOR: boolean;
  113305. CLEARCOAT_TEXTURE: boolean;
  113306. CLEARCOAT_TEXTUREDIRECTUV: number;
  113307. CLEARCOAT_BUMP: boolean;
  113308. CLEARCOAT_BUMPDIRECTUV: number;
  113309. CLEARCOAT_TINT: boolean;
  113310. CLEARCOAT_TINT_TEXTURE: boolean;
  113311. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  113312. /** @hidden */
  113313. _areTexturesDirty: boolean;
  113314. }
  113315. /**
  113316. * Define the code related to the clear coat parameters of the pbr material.
  113317. */
  113318. export class PBRClearCoatConfiguration {
  113319. /**
  113320. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113321. * The default fits with a polyurethane material.
  113322. */
  113323. private static readonly _DefaultIndexOfRefraction;
  113324. private _isEnabled;
  113325. /**
  113326. * Defines if the clear coat is enabled in the material.
  113327. */
  113328. isEnabled: boolean;
  113329. /**
  113330. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  113331. */
  113332. intensity: number;
  113333. /**
  113334. * Defines the clear coat layer roughness.
  113335. */
  113336. roughness: number;
  113337. private _indexOfRefraction;
  113338. /**
  113339. * Defines the index of refraction of the clear coat.
  113340. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113341. * The default fits with a polyurethane material.
  113342. * Changing the default value is more performance intensive.
  113343. */
  113344. indexOfRefraction: number;
  113345. private _texture;
  113346. /**
  113347. * Stores the clear coat values in a texture.
  113348. */
  113349. texture: Nullable<BaseTexture>;
  113350. private _bumpTexture;
  113351. /**
  113352. * Define the clear coat specific bump texture.
  113353. */
  113354. bumpTexture: Nullable<BaseTexture>;
  113355. private _isTintEnabled;
  113356. /**
  113357. * Defines if the clear coat tint is enabled in the material.
  113358. */
  113359. isTintEnabled: boolean;
  113360. /**
  113361. * Defines the clear coat tint of the material.
  113362. * This is only use if tint is enabled
  113363. */
  113364. tintColor: Color3;
  113365. /**
  113366. * Defines the distance at which the tint color should be found in the
  113367. * clear coat media.
  113368. * This is only use if tint is enabled
  113369. */
  113370. tintColorAtDistance: number;
  113371. /**
  113372. * Defines the clear coat layer thickness.
  113373. * This is only use if tint is enabled
  113374. */
  113375. tintThickness: number;
  113376. private _tintTexture;
  113377. /**
  113378. * Stores the clear tint values in a texture.
  113379. * rgb is tint
  113380. * a is a thickness factor
  113381. */
  113382. tintTexture: Nullable<BaseTexture>;
  113383. /** @hidden */
  113384. private _internalMarkAllSubMeshesAsTexturesDirty;
  113385. /** @hidden */
  113386. _markAllSubMeshesAsTexturesDirty(): void;
  113387. /**
  113388. * Instantiate a new istance of clear coat configuration.
  113389. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113390. */
  113391. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113392. /**
  113393. * Gets wehter the submesh is ready to be used or not.
  113394. * @param defines the list of "defines" to update.
  113395. * @param scene defines the scene the material belongs to.
  113396. * @param engine defines the engine the material belongs to.
  113397. * @param disableBumpMap defines wether the material disables bump or not.
  113398. * @returns - boolean indicating that the submesh is ready or not.
  113399. */
  113400. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  113401. /**
  113402. * Checks to see if a texture is used in the material.
  113403. * @param defines the list of "defines" to update.
  113404. * @param scene defines the scene to the material belongs to.
  113405. */
  113406. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  113407. /**
  113408. * Binds the material data.
  113409. * @param uniformBuffer defines the Uniform buffer to fill in.
  113410. * @param scene defines the scene the material belongs to.
  113411. * @param engine defines the engine the material belongs to.
  113412. * @param disableBumpMap defines wether the material disables bump or not.
  113413. * @param isFrozen defines wether the material is frozen or not.
  113414. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113415. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113416. */
  113417. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  113418. /**
  113419. * Checks to see if a texture is used in the material.
  113420. * @param texture - Base texture to use.
  113421. * @returns - Boolean specifying if a texture is used in the material.
  113422. */
  113423. hasTexture(texture: BaseTexture): boolean;
  113424. /**
  113425. * Returns an array of the actively used textures.
  113426. * @param activeTextures Array of BaseTextures
  113427. */
  113428. getActiveTextures(activeTextures: BaseTexture[]): void;
  113429. /**
  113430. * Returns the animatable textures.
  113431. * @param animatables Array of animatable textures.
  113432. */
  113433. getAnimatables(animatables: IAnimatable[]): void;
  113434. /**
  113435. * Disposes the resources of the material.
  113436. * @param forceDisposeTextures - Forces the disposal of all textures.
  113437. */
  113438. dispose(forceDisposeTextures?: boolean): void;
  113439. /**
  113440. * Get the current class name of the texture useful for serialization or dynamic coding.
  113441. * @returns "PBRClearCoatConfiguration"
  113442. */
  113443. getClassName(): string;
  113444. /**
  113445. * Add fallbacks to the effect fallbacks list.
  113446. * @param defines defines the Base texture to use.
  113447. * @param fallbacks defines the current fallback list.
  113448. * @param currentRank defines the current fallback rank.
  113449. * @returns the new fallback rank.
  113450. */
  113451. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113452. /**
  113453. * Add the required uniforms to the current list.
  113454. * @param uniforms defines the current uniform list.
  113455. */
  113456. static AddUniforms(uniforms: string[]): void;
  113457. /**
  113458. * Add the required samplers to the current list.
  113459. * @param samplers defines the current sampler list.
  113460. */
  113461. static AddSamplers(samplers: string[]): void;
  113462. /**
  113463. * Add the required uniforms to the current buffer.
  113464. * @param uniformBuffer defines the current uniform buffer.
  113465. */
  113466. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113467. /**
  113468. * Makes a duplicate of the current configuration into another one.
  113469. * @param clearCoatConfiguration define the config where to copy the info
  113470. */
  113471. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  113472. /**
  113473. * Serializes this clear coat configuration.
  113474. * @returns - An object with the serialized config.
  113475. */
  113476. serialize(): any;
  113477. /**
  113478. * Parses a anisotropy Configuration from a serialized object.
  113479. * @param source - Serialized object.
  113480. * @param scene Defines the scene we are parsing for
  113481. * @param rootUrl Defines the rootUrl to load from
  113482. */
  113483. parse(source: any, scene: Scene, rootUrl: string): void;
  113484. }
  113485. }
  113486. declare module BABYLON {
  113487. /**
  113488. * @hidden
  113489. */
  113490. export interface IMaterialAnisotropicDefines {
  113491. ANISOTROPIC: boolean;
  113492. ANISOTROPIC_TEXTURE: boolean;
  113493. ANISOTROPIC_TEXTUREDIRECTUV: number;
  113494. MAINUV1: boolean;
  113495. _areTexturesDirty: boolean;
  113496. _needUVs: boolean;
  113497. }
  113498. /**
  113499. * Define the code related to the anisotropic parameters of the pbr material.
  113500. */
  113501. export class PBRAnisotropicConfiguration {
  113502. private _isEnabled;
  113503. /**
  113504. * Defines if the anisotropy is enabled in the material.
  113505. */
  113506. isEnabled: boolean;
  113507. /**
  113508. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  113509. */
  113510. intensity: number;
  113511. /**
  113512. * Defines if the effect is along the tangents, bitangents or in between.
  113513. * By default, the effect is "strectching" the highlights along the tangents.
  113514. */
  113515. direction: Vector2;
  113516. private _texture;
  113517. /**
  113518. * Stores the anisotropy values in a texture.
  113519. * rg is direction (like normal from -1 to 1)
  113520. * b is a intensity
  113521. */
  113522. texture: Nullable<BaseTexture>;
  113523. /** @hidden */
  113524. private _internalMarkAllSubMeshesAsTexturesDirty;
  113525. /** @hidden */
  113526. _markAllSubMeshesAsTexturesDirty(): void;
  113527. /**
  113528. * Instantiate a new istance of anisotropy configuration.
  113529. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113530. */
  113531. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113532. /**
  113533. * Specifies that the submesh is ready to be used.
  113534. * @param defines the list of "defines" to update.
  113535. * @param scene defines the scene the material belongs to.
  113536. * @returns - boolean indicating that the submesh is ready or not.
  113537. */
  113538. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  113539. /**
  113540. * Checks to see if a texture is used in the material.
  113541. * @param defines the list of "defines" to update.
  113542. * @param mesh the mesh we are preparing the defines for.
  113543. * @param scene defines the scene the material belongs to.
  113544. */
  113545. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  113546. /**
  113547. * Binds the material data.
  113548. * @param uniformBuffer defines the Uniform buffer to fill in.
  113549. * @param scene defines the scene the material belongs to.
  113550. * @param isFrozen defines wether the material is frozen or not.
  113551. */
  113552. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113553. /**
  113554. * Checks to see if a texture is used in the material.
  113555. * @param texture - Base texture to use.
  113556. * @returns - Boolean specifying if a texture is used in the material.
  113557. */
  113558. hasTexture(texture: BaseTexture): boolean;
  113559. /**
  113560. * Returns an array of the actively used textures.
  113561. * @param activeTextures Array of BaseTextures
  113562. */
  113563. getActiveTextures(activeTextures: BaseTexture[]): void;
  113564. /**
  113565. * Returns the animatable textures.
  113566. * @param animatables Array of animatable textures.
  113567. */
  113568. getAnimatables(animatables: IAnimatable[]): void;
  113569. /**
  113570. * Disposes the resources of the material.
  113571. * @param forceDisposeTextures - Forces the disposal of all textures.
  113572. */
  113573. dispose(forceDisposeTextures?: boolean): void;
  113574. /**
  113575. * Get the current class name of the texture useful for serialization or dynamic coding.
  113576. * @returns "PBRAnisotropicConfiguration"
  113577. */
  113578. getClassName(): string;
  113579. /**
  113580. * Add fallbacks to the effect fallbacks list.
  113581. * @param defines defines the Base texture to use.
  113582. * @param fallbacks defines the current fallback list.
  113583. * @param currentRank defines the current fallback rank.
  113584. * @returns the new fallback rank.
  113585. */
  113586. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113587. /**
  113588. * Add the required uniforms to the current list.
  113589. * @param uniforms defines the current uniform list.
  113590. */
  113591. static AddUniforms(uniforms: string[]): void;
  113592. /**
  113593. * Add the required uniforms to the current buffer.
  113594. * @param uniformBuffer defines the current uniform buffer.
  113595. */
  113596. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113597. /**
  113598. * Add the required samplers to the current list.
  113599. * @param samplers defines the current sampler list.
  113600. */
  113601. static AddSamplers(samplers: string[]): void;
  113602. /**
  113603. * Makes a duplicate of the current configuration into another one.
  113604. * @param anisotropicConfiguration define the config where to copy the info
  113605. */
  113606. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  113607. /**
  113608. * Serializes this anisotropy configuration.
  113609. * @returns - An object with the serialized config.
  113610. */
  113611. serialize(): any;
  113612. /**
  113613. * Parses a anisotropy Configuration from a serialized object.
  113614. * @param source - Serialized object.
  113615. * @param scene Defines the scene we are parsing for
  113616. * @param rootUrl Defines the rootUrl to load from
  113617. */
  113618. parse(source: any, scene: Scene, rootUrl: string): void;
  113619. }
  113620. }
  113621. declare module BABYLON {
  113622. /**
  113623. * @hidden
  113624. */
  113625. export interface IMaterialBRDFDefines {
  113626. BRDF_V_HEIGHT_CORRELATED: boolean;
  113627. MS_BRDF_ENERGY_CONSERVATION: boolean;
  113628. SPHERICAL_HARMONICS: boolean;
  113629. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  113630. /** @hidden */
  113631. _areMiscDirty: boolean;
  113632. }
  113633. /**
  113634. * Define the code related to the BRDF parameters of the pbr material.
  113635. */
  113636. export class PBRBRDFConfiguration {
  113637. /**
  113638. * Default value used for the energy conservation.
  113639. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113640. */
  113641. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  113642. /**
  113643. * Default value used for the Smith Visibility Height Correlated mode.
  113644. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113645. */
  113646. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  113647. /**
  113648. * Default value used for the IBL diffuse part.
  113649. * This can help switching back to the polynomials mode globally which is a tiny bit
  113650. * less GPU intensive at the drawback of a lower quality.
  113651. */
  113652. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  113653. /**
  113654. * Default value used for activating energy conservation for the specular workflow.
  113655. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113656. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113657. */
  113658. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  113659. private _useEnergyConservation;
  113660. /**
  113661. * Defines if the material uses energy conservation.
  113662. */
  113663. useEnergyConservation: boolean;
  113664. private _useSmithVisibilityHeightCorrelated;
  113665. /**
  113666. * LEGACY Mode set to false
  113667. * Defines if the material uses height smith correlated visibility term.
  113668. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  113669. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  113670. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  113671. * Not relying on height correlated will also disable energy conservation.
  113672. */
  113673. useSmithVisibilityHeightCorrelated: boolean;
  113674. private _useSphericalHarmonics;
  113675. /**
  113676. * LEGACY Mode set to false
  113677. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  113678. * diffuse part of the IBL.
  113679. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  113680. * to the ground truth.
  113681. */
  113682. useSphericalHarmonics: boolean;
  113683. private _useSpecularGlossinessInputEnergyConservation;
  113684. /**
  113685. * Defines if the material uses energy conservation, when the specular workflow is active.
  113686. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113687. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113688. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  113689. */
  113690. useSpecularGlossinessInputEnergyConservation: boolean;
  113691. /** @hidden */
  113692. private _internalMarkAllSubMeshesAsMiscDirty;
  113693. /** @hidden */
  113694. _markAllSubMeshesAsMiscDirty(): void;
  113695. /**
  113696. * Instantiate a new istance of clear coat configuration.
  113697. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  113698. */
  113699. constructor(markAllSubMeshesAsMiscDirty: () => void);
  113700. /**
  113701. * Checks to see if a texture is used in the material.
  113702. * @param defines the list of "defines" to update.
  113703. */
  113704. prepareDefines(defines: IMaterialBRDFDefines): void;
  113705. /**
  113706. * Get the current class name of the texture useful for serialization or dynamic coding.
  113707. * @returns "PBRClearCoatConfiguration"
  113708. */
  113709. getClassName(): string;
  113710. /**
  113711. * Makes a duplicate of the current configuration into another one.
  113712. * @param brdfConfiguration define the config where to copy the info
  113713. */
  113714. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  113715. /**
  113716. * Serializes this BRDF configuration.
  113717. * @returns - An object with the serialized config.
  113718. */
  113719. serialize(): any;
  113720. /**
  113721. * Parses a anisotropy Configuration from a serialized object.
  113722. * @param source - Serialized object.
  113723. * @param scene Defines the scene we are parsing for
  113724. * @param rootUrl Defines the rootUrl to load from
  113725. */
  113726. parse(source: any, scene: Scene, rootUrl: string): void;
  113727. }
  113728. }
  113729. declare module BABYLON {
  113730. /**
  113731. * @hidden
  113732. */
  113733. export interface IMaterialSheenDefines {
  113734. SHEEN: boolean;
  113735. SHEEN_TEXTURE: boolean;
  113736. SHEEN_TEXTUREDIRECTUV: number;
  113737. SHEEN_LINKWITHALBEDO: boolean;
  113738. /** @hidden */
  113739. _areTexturesDirty: boolean;
  113740. }
  113741. /**
  113742. * Define the code related to the Sheen parameters of the pbr material.
  113743. */
  113744. export class PBRSheenConfiguration {
  113745. private _isEnabled;
  113746. /**
  113747. * Defines if the material uses sheen.
  113748. */
  113749. isEnabled: boolean;
  113750. private _linkSheenWithAlbedo;
  113751. /**
  113752. * Defines if the sheen is linked to the sheen color.
  113753. */
  113754. linkSheenWithAlbedo: boolean;
  113755. /**
  113756. * Defines the sheen intensity.
  113757. */
  113758. intensity: number;
  113759. /**
  113760. * Defines the sheen color.
  113761. */
  113762. color: Color3;
  113763. private _texture;
  113764. /**
  113765. * Stores the sheen tint values in a texture.
  113766. * rgb is tint
  113767. * a is a intensity
  113768. */
  113769. texture: Nullable<BaseTexture>;
  113770. /** @hidden */
  113771. private _internalMarkAllSubMeshesAsTexturesDirty;
  113772. /** @hidden */
  113773. _markAllSubMeshesAsTexturesDirty(): void;
  113774. /**
  113775. * Instantiate a new istance of clear coat configuration.
  113776. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113777. */
  113778. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113779. /**
  113780. * Specifies that the submesh is ready to be used.
  113781. * @param defines the list of "defines" to update.
  113782. * @param scene defines the scene the material belongs to.
  113783. * @returns - boolean indicating that the submesh is ready or not.
  113784. */
  113785. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  113786. /**
  113787. * Checks to see if a texture is used in the material.
  113788. * @param defines the list of "defines" to update.
  113789. * @param scene defines the scene the material belongs to.
  113790. */
  113791. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  113792. /**
  113793. * Binds the material data.
  113794. * @param uniformBuffer defines the Uniform buffer to fill in.
  113795. * @param scene defines the scene the material belongs to.
  113796. * @param isFrozen defines wether the material is frozen or not.
  113797. */
  113798. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113799. /**
  113800. * Checks to see if a texture is used in the material.
  113801. * @param texture - Base texture to use.
  113802. * @returns - Boolean specifying if a texture is used in the material.
  113803. */
  113804. hasTexture(texture: BaseTexture): boolean;
  113805. /**
  113806. * Returns an array of the actively used textures.
  113807. * @param activeTextures Array of BaseTextures
  113808. */
  113809. getActiveTextures(activeTextures: BaseTexture[]): void;
  113810. /**
  113811. * Returns the animatable textures.
  113812. * @param animatables Array of animatable textures.
  113813. */
  113814. getAnimatables(animatables: IAnimatable[]): void;
  113815. /**
  113816. * Disposes the resources of the material.
  113817. * @param forceDisposeTextures - Forces the disposal of all textures.
  113818. */
  113819. dispose(forceDisposeTextures?: boolean): void;
  113820. /**
  113821. * Get the current class name of the texture useful for serialization or dynamic coding.
  113822. * @returns "PBRSheenConfiguration"
  113823. */
  113824. getClassName(): string;
  113825. /**
  113826. * Add fallbacks to the effect fallbacks list.
  113827. * @param defines defines the Base texture to use.
  113828. * @param fallbacks defines the current fallback list.
  113829. * @param currentRank defines the current fallback rank.
  113830. * @returns the new fallback rank.
  113831. */
  113832. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113833. /**
  113834. * Add the required uniforms to the current list.
  113835. * @param uniforms defines the current uniform list.
  113836. */
  113837. static AddUniforms(uniforms: string[]): void;
  113838. /**
  113839. * Add the required uniforms to the current buffer.
  113840. * @param uniformBuffer defines the current uniform buffer.
  113841. */
  113842. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113843. /**
  113844. * Add the required samplers to the current list.
  113845. * @param samplers defines the current sampler list.
  113846. */
  113847. static AddSamplers(samplers: string[]): void;
  113848. /**
  113849. * Makes a duplicate of the current configuration into another one.
  113850. * @param sheenConfiguration define the config where to copy the info
  113851. */
  113852. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  113853. /**
  113854. * Serializes this BRDF configuration.
  113855. * @returns - An object with the serialized config.
  113856. */
  113857. serialize(): any;
  113858. /**
  113859. * Parses a anisotropy Configuration from a serialized object.
  113860. * @param source - Serialized object.
  113861. * @param scene Defines the scene we are parsing for
  113862. * @param rootUrl Defines the rootUrl to load from
  113863. */
  113864. parse(source: any, scene: Scene, rootUrl: string): void;
  113865. }
  113866. }
  113867. declare module BABYLON {
  113868. /**
  113869. * @hidden
  113870. */
  113871. export interface IMaterialSubSurfaceDefines {
  113872. SUBSURFACE: boolean;
  113873. SS_REFRACTION: boolean;
  113874. SS_TRANSLUCENCY: boolean;
  113875. SS_SCATERRING: boolean;
  113876. SS_THICKNESSANDMASK_TEXTURE: boolean;
  113877. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  113878. SS_REFRACTIONMAP_3D: boolean;
  113879. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  113880. SS_LODINREFRACTIONALPHA: boolean;
  113881. SS_GAMMAREFRACTION: boolean;
  113882. SS_RGBDREFRACTION: boolean;
  113883. SS_LINEARSPECULARREFRACTION: boolean;
  113884. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  113885. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  113886. /** @hidden */
  113887. _areTexturesDirty: boolean;
  113888. }
  113889. /**
  113890. * Define the code related to the sub surface parameters of the pbr material.
  113891. */
  113892. export class PBRSubSurfaceConfiguration {
  113893. private _isRefractionEnabled;
  113894. /**
  113895. * Defines if the refraction is enabled in the material.
  113896. */
  113897. isRefractionEnabled: boolean;
  113898. private _isTranslucencyEnabled;
  113899. /**
  113900. * Defines if the translucency is enabled in the material.
  113901. */
  113902. isTranslucencyEnabled: boolean;
  113903. private _isScatteringEnabled;
  113904. /**
  113905. * Defines the refraction intensity of the material.
  113906. * The refraction when enabled replaces the Diffuse part of the material.
  113907. * The intensity helps transitionning between diffuse and refraction.
  113908. */
  113909. refractionIntensity: number;
  113910. /**
  113911. * Defines the translucency intensity of the material.
  113912. * When translucency has been enabled, this defines how much of the "translucency"
  113913. * is addded to the diffuse part of the material.
  113914. */
  113915. translucencyIntensity: number;
  113916. /**
  113917. * Defines the scattering intensity of the material.
  113918. * When scattering has been enabled, this defines how much of the "scattered light"
  113919. * is addded to the diffuse part of the material.
  113920. */
  113921. scatteringIntensity: number;
  113922. private _thicknessTexture;
  113923. /**
  113924. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  113925. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  113926. * 0 would mean minimumThickness
  113927. * 1 would mean maximumThickness
  113928. * The other channels might be use as a mask to vary the different effects intensity.
  113929. */
  113930. thicknessTexture: Nullable<BaseTexture>;
  113931. private _refractionTexture;
  113932. /**
  113933. * Defines the texture to use for refraction.
  113934. */
  113935. refractionTexture: Nullable<BaseTexture>;
  113936. private _indexOfRefraction;
  113937. /**
  113938. * Defines the index of refraction used in the material.
  113939. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  113940. */
  113941. indexOfRefraction: number;
  113942. private _invertRefractionY;
  113943. /**
  113944. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113945. */
  113946. invertRefractionY: boolean;
  113947. private _linkRefractionWithTransparency;
  113948. /**
  113949. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113950. * Materials half opaque for instance using refraction could benefit from this control.
  113951. */
  113952. linkRefractionWithTransparency: boolean;
  113953. /**
  113954. * Defines the minimum thickness stored in the thickness map.
  113955. * If no thickness map is defined, this value will be used to simulate thickness.
  113956. */
  113957. minimumThickness: number;
  113958. /**
  113959. * Defines the maximum thickness stored in the thickness map.
  113960. */
  113961. maximumThickness: number;
  113962. /**
  113963. * Defines the volume tint of the material.
  113964. * This is used for both translucency and scattering.
  113965. */
  113966. tintColor: Color3;
  113967. /**
  113968. * Defines the distance at which the tint color should be found in the media.
  113969. * This is used for refraction only.
  113970. */
  113971. tintColorAtDistance: number;
  113972. /**
  113973. * Defines how far each channel transmit through the media.
  113974. * It is defined as a color to simplify it selection.
  113975. */
  113976. diffusionDistance: Color3;
  113977. private _useMaskFromThicknessTexture;
  113978. /**
  113979. * Stores the intensity of the different subsurface effects in the thickness texture.
  113980. * * the green channel is the translucency intensity.
  113981. * * the blue channel is the scattering intensity.
  113982. * * the alpha channel is the refraction intensity.
  113983. */
  113984. useMaskFromThicknessTexture: boolean;
  113985. /** @hidden */
  113986. private _internalMarkAllSubMeshesAsTexturesDirty;
  113987. /** @hidden */
  113988. _markAllSubMeshesAsTexturesDirty(): void;
  113989. /**
  113990. * Instantiate a new istance of sub surface configuration.
  113991. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113992. */
  113993. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113994. /**
  113995. * Gets wehter the submesh is ready to be used or not.
  113996. * @param defines the list of "defines" to update.
  113997. * @param scene defines the scene the material belongs to.
  113998. * @returns - boolean indicating that the submesh is ready or not.
  113999. */
  114000. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  114001. /**
  114002. * Checks to see if a texture is used in the material.
  114003. * @param defines the list of "defines" to update.
  114004. * @param scene defines the scene to the material belongs to.
  114005. */
  114006. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  114007. /**
  114008. * Binds the material data.
  114009. * @param uniformBuffer defines the Uniform buffer to fill in.
  114010. * @param scene defines the scene the material belongs to.
  114011. * @param engine defines the engine the material belongs to.
  114012. * @param isFrozen defines wether the material is frozen or not.
  114013. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  114014. */
  114015. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  114016. /**
  114017. * Unbinds the material from the mesh.
  114018. * @param activeEffect defines the effect that should be unbound from.
  114019. * @returns true if unbound, otherwise false
  114020. */
  114021. unbind(activeEffect: Effect): boolean;
  114022. /**
  114023. * Returns the texture used for refraction or null if none is used.
  114024. * @param scene defines the scene the material belongs to.
  114025. * @returns - Refraction texture if present. If no refraction texture and refraction
  114026. * is linked with transparency, returns environment texture. Otherwise, returns null.
  114027. */
  114028. private _getRefractionTexture;
  114029. /**
  114030. * Returns true if alpha blending should be disabled.
  114031. */
  114032. readonly disableAlphaBlending: boolean;
  114033. /**
  114034. * Fills the list of render target textures.
  114035. * @param renderTargets the list of render targets to update
  114036. */
  114037. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  114038. /**
  114039. * Checks to see if a texture is used in the material.
  114040. * @param texture - Base texture to use.
  114041. * @returns - Boolean specifying if a texture is used in the material.
  114042. */
  114043. hasTexture(texture: BaseTexture): boolean;
  114044. /**
  114045. * Gets a boolean indicating that current material needs to register RTT
  114046. * @returns true if this uses a render target otherwise false.
  114047. */
  114048. hasRenderTargetTextures(): boolean;
  114049. /**
  114050. * Returns an array of the actively used textures.
  114051. * @param activeTextures Array of BaseTextures
  114052. */
  114053. getActiveTextures(activeTextures: BaseTexture[]): void;
  114054. /**
  114055. * Returns the animatable textures.
  114056. * @param animatables Array of animatable textures.
  114057. */
  114058. getAnimatables(animatables: IAnimatable[]): void;
  114059. /**
  114060. * Disposes the resources of the material.
  114061. * @param forceDisposeTextures - Forces the disposal of all textures.
  114062. */
  114063. dispose(forceDisposeTextures?: boolean): void;
  114064. /**
  114065. * Get the current class name of the texture useful for serialization or dynamic coding.
  114066. * @returns "PBRSubSurfaceConfiguration"
  114067. */
  114068. getClassName(): string;
  114069. /**
  114070. * Add fallbacks to the effect fallbacks list.
  114071. * @param defines defines the Base texture to use.
  114072. * @param fallbacks defines the current fallback list.
  114073. * @param currentRank defines the current fallback rank.
  114074. * @returns the new fallback rank.
  114075. */
  114076. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114077. /**
  114078. * Add the required uniforms to the current list.
  114079. * @param uniforms defines the current uniform list.
  114080. */
  114081. static AddUniforms(uniforms: string[]): void;
  114082. /**
  114083. * Add the required samplers to the current list.
  114084. * @param samplers defines the current sampler list.
  114085. */
  114086. static AddSamplers(samplers: string[]): void;
  114087. /**
  114088. * Add the required uniforms to the current buffer.
  114089. * @param uniformBuffer defines the current uniform buffer.
  114090. */
  114091. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114092. /**
  114093. * Makes a duplicate of the current configuration into another one.
  114094. * @param configuration define the config where to copy the info
  114095. */
  114096. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  114097. /**
  114098. * Serializes this Sub Surface configuration.
  114099. * @returns - An object with the serialized config.
  114100. */
  114101. serialize(): any;
  114102. /**
  114103. * Parses a anisotropy Configuration from a serialized object.
  114104. * @param source - Serialized object.
  114105. * @param scene Defines the scene we are parsing for
  114106. * @param rootUrl Defines the rootUrl to load from
  114107. */
  114108. parse(source: any, scene: Scene, rootUrl: string): void;
  114109. }
  114110. }
  114111. declare module BABYLON {
  114112. /** @hidden */
  114113. export var pbrFragmentDeclaration: {
  114114. name: string;
  114115. shader: string;
  114116. };
  114117. }
  114118. declare module BABYLON {
  114119. /** @hidden */
  114120. export var pbrUboDeclaration: {
  114121. name: string;
  114122. shader: string;
  114123. };
  114124. }
  114125. declare module BABYLON {
  114126. /** @hidden */
  114127. export var pbrFragmentExtraDeclaration: {
  114128. name: string;
  114129. shader: string;
  114130. };
  114131. }
  114132. declare module BABYLON {
  114133. /** @hidden */
  114134. export var pbrFragmentSamplersDeclaration: {
  114135. name: string;
  114136. shader: string;
  114137. };
  114138. }
  114139. declare module BABYLON {
  114140. /** @hidden */
  114141. export var pbrHelperFunctions: {
  114142. name: string;
  114143. shader: string;
  114144. };
  114145. }
  114146. declare module BABYLON {
  114147. /** @hidden */
  114148. export var harmonicsFunctions: {
  114149. name: string;
  114150. shader: string;
  114151. };
  114152. }
  114153. declare module BABYLON {
  114154. /** @hidden */
  114155. export var pbrDirectLightingSetupFunctions: {
  114156. name: string;
  114157. shader: string;
  114158. };
  114159. }
  114160. declare module BABYLON {
  114161. /** @hidden */
  114162. export var pbrDirectLightingFalloffFunctions: {
  114163. name: string;
  114164. shader: string;
  114165. };
  114166. }
  114167. declare module BABYLON {
  114168. /** @hidden */
  114169. export var pbrBRDFFunctions: {
  114170. name: string;
  114171. shader: string;
  114172. };
  114173. }
  114174. declare module BABYLON {
  114175. /** @hidden */
  114176. export var pbrDirectLightingFunctions: {
  114177. name: string;
  114178. shader: string;
  114179. };
  114180. }
  114181. declare module BABYLON {
  114182. /** @hidden */
  114183. export var pbrIBLFunctions: {
  114184. name: string;
  114185. shader: string;
  114186. };
  114187. }
  114188. declare module BABYLON {
  114189. /** @hidden */
  114190. export var pbrDebug: {
  114191. name: string;
  114192. shader: string;
  114193. };
  114194. }
  114195. declare module BABYLON {
  114196. /** @hidden */
  114197. export var pbrPixelShader: {
  114198. name: string;
  114199. shader: string;
  114200. };
  114201. }
  114202. declare module BABYLON {
  114203. /** @hidden */
  114204. export var pbrVertexDeclaration: {
  114205. name: string;
  114206. shader: string;
  114207. };
  114208. }
  114209. declare module BABYLON {
  114210. /** @hidden */
  114211. export var pbrVertexShader: {
  114212. name: string;
  114213. shader: string;
  114214. };
  114215. }
  114216. declare module BABYLON {
  114217. /**
  114218. * Manages the defines for the PBR Material.
  114219. * @hidden
  114220. */
  114221. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  114222. PBR: boolean;
  114223. MAINUV1: boolean;
  114224. MAINUV2: boolean;
  114225. UV1: boolean;
  114226. UV2: boolean;
  114227. ALBEDO: boolean;
  114228. ALBEDODIRECTUV: number;
  114229. VERTEXCOLOR: boolean;
  114230. AMBIENT: boolean;
  114231. AMBIENTDIRECTUV: number;
  114232. AMBIENTINGRAYSCALE: boolean;
  114233. OPACITY: boolean;
  114234. VERTEXALPHA: boolean;
  114235. OPACITYDIRECTUV: number;
  114236. OPACITYRGB: boolean;
  114237. ALPHATEST: boolean;
  114238. DEPTHPREPASS: boolean;
  114239. ALPHABLEND: boolean;
  114240. ALPHAFROMALBEDO: boolean;
  114241. ALPHATESTVALUE: string;
  114242. SPECULAROVERALPHA: boolean;
  114243. RADIANCEOVERALPHA: boolean;
  114244. ALPHAFRESNEL: boolean;
  114245. LINEARALPHAFRESNEL: boolean;
  114246. PREMULTIPLYALPHA: boolean;
  114247. EMISSIVE: boolean;
  114248. EMISSIVEDIRECTUV: number;
  114249. REFLECTIVITY: boolean;
  114250. REFLECTIVITYDIRECTUV: number;
  114251. SPECULARTERM: boolean;
  114252. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  114253. MICROSURFACEAUTOMATIC: boolean;
  114254. LODBASEDMICROSFURACE: boolean;
  114255. MICROSURFACEMAP: boolean;
  114256. MICROSURFACEMAPDIRECTUV: number;
  114257. METALLICWORKFLOW: boolean;
  114258. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  114259. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  114260. METALLNESSSTOREINMETALMAPBLUE: boolean;
  114261. AOSTOREINMETALMAPRED: boolean;
  114262. ENVIRONMENTBRDF: boolean;
  114263. ENVIRONMENTBRDF_RGBD: boolean;
  114264. NORMAL: boolean;
  114265. TANGENT: boolean;
  114266. BUMP: boolean;
  114267. BUMPDIRECTUV: number;
  114268. OBJECTSPACE_NORMALMAP: boolean;
  114269. PARALLAX: boolean;
  114270. PARALLAXOCCLUSION: boolean;
  114271. NORMALXYSCALE: boolean;
  114272. LIGHTMAP: boolean;
  114273. LIGHTMAPDIRECTUV: number;
  114274. USELIGHTMAPASSHADOWMAP: boolean;
  114275. GAMMALIGHTMAP: boolean;
  114276. RGBDLIGHTMAP: boolean;
  114277. REFLECTION: boolean;
  114278. REFLECTIONMAP_3D: boolean;
  114279. REFLECTIONMAP_SPHERICAL: boolean;
  114280. REFLECTIONMAP_PLANAR: boolean;
  114281. REFLECTIONMAP_CUBIC: boolean;
  114282. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  114283. REFLECTIONMAP_PROJECTION: boolean;
  114284. REFLECTIONMAP_SKYBOX: boolean;
  114285. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  114286. REFLECTIONMAP_EXPLICIT: boolean;
  114287. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  114288. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  114289. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  114290. INVERTCUBICMAP: boolean;
  114291. USESPHERICALFROMREFLECTIONMAP: boolean;
  114292. USEIRRADIANCEMAP: boolean;
  114293. SPHERICAL_HARMONICS: boolean;
  114294. USESPHERICALINVERTEX: boolean;
  114295. REFLECTIONMAP_OPPOSITEZ: boolean;
  114296. LODINREFLECTIONALPHA: boolean;
  114297. GAMMAREFLECTION: boolean;
  114298. RGBDREFLECTION: boolean;
  114299. LINEARSPECULARREFLECTION: boolean;
  114300. RADIANCEOCCLUSION: boolean;
  114301. HORIZONOCCLUSION: boolean;
  114302. INSTANCES: boolean;
  114303. NUM_BONE_INFLUENCERS: number;
  114304. BonesPerMesh: number;
  114305. BONETEXTURE: boolean;
  114306. NONUNIFORMSCALING: boolean;
  114307. MORPHTARGETS: boolean;
  114308. MORPHTARGETS_NORMAL: boolean;
  114309. MORPHTARGETS_TANGENT: boolean;
  114310. MORPHTARGETS_UV: boolean;
  114311. NUM_MORPH_INFLUENCERS: number;
  114312. IMAGEPROCESSING: boolean;
  114313. VIGNETTE: boolean;
  114314. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114315. VIGNETTEBLENDMODEOPAQUE: boolean;
  114316. TONEMAPPING: boolean;
  114317. TONEMAPPING_ACES: boolean;
  114318. CONTRAST: boolean;
  114319. COLORCURVES: boolean;
  114320. COLORGRADING: boolean;
  114321. COLORGRADING3D: boolean;
  114322. SAMPLER3DGREENDEPTH: boolean;
  114323. SAMPLER3DBGRMAP: boolean;
  114324. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114325. EXPOSURE: boolean;
  114326. MULTIVIEW: boolean;
  114327. USEPHYSICALLIGHTFALLOFF: boolean;
  114328. USEGLTFLIGHTFALLOFF: boolean;
  114329. TWOSIDEDLIGHTING: boolean;
  114330. SHADOWFLOAT: boolean;
  114331. CLIPPLANE: boolean;
  114332. CLIPPLANE2: boolean;
  114333. CLIPPLANE3: boolean;
  114334. CLIPPLANE4: boolean;
  114335. POINTSIZE: boolean;
  114336. FOG: boolean;
  114337. LOGARITHMICDEPTH: boolean;
  114338. FORCENORMALFORWARD: boolean;
  114339. SPECULARAA: boolean;
  114340. CLEARCOAT: boolean;
  114341. CLEARCOAT_DEFAULTIOR: boolean;
  114342. CLEARCOAT_TEXTURE: boolean;
  114343. CLEARCOAT_TEXTUREDIRECTUV: number;
  114344. CLEARCOAT_BUMP: boolean;
  114345. CLEARCOAT_BUMPDIRECTUV: number;
  114346. CLEARCOAT_TINT: boolean;
  114347. CLEARCOAT_TINT_TEXTURE: boolean;
  114348. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114349. ANISOTROPIC: boolean;
  114350. ANISOTROPIC_TEXTURE: boolean;
  114351. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114352. BRDF_V_HEIGHT_CORRELATED: boolean;
  114353. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114354. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114355. SHEEN: boolean;
  114356. SHEEN_TEXTURE: boolean;
  114357. SHEEN_TEXTUREDIRECTUV: number;
  114358. SHEEN_LINKWITHALBEDO: boolean;
  114359. SUBSURFACE: boolean;
  114360. SS_REFRACTION: boolean;
  114361. SS_TRANSLUCENCY: boolean;
  114362. SS_SCATERRING: boolean;
  114363. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114364. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114365. SS_REFRACTIONMAP_3D: boolean;
  114366. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114367. SS_LODINREFRACTIONALPHA: boolean;
  114368. SS_GAMMAREFRACTION: boolean;
  114369. SS_RGBDREFRACTION: boolean;
  114370. SS_LINEARSPECULARREFRACTION: boolean;
  114371. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114372. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114373. UNLIT: boolean;
  114374. DEBUGMODE: number;
  114375. /**
  114376. * Initializes the PBR Material defines.
  114377. */
  114378. constructor();
  114379. /**
  114380. * Resets the PBR Material defines.
  114381. */
  114382. reset(): void;
  114383. }
  114384. /**
  114385. * The Physically based material base class of BJS.
  114386. *
  114387. * This offers the main features of a standard PBR material.
  114388. * For more information, please refer to the documentation :
  114389. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114390. */
  114391. export abstract class PBRBaseMaterial extends PushMaterial {
  114392. /**
  114393. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114394. */
  114395. static readonly PBRMATERIAL_OPAQUE: number;
  114396. /**
  114397. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114398. */
  114399. static readonly PBRMATERIAL_ALPHATEST: number;
  114400. /**
  114401. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114402. */
  114403. static readonly PBRMATERIAL_ALPHABLEND: number;
  114404. /**
  114405. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114406. * They are also discarded below the alpha cutoff threshold to improve performances.
  114407. */
  114408. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114409. /**
  114410. * Defines the default value of how much AO map is occluding the analytical lights
  114411. * (point spot...).
  114412. */
  114413. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114414. /**
  114415. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  114416. */
  114417. static readonly LIGHTFALLOFF_PHYSICAL: number;
  114418. /**
  114419. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  114420. * to enhance interoperability with other engines.
  114421. */
  114422. static readonly LIGHTFALLOFF_GLTF: number;
  114423. /**
  114424. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  114425. * to enhance interoperability with other materials.
  114426. */
  114427. static readonly LIGHTFALLOFF_STANDARD: number;
  114428. /**
  114429. * Intensity of the direct lights e.g. the four lights available in your scene.
  114430. * This impacts both the direct diffuse and specular highlights.
  114431. */
  114432. protected _directIntensity: number;
  114433. /**
  114434. * Intensity of the emissive part of the material.
  114435. * This helps controlling the emissive effect without modifying the emissive color.
  114436. */
  114437. protected _emissiveIntensity: number;
  114438. /**
  114439. * Intensity of the environment e.g. how much the environment will light the object
  114440. * either through harmonics for rough material or through the refelction for shiny ones.
  114441. */
  114442. protected _environmentIntensity: number;
  114443. /**
  114444. * This is a special control allowing the reduction of the specular highlights coming from the
  114445. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114446. */
  114447. protected _specularIntensity: number;
  114448. /**
  114449. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  114450. */
  114451. private _lightingInfos;
  114452. /**
  114453. * Debug Control allowing disabling the bump map on this material.
  114454. */
  114455. protected _disableBumpMap: boolean;
  114456. /**
  114457. * AKA Diffuse Texture in standard nomenclature.
  114458. */
  114459. protected _albedoTexture: Nullable<BaseTexture>;
  114460. /**
  114461. * AKA Occlusion Texture in other nomenclature.
  114462. */
  114463. protected _ambientTexture: Nullable<BaseTexture>;
  114464. /**
  114465. * AKA Occlusion Texture Intensity in other nomenclature.
  114466. */
  114467. protected _ambientTextureStrength: number;
  114468. /**
  114469. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114470. * 1 means it completely occludes it
  114471. * 0 mean it has no impact
  114472. */
  114473. protected _ambientTextureImpactOnAnalyticalLights: number;
  114474. /**
  114475. * Stores the alpha values in a texture.
  114476. */
  114477. protected _opacityTexture: Nullable<BaseTexture>;
  114478. /**
  114479. * Stores the reflection values in a texture.
  114480. */
  114481. protected _reflectionTexture: Nullable<BaseTexture>;
  114482. /**
  114483. * Stores the emissive values in a texture.
  114484. */
  114485. protected _emissiveTexture: Nullable<BaseTexture>;
  114486. /**
  114487. * AKA Specular texture in other nomenclature.
  114488. */
  114489. protected _reflectivityTexture: Nullable<BaseTexture>;
  114490. /**
  114491. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114492. */
  114493. protected _metallicTexture: Nullable<BaseTexture>;
  114494. /**
  114495. * Specifies the metallic scalar of the metallic/roughness workflow.
  114496. * Can also be used to scale the metalness values of the metallic texture.
  114497. */
  114498. protected _metallic: Nullable<number>;
  114499. /**
  114500. * Specifies the roughness scalar of the metallic/roughness workflow.
  114501. * Can also be used to scale the roughness values of the metallic texture.
  114502. */
  114503. protected _roughness: Nullable<number>;
  114504. /**
  114505. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114506. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114507. */
  114508. protected _microSurfaceTexture: Nullable<BaseTexture>;
  114509. /**
  114510. * Stores surface normal data used to displace a mesh in a texture.
  114511. */
  114512. protected _bumpTexture: Nullable<BaseTexture>;
  114513. /**
  114514. * Stores the pre-calculated light information of a mesh in a texture.
  114515. */
  114516. protected _lightmapTexture: Nullable<BaseTexture>;
  114517. /**
  114518. * The color of a material in ambient lighting.
  114519. */
  114520. protected _ambientColor: Color3;
  114521. /**
  114522. * AKA Diffuse Color in other nomenclature.
  114523. */
  114524. protected _albedoColor: Color3;
  114525. /**
  114526. * AKA Specular Color in other nomenclature.
  114527. */
  114528. protected _reflectivityColor: Color3;
  114529. /**
  114530. * The color applied when light is reflected from a material.
  114531. */
  114532. protected _reflectionColor: Color3;
  114533. /**
  114534. * The color applied when light is emitted from a material.
  114535. */
  114536. protected _emissiveColor: Color3;
  114537. /**
  114538. * AKA Glossiness in other nomenclature.
  114539. */
  114540. protected _microSurface: number;
  114541. /**
  114542. * Specifies that the material will use the light map as a show map.
  114543. */
  114544. protected _useLightmapAsShadowmap: boolean;
  114545. /**
  114546. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114547. * makes the reflect vector face the model (under horizon).
  114548. */
  114549. protected _useHorizonOcclusion: boolean;
  114550. /**
  114551. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114552. * too much the area relying on ambient texture to define their ambient occlusion.
  114553. */
  114554. protected _useRadianceOcclusion: boolean;
  114555. /**
  114556. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114557. */
  114558. protected _useAlphaFromAlbedoTexture: boolean;
  114559. /**
  114560. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  114561. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114562. */
  114563. protected _useSpecularOverAlpha: boolean;
  114564. /**
  114565. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114566. */
  114567. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114568. /**
  114569. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114570. */
  114571. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  114572. /**
  114573. * Specifies if the metallic texture contains the roughness information in its green channel.
  114574. */
  114575. protected _useRoughnessFromMetallicTextureGreen: boolean;
  114576. /**
  114577. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114578. */
  114579. protected _useMetallnessFromMetallicTextureBlue: boolean;
  114580. /**
  114581. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114582. */
  114583. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  114584. /**
  114585. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114586. */
  114587. protected _useAmbientInGrayScale: boolean;
  114588. /**
  114589. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114590. * The material will try to infer what glossiness each pixel should be.
  114591. */
  114592. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  114593. /**
  114594. * Defines the falloff type used in this material.
  114595. * It by default is Physical.
  114596. */
  114597. protected _lightFalloff: number;
  114598. /**
  114599. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114600. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114601. */
  114602. protected _useRadianceOverAlpha: boolean;
  114603. /**
  114604. * Allows using an object space normal map (instead of tangent space).
  114605. */
  114606. protected _useObjectSpaceNormalMap: boolean;
  114607. /**
  114608. * Allows using the bump map in parallax mode.
  114609. */
  114610. protected _useParallax: boolean;
  114611. /**
  114612. * Allows using the bump map in parallax occlusion mode.
  114613. */
  114614. protected _useParallaxOcclusion: boolean;
  114615. /**
  114616. * Controls the scale bias of the parallax mode.
  114617. */
  114618. protected _parallaxScaleBias: number;
  114619. /**
  114620. * If sets to true, disables all the lights affecting the material.
  114621. */
  114622. protected _disableLighting: boolean;
  114623. /**
  114624. * Number of Simultaneous lights allowed on the material.
  114625. */
  114626. protected _maxSimultaneousLights: number;
  114627. /**
  114628. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114629. */
  114630. protected _invertNormalMapX: boolean;
  114631. /**
  114632. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114633. */
  114634. protected _invertNormalMapY: boolean;
  114635. /**
  114636. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114637. */
  114638. protected _twoSidedLighting: boolean;
  114639. /**
  114640. * Defines the alpha limits in alpha test mode.
  114641. */
  114642. protected _alphaCutOff: number;
  114643. /**
  114644. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114645. */
  114646. protected _forceAlphaTest: boolean;
  114647. /**
  114648. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114649. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114650. */
  114651. protected _useAlphaFresnel: boolean;
  114652. /**
  114653. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114654. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114655. */
  114656. protected _useLinearAlphaFresnel: boolean;
  114657. /**
  114658. * The transparency mode of the material.
  114659. */
  114660. protected _transparencyMode: Nullable<number>;
  114661. /**
  114662. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  114663. * from cos thetav and roughness:
  114664. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  114665. */
  114666. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  114667. /**
  114668. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114669. */
  114670. protected _forceIrradianceInFragment: boolean;
  114671. /**
  114672. * Force normal to face away from face.
  114673. */
  114674. protected _forceNormalForward: boolean;
  114675. /**
  114676. * Enables specular anti aliasing in the PBR shader.
  114677. * It will both interacts on the Geometry for analytical and IBL lighting.
  114678. * It also prefilter the roughness map based on the bump values.
  114679. */
  114680. protected _enableSpecularAntiAliasing: boolean;
  114681. /**
  114682. * Default configuration related to image processing available in the PBR Material.
  114683. */
  114684. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114685. /**
  114686. * Keep track of the image processing observer to allow dispose and replace.
  114687. */
  114688. private _imageProcessingObserver;
  114689. /**
  114690. * Attaches a new image processing configuration to the PBR Material.
  114691. * @param configuration
  114692. */
  114693. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114694. /**
  114695. * Stores the available render targets.
  114696. */
  114697. private _renderTargets;
  114698. /**
  114699. * Sets the global ambient color for the material used in lighting calculations.
  114700. */
  114701. private _globalAmbientColor;
  114702. /**
  114703. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  114704. */
  114705. private _useLogarithmicDepth;
  114706. /**
  114707. * If set to true, no lighting calculations will be applied.
  114708. */
  114709. private _unlit;
  114710. private _debugMode;
  114711. /**
  114712. * @hidden
  114713. * This is reserved for the inspector.
  114714. * Defines the material debug mode.
  114715. * It helps seeing only some components of the material while troubleshooting.
  114716. */
  114717. debugMode: number;
  114718. /**
  114719. * @hidden
  114720. * This is reserved for the inspector.
  114721. * Specify from where on screen the debug mode should start.
  114722. * The value goes from -1 (full screen) to 1 (not visible)
  114723. * It helps with side by side comparison against the final render
  114724. * This defaults to -1
  114725. */
  114726. private debugLimit;
  114727. /**
  114728. * @hidden
  114729. * This is reserved for the inspector.
  114730. * As the default viewing range might not be enough (if the ambient is really small for instance)
  114731. * You can use the factor to better multiply the final value.
  114732. */
  114733. private debugFactor;
  114734. /**
  114735. * Defines the clear coat layer parameters for the material.
  114736. */
  114737. readonly clearCoat: PBRClearCoatConfiguration;
  114738. /**
  114739. * Defines the anisotropic parameters for the material.
  114740. */
  114741. readonly anisotropy: PBRAnisotropicConfiguration;
  114742. /**
  114743. * Defines the BRDF parameters for the material.
  114744. */
  114745. readonly brdf: PBRBRDFConfiguration;
  114746. /**
  114747. * Defines the Sheen parameters for the material.
  114748. */
  114749. readonly sheen: PBRSheenConfiguration;
  114750. /**
  114751. * Defines the SubSurface parameters for the material.
  114752. */
  114753. readonly subSurface: PBRSubSurfaceConfiguration;
  114754. /**
  114755. * Custom callback helping to override the default shader used in the material.
  114756. */
  114757. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  114758. protected _rebuildInParallel: boolean;
  114759. /**
  114760. * Instantiates a new PBRMaterial instance.
  114761. *
  114762. * @param name The material name
  114763. * @param scene The scene the material will be use in.
  114764. */
  114765. constructor(name: string, scene: Scene);
  114766. /**
  114767. * Gets a boolean indicating that current material needs to register RTT
  114768. */
  114769. readonly hasRenderTargetTextures: boolean;
  114770. /**
  114771. * Gets the name of the material class.
  114772. */
  114773. getClassName(): string;
  114774. /**
  114775. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114776. */
  114777. /**
  114778. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114779. */
  114780. useLogarithmicDepth: boolean;
  114781. /**
  114782. * Gets the current transparency mode.
  114783. */
  114784. /**
  114785. * Sets the transparency mode of the material.
  114786. *
  114787. * | Value | Type | Description |
  114788. * | ----- | ----------------------------------- | ----------- |
  114789. * | 0 | OPAQUE | |
  114790. * | 1 | ALPHATEST | |
  114791. * | 2 | ALPHABLEND | |
  114792. * | 3 | ALPHATESTANDBLEND | |
  114793. *
  114794. */
  114795. transparencyMode: Nullable<number>;
  114796. /**
  114797. * Returns true if alpha blending should be disabled.
  114798. */
  114799. private readonly _disableAlphaBlending;
  114800. /**
  114801. * Specifies whether or not this material should be rendered in alpha blend mode.
  114802. */
  114803. needAlphaBlending(): boolean;
  114804. /**
  114805. * Specifies if the mesh will require alpha blending.
  114806. * @param mesh - BJS mesh.
  114807. */
  114808. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  114809. /**
  114810. * Specifies whether or not this material should be rendered in alpha test mode.
  114811. */
  114812. needAlphaTesting(): boolean;
  114813. /**
  114814. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  114815. */
  114816. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  114817. /**
  114818. * Gets the texture used for the alpha test.
  114819. */
  114820. getAlphaTestTexture(): Nullable<BaseTexture>;
  114821. /**
  114822. * Specifies that the submesh is ready to be used.
  114823. * @param mesh - BJS mesh.
  114824. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  114825. * @param useInstances - Specifies that instances should be used.
  114826. * @returns - boolean indicating that the submesh is ready or not.
  114827. */
  114828. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114829. /**
  114830. * Specifies if the material uses metallic roughness workflow.
  114831. * @returns boolean specifiying if the material uses metallic roughness workflow.
  114832. */
  114833. isMetallicWorkflow(): boolean;
  114834. private _prepareEffect;
  114835. private _prepareDefines;
  114836. /**
  114837. * Force shader compilation
  114838. */
  114839. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  114840. clipPlane: boolean;
  114841. }>): void;
  114842. /**
  114843. * Initializes the uniform buffer layout for the shader.
  114844. */
  114845. buildUniformLayout(): void;
  114846. /**
  114847. * Unbinds the material from the mesh
  114848. */
  114849. unbind(): void;
  114850. /**
  114851. * Binds the submesh data.
  114852. * @param world - The world matrix.
  114853. * @param mesh - The BJS mesh.
  114854. * @param subMesh - A submesh of the BJS mesh.
  114855. */
  114856. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114857. /**
  114858. * Returns the animatable textures.
  114859. * @returns - Array of animatable textures.
  114860. */
  114861. getAnimatables(): IAnimatable[];
  114862. /**
  114863. * Returns the texture used for reflections.
  114864. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  114865. */
  114866. private _getReflectionTexture;
  114867. /**
  114868. * Returns an array of the actively used textures.
  114869. * @returns - Array of BaseTextures
  114870. */
  114871. getActiveTextures(): BaseTexture[];
  114872. /**
  114873. * Checks to see if a texture is used in the material.
  114874. * @param texture - Base texture to use.
  114875. * @returns - Boolean specifying if a texture is used in the material.
  114876. */
  114877. hasTexture(texture: BaseTexture): boolean;
  114878. /**
  114879. * Disposes the resources of the material.
  114880. * @param forceDisposeEffect - Forces the disposal of effects.
  114881. * @param forceDisposeTextures - Forces the disposal of all textures.
  114882. */
  114883. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114884. }
  114885. }
  114886. declare module BABYLON {
  114887. /**
  114888. * The Physically based material of BJS.
  114889. *
  114890. * This offers the main features of a standard PBR material.
  114891. * For more information, please refer to the documentation :
  114892. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114893. */
  114894. export class PBRMaterial extends PBRBaseMaterial {
  114895. /**
  114896. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114897. */
  114898. static readonly PBRMATERIAL_OPAQUE: number;
  114899. /**
  114900. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114901. */
  114902. static readonly PBRMATERIAL_ALPHATEST: number;
  114903. /**
  114904. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114905. */
  114906. static readonly PBRMATERIAL_ALPHABLEND: number;
  114907. /**
  114908. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114909. * They are also discarded below the alpha cutoff threshold to improve performances.
  114910. */
  114911. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114912. /**
  114913. * Defines the default value of how much AO map is occluding the analytical lights
  114914. * (point spot...).
  114915. */
  114916. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114917. /**
  114918. * Intensity of the direct lights e.g. the four lights available in your scene.
  114919. * This impacts both the direct diffuse and specular highlights.
  114920. */
  114921. directIntensity: number;
  114922. /**
  114923. * Intensity of the emissive part of the material.
  114924. * This helps controlling the emissive effect without modifying the emissive color.
  114925. */
  114926. emissiveIntensity: number;
  114927. /**
  114928. * Intensity of the environment e.g. how much the environment will light the object
  114929. * either through harmonics for rough material or through the refelction for shiny ones.
  114930. */
  114931. environmentIntensity: number;
  114932. /**
  114933. * This is a special control allowing the reduction of the specular highlights coming from the
  114934. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114935. */
  114936. specularIntensity: number;
  114937. /**
  114938. * Debug Control allowing disabling the bump map on this material.
  114939. */
  114940. disableBumpMap: boolean;
  114941. /**
  114942. * AKA Diffuse Texture in standard nomenclature.
  114943. */
  114944. albedoTexture: BaseTexture;
  114945. /**
  114946. * AKA Occlusion Texture in other nomenclature.
  114947. */
  114948. ambientTexture: BaseTexture;
  114949. /**
  114950. * AKA Occlusion Texture Intensity in other nomenclature.
  114951. */
  114952. ambientTextureStrength: number;
  114953. /**
  114954. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114955. * 1 means it completely occludes it
  114956. * 0 mean it has no impact
  114957. */
  114958. ambientTextureImpactOnAnalyticalLights: number;
  114959. /**
  114960. * Stores the alpha values in a texture.
  114961. */
  114962. opacityTexture: BaseTexture;
  114963. /**
  114964. * Stores the reflection values in a texture.
  114965. */
  114966. reflectionTexture: Nullable<BaseTexture>;
  114967. /**
  114968. * Stores the emissive values in a texture.
  114969. */
  114970. emissiveTexture: BaseTexture;
  114971. /**
  114972. * AKA Specular texture in other nomenclature.
  114973. */
  114974. reflectivityTexture: BaseTexture;
  114975. /**
  114976. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114977. */
  114978. metallicTexture: BaseTexture;
  114979. /**
  114980. * Specifies the metallic scalar of the metallic/roughness workflow.
  114981. * Can also be used to scale the metalness values of the metallic texture.
  114982. */
  114983. metallic: Nullable<number>;
  114984. /**
  114985. * Specifies the roughness scalar of the metallic/roughness workflow.
  114986. * Can also be used to scale the roughness values of the metallic texture.
  114987. */
  114988. roughness: Nullable<number>;
  114989. /**
  114990. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114991. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114992. */
  114993. microSurfaceTexture: BaseTexture;
  114994. /**
  114995. * Stores surface normal data used to displace a mesh in a texture.
  114996. */
  114997. bumpTexture: BaseTexture;
  114998. /**
  114999. * Stores the pre-calculated light information of a mesh in a texture.
  115000. */
  115001. lightmapTexture: BaseTexture;
  115002. /**
  115003. * Stores the refracted light information in a texture.
  115004. */
  115005. refractionTexture: Nullable<BaseTexture>;
  115006. /**
  115007. * The color of a material in ambient lighting.
  115008. */
  115009. ambientColor: Color3;
  115010. /**
  115011. * AKA Diffuse Color in other nomenclature.
  115012. */
  115013. albedoColor: Color3;
  115014. /**
  115015. * AKA Specular Color in other nomenclature.
  115016. */
  115017. reflectivityColor: Color3;
  115018. /**
  115019. * The color reflected from the material.
  115020. */
  115021. reflectionColor: Color3;
  115022. /**
  115023. * The color emitted from the material.
  115024. */
  115025. emissiveColor: Color3;
  115026. /**
  115027. * AKA Glossiness in other nomenclature.
  115028. */
  115029. microSurface: number;
  115030. /**
  115031. * source material index of refraction (IOR)' / 'destination material IOR.
  115032. */
  115033. indexOfRefraction: number;
  115034. /**
  115035. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115036. */
  115037. invertRefractionY: boolean;
  115038. /**
  115039. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115040. * Materials half opaque for instance using refraction could benefit from this control.
  115041. */
  115042. linkRefractionWithTransparency: boolean;
  115043. /**
  115044. * If true, the light map contains occlusion information instead of lighting info.
  115045. */
  115046. useLightmapAsShadowmap: boolean;
  115047. /**
  115048. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115049. */
  115050. useAlphaFromAlbedoTexture: boolean;
  115051. /**
  115052. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115053. */
  115054. forceAlphaTest: boolean;
  115055. /**
  115056. * Defines the alpha limits in alpha test mode.
  115057. */
  115058. alphaCutOff: number;
  115059. /**
  115060. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  115061. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115062. */
  115063. useSpecularOverAlpha: boolean;
  115064. /**
  115065. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115066. */
  115067. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115068. /**
  115069. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115070. */
  115071. useRoughnessFromMetallicTextureAlpha: boolean;
  115072. /**
  115073. * Specifies if the metallic texture contains the roughness information in its green channel.
  115074. */
  115075. useRoughnessFromMetallicTextureGreen: boolean;
  115076. /**
  115077. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115078. */
  115079. useMetallnessFromMetallicTextureBlue: boolean;
  115080. /**
  115081. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115082. */
  115083. useAmbientOcclusionFromMetallicTextureRed: boolean;
  115084. /**
  115085. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115086. */
  115087. useAmbientInGrayScale: boolean;
  115088. /**
  115089. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115090. * The material will try to infer what glossiness each pixel should be.
  115091. */
  115092. useAutoMicroSurfaceFromReflectivityMap: boolean;
  115093. /**
  115094. * BJS is using an harcoded light falloff based on a manually sets up range.
  115095. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115096. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115097. */
  115098. /**
  115099. * BJS is using an harcoded light falloff based on a manually sets up range.
  115100. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115101. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115102. */
  115103. usePhysicalLightFalloff: boolean;
  115104. /**
  115105. * In order to support the falloff compatibility with gltf, a special mode has been added
  115106. * to reproduce the gltf light falloff.
  115107. */
  115108. /**
  115109. * In order to support the falloff compatibility with gltf, a special mode has been added
  115110. * to reproduce the gltf light falloff.
  115111. */
  115112. useGLTFLightFalloff: boolean;
  115113. /**
  115114. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115115. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115116. */
  115117. useRadianceOverAlpha: boolean;
  115118. /**
  115119. * Allows using an object space normal map (instead of tangent space).
  115120. */
  115121. useObjectSpaceNormalMap: boolean;
  115122. /**
  115123. * Allows using the bump map in parallax mode.
  115124. */
  115125. useParallax: boolean;
  115126. /**
  115127. * Allows using the bump map in parallax occlusion mode.
  115128. */
  115129. useParallaxOcclusion: boolean;
  115130. /**
  115131. * Controls the scale bias of the parallax mode.
  115132. */
  115133. parallaxScaleBias: number;
  115134. /**
  115135. * If sets to true, disables all the lights affecting the material.
  115136. */
  115137. disableLighting: boolean;
  115138. /**
  115139. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115140. */
  115141. forceIrradianceInFragment: boolean;
  115142. /**
  115143. * Number of Simultaneous lights allowed on the material.
  115144. */
  115145. maxSimultaneousLights: number;
  115146. /**
  115147. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115148. */
  115149. invertNormalMapX: boolean;
  115150. /**
  115151. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115152. */
  115153. invertNormalMapY: boolean;
  115154. /**
  115155. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115156. */
  115157. twoSidedLighting: boolean;
  115158. /**
  115159. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115160. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115161. */
  115162. useAlphaFresnel: boolean;
  115163. /**
  115164. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115165. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115166. */
  115167. useLinearAlphaFresnel: boolean;
  115168. /**
  115169. * Let user defines the brdf lookup texture used for IBL.
  115170. * A default 8bit version is embedded but you could point at :
  115171. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  115172. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115173. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  115174. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115175. */
  115176. environmentBRDFTexture: Nullable<BaseTexture>;
  115177. /**
  115178. * Force normal to face away from face.
  115179. */
  115180. forceNormalForward: boolean;
  115181. /**
  115182. * Enables specular anti aliasing in the PBR shader.
  115183. * It will both interacts on the Geometry for analytical and IBL lighting.
  115184. * It also prefilter the roughness map based on the bump values.
  115185. */
  115186. enableSpecularAntiAliasing: boolean;
  115187. /**
  115188. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115189. * makes the reflect vector face the model (under horizon).
  115190. */
  115191. useHorizonOcclusion: boolean;
  115192. /**
  115193. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115194. * too much the area relying on ambient texture to define their ambient occlusion.
  115195. */
  115196. useRadianceOcclusion: boolean;
  115197. /**
  115198. * If set to true, no lighting calculations will be applied.
  115199. */
  115200. unlit: boolean;
  115201. /**
  115202. * Gets the image processing configuration used either in this material.
  115203. */
  115204. /**
  115205. * Sets the Default image processing configuration used either in the this material.
  115206. *
  115207. * If sets to null, the scene one is in use.
  115208. */
  115209. imageProcessingConfiguration: ImageProcessingConfiguration;
  115210. /**
  115211. * Gets wether the color curves effect is enabled.
  115212. */
  115213. /**
  115214. * Sets wether the color curves effect is enabled.
  115215. */
  115216. cameraColorCurvesEnabled: boolean;
  115217. /**
  115218. * Gets wether the color grading effect is enabled.
  115219. */
  115220. /**
  115221. * Gets wether the color grading effect is enabled.
  115222. */
  115223. cameraColorGradingEnabled: boolean;
  115224. /**
  115225. * Gets wether tonemapping is enabled or not.
  115226. */
  115227. /**
  115228. * Sets wether tonemapping is enabled or not
  115229. */
  115230. cameraToneMappingEnabled: boolean;
  115231. /**
  115232. * The camera exposure used on this material.
  115233. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115234. * This corresponds to a photographic exposure.
  115235. */
  115236. /**
  115237. * The camera exposure used on this material.
  115238. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115239. * This corresponds to a photographic exposure.
  115240. */
  115241. cameraExposure: number;
  115242. /**
  115243. * Gets The camera contrast used on this material.
  115244. */
  115245. /**
  115246. * Sets The camera contrast used on this material.
  115247. */
  115248. cameraContrast: number;
  115249. /**
  115250. * Gets the Color Grading 2D Lookup Texture.
  115251. */
  115252. /**
  115253. * Sets the Color Grading 2D Lookup Texture.
  115254. */
  115255. cameraColorGradingTexture: Nullable<BaseTexture>;
  115256. /**
  115257. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115258. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115259. * 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;
  115260. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115261. */
  115262. /**
  115263. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115264. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115265. * 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;
  115266. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115267. */
  115268. cameraColorCurves: Nullable<ColorCurves>;
  115269. /**
  115270. * Instantiates a new PBRMaterial instance.
  115271. *
  115272. * @param name The material name
  115273. * @param scene The scene the material will be use in.
  115274. */
  115275. constructor(name: string, scene: Scene);
  115276. /**
  115277. * Returns the name of this material class.
  115278. */
  115279. getClassName(): string;
  115280. /**
  115281. * Makes a duplicate of the current material.
  115282. * @param name - name to use for the new material.
  115283. */
  115284. clone(name: string): PBRMaterial;
  115285. /**
  115286. * Serializes this PBR Material.
  115287. * @returns - An object with the serialized material.
  115288. */
  115289. serialize(): any;
  115290. /**
  115291. * Parses a PBR Material from a serialized object.
  115292. * @param source - Serialized object.
  115293. * @param scene - BJS scene instance.
  115294. * @param rootUrl - url for the scene object
  115295. * @returns - PBRMaterial
  115296. */
  115297. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  115298. }
  115299. }
  115300. declare module BABYLON {
  115301. /**
  115302. * Direct draw surface info
  115303. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  115304. */
  115305. export interface DDSInfo {
  115306. /**
  115307. * Width of the texture
  115308. */
  115309. width: number;
  115310. /**
  115311. * Width of the texture
  115312. */
  115313. height: number;
  115314. /**
  115315. * Number of Mipmaps for the texture
  115316. * @see https://en.wikipedia.org/wiki/Mipmap
  115317. */
  115318. mipmapCount: number;
  115319. /**
  115320. * If the textures format is a known fourCC format
  115321. * @see https://www.fourcc.org/
  115322. */
  115323. isFourCC: boolean;
  115324. /**
  115325. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  115326. */
  115327. isRGB: boolean;
  115328. /**
  115329. * If the texture is a lumincance format
  115330. */
  115331. isLuminance: boolean;
  115332. /**
  115333. * If this is a cube texture
  115334. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  115335. */
  115336. isCube: boolean;
  115337. /**
  115338. * If the texture is a compressed format eg. FOURCC_DXT1
  115339. */
  115340. isCompressed: boolean;
  115341. /**
  115342. * The dxgiFormat of the texture
  115343. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  115344. */
  115345. dxgiFormat: number;
  115346. /**
  115347. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  115348. */
  115349. textureType: number;
  115350. /**
  115351. * Sphericle polynomial created for the dds texture
  115352. */
  115353. sphericalPolynomial?: SphericalPolynomial;
  115354. }
  115355. /**
  115356. * Class used to provide DDS decompression tools
  115357. */
  115358. export class DDSTools {
  115359. /**
  115360. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  115361. */
  115362. static StoreLODInAlphaChannel: boolean;
  115363. /**
  115364. * Gets DDS information from an array buffer
  115365. * @param arrayBuffer defines the array buffer to read data from
  115366. * @returns the DDS information
  115367. */
  115368. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  115369. private static _FloatView;
  115370. private static _Int32View;
  115371. private static _ToHalfFloat;
  115372. private static _FromHalfFloat;
  115373. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  115374. private static _GetHalfFloatRGBAArrayBuffer;
  115375. private static _GetFloatRGBAArrayBuffer;
  115376. private static _GetFloatAsUIntRGBAArrayBuffer;
  115377. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  115378. private static _GetRGBAArrayBuffer;
  115379. private static _ExtractLongWordOrder;
  115380. private static _GetRGBArrayBuffer;
  115381. private static _GetLuminanceArrayBuffer;
  115382. /**
  115383. * Uploads DDS Levels to a Babylon Texture
  115384. * @hidden
  115385. */
  115386. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  115387. }
  115388. interface ThinEngine {
  115389. /**
  115390. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  115391. * @param rootUrl defines the url where the file to load is located
  115392. * @param scene defines the current scene
  115393. * @param lodScale defines scale to apply to the mip map selection
  115394. * @param lodOffset defines offset to apply to the mip map selection
  115395. * @param onLoad defines an optional callback raised when the texture is loaded
  115396. * @param onError defines an optional callback raised if there is an issue to load the texture
  115397. * @param format defines the format of the data
  115398. * @param forcedExtension defines the extension to use to pick the right loader
  115399. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  115400. * @returns the cube texture as an InternalTexture
  115401. */
  115402. 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;
  115403. }
  115404. }
  115405. declare module BABYLON {
  115406. /**
  115407. * Implementation of the DDS Texture Loader.
  115408. * @hidden
  115409. */
  115410. export class _DDSTextureLoader implements IInternalTextureLoader {
  115411. /**
  115412. * Defines wether the loader supports cascade loading the different faces.
  115413. */
  115414. readonly supportCascades: boolean;
  115415. /**
  115416. * This returns if the loader support the current file information.
  115417. * @param extension defines the file extension of the file being loaded
  115418. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115419. * @param fallback defines the fallback internal texture if any
  115420. * @param isBase64 defines whether the texture is encoded as a base64
  115421. * @param isBuffer defines whether the texture data are stored as a buffer
  115422. * @returns true if the loader can load the specified file
  115423. */
  115424. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115425. /**
  115426. * Transform the url before loading if required.
  115427. * @param rootUrl the url of the texture
  115428. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115429. * @returns the transformed texture
  115430. */
  115431. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115432. /**
  115433. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115434. * @param rootUrl the url of the texture
  115435. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115436. * @returns the fallback texture
  115437. */
  115438. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115439. /**
  115440. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115441. * @param data contains the texture data
  115442. * @param texture defines the BabylonJS internal texture
  115443. * @param createPolynomials will be true if polynomials have been requested
  115444. * @param onLoad defines the callback to trigger once the texture is ready
  115445. * @param onError defines the callback to trigger in case of error
  115446. */
  115447. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115448. /**
  115449. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115450. * @param data contains the texture data
  115451. * @param texture defines the BabylonJS internal texture
  115452. * @param callback defines the method to call once ready to upload
  115453. */
  115454. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115455. }
  115456. }
  115457. declare module BABYLON {
  115458. /**
  115459. * Implementation of the ENV Texture Loader.
  115460. * @hidden
  115461. */
  115462. export class _ENVTextureLoader implements IInternalTextureLoader {
  115463. /**
  115464. * Defines wether the loader supports cascade loading the different faces.
  115465. */
  115466. readonly supportCascades: boolean;
  115467. /**
  115468. * This returns if the loader support the current file information.
  115469. * @param extension defines the file extension of the file being loaded
  115470. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115471. * @param fallback defines the fallback internal texture if any
  115472. * @param isBase64 defines whether the texture is encoded as a base64
  115473. * @param isBuffer defines whether the texture data are stored as a buffer
  115474. * @returns true if the loader can load the specified file
  115475. */
  115476. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115477. /**
  115478. * Transform the url before loading if required.
  115479. * @param rootUrl the url of the texture
  115480. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115481. * @returns the transformed texture
  115482. */
  115483. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115484. /**
  115485. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115486. * @param rootUrl the url of the texture
  115487. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115488. * @returns the fallback texture
  115489. */
  115490. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115491. /**
  115492. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115493. * @param data contains the texture data
  115494. * @param texture defines the BabylonJS internal texture
  115495. * @param createPolynomials will be true if polynomials have been requested
  115496. * @param onLoad defines the callback to trigger once the texture is ready
  115497. * @param onError defines the callback to trigger in case of error
  115498. */
  115499. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115500. /**
  115501. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115502. * @param data contains the texture data
  115503. * @param texture defines the BabylonJS internal texture
  115504. * @param callback defines the method to call once ready to upload
  115505. */
  115506. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115507. }
  115508. }
  115509. declare module BABYLON {
  115510. /**
  115511. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  115512. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  115513. */
  115514. export class KhronosTextureContainer {
  115515. /** contents of the KTX container file */
  115516. arrayBuffer: any;
  115517. private static HEADER_LEN;
  115518. private static COMPRESSED_2D;
  115519. private static COMPRESSED_3D;
  115520. private static TEX_2D;
  115521. private static TEX_3D;
  115522. /**
  115523. * Gets the openGL type
  115524. */
  115525. glType: number;
  115526. /**
  115527. * Gets the openGL type size
  115528. */
  115529. glTypeSize: number;
  115530. /**
  115531. * Gets the openGL format
  115532. */
  115533. glFormat: number;
  115534. /**
  115535. * Gets the openGL internal format
  115536. */
  115537. glInternalFormat: number;
  115538. /**
  115539. * Gets the base internal format
  115540. */
  115541. glBaseInternalFormat: number;
  115542. /**
  115543. * Gets image width in pixel
  115544. */
  115545. pixelWidth: number;
  115546. /**
  115547. * Gets image height in pixel
  115548. */
  115549. pixelHeight: number;
  115550. /**
  115551. * Gets image depth in pixels
  115552. */
  115553. pixelDepth: number;
  115554. /**
  115555. * Gets the number of array elements
  115556. */
  115557. numberOfArrayElements: number;
  115558. /**
  115559. * Gets the number of faces
  115560. */
  115561. numberOfFaces: number;
  115562. /**
  115563. * Gets the number of mipmap levels
  115564. */
  115565. numberOfMipmapLevels: number;
  115566. /**
  115567. * Gets the bytes of key value data
  115568. */
  115569. bytesOfKeyValueData: number;
  115570. /**
  115571. * Gets the load type
  115572. */
  115573. loadType: number;
  115574. /**
  115575. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  115576. */
  115577. isInvalid: boolean;
  115578. /**
  115579. * Creates a new KhronosTextureContainer
  115580. * @param arrayBuffer contents of the KTX container file
  115581. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  115582. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  115583. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  115584. */
  115585. constructor(
  115586. /** contents of the KTX container file */
  115587. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  115588. /**
  115589. * Uploads KTX content to a Babylon Texture.
  115590. * It is assumed that the texture has already been created & is currently bound
  115591. * @hidden
  115592. */
  115593. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  115594. private _upload2DCompressedLevels;
  115595. }
  115596. }
  115597. declare module BABYLON {
  115598. /**
  115599. * Implementation of the KTX Texture Loader.
  115600. * @hidden
  115601. */
  115602. export class _KTXTextureLoader implements IInternalTextureLoader {
  115603. /**
  115604. * Defines wether the loader supports cascade loading the different faces.
  115605. */
  115606. readonly supportCascades: boolean;
  115607. /**
  115608. * This returns if the loader support the current file information.
  115609. * @param extension defines the file extension of the file being loaded
  115610. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115611. * @param fallback defines the fallback internal texture if any
  115612. * @param isBase64 defines whether the texture is encoded as a base64
  115613. * @param isBuffer defines whether the texture data are stored as a buffer
  115614. * @returns true if the loader can load the specified file
  115615. */
  115616. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115617. /**
  115618. * Transform the url before loading if required.
  115619. * @param rootUrl the url of the texture
  115620. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115621. * @returns the transformed texture
  115622. */
  115623. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115624. /**
  115625. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115626. * @param rootUrl the url of the texture
  115627. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115628. * @returns the fallback texture
  115629. */
  115630. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115631. /**
  115632. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115633. * @param data contains the texture data
  115634. * @param texture defines the BabylonJS internal texture
  115635. * @param createPolynomials will be true if polynomials have been requested
  115636. * @param onLoad defines the callback to trigger once the texture is ready
  115637. * @param onError defines the callback to trigger in case of error
  115638. */
  115639. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115640. /**
  115641. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115642. * @param data contains the texture data
  115643. * @param texture defines the BabylonJS internal texture
  115644. * @param callback defines the method to call once ready to upload
  115645. */
  115646. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  115647. }
  115648. }
  115649. declare module BABYLON {
  115650. /**
  115651. * Options for the default xr helper
  115652. */
  115653. export class WebXRDefaultExperienceOptions {
  115654. /**
  115655. * Floor meshes that should be used for teleporting
  115656. */
  115657. floorMeshes: Array<AbstractMesh>;
  115658. }
  115659. /**
  115660. * Default experience which provides a similar setup to the previous webVRExperience
  115661. */
  115662. export class WebXRDefaultExperience {
  115663. /**
  115664. * Base experience
  115665. */
  115666. baseExperience: WebXRExperienceHelper;
  115667. /**
  115668. * Input experience extension
  115669. */
  115670. input: WebXRInput;
  115671. /**
  115672. * Loads the controller models
  115673. */
  115674. controllerModelLoader: WebXRControllerModelLoader;
  115675. /**
  115676. * Enables laser pointer and selection
  115677. */
  115678. pointerSelection: WebXRControllerPointerSelection;
  115679. /**
  115680. * Enables teleportation
  115681. */
  115682. teleportation: WebXRControllerTeleportation;
  115683. /**
  115684. * Enables ui for enetering/exiting xr
  115685. */
  115686. enterExitUI: WebXREnterExitUI;
  115687. /**
  115688. * Default output canvas xr should render to
  115689. */
  115690. outputCanvas: WebXRManagedOutputCanvas;
  115691. /**
  115692. * Creates the default xr experience
  115693. * @param scene scene
  115694. * @param options options for basic configuration
  115695. * @returns resulting WebXRDefaultExperience
  115696. */
  115697. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115698. private constructor();
  115699. /**
  115700. * DIsposes of the experience helper
  115701. */
  115702. dispose(): void;
  115703. }
  115704. }
  115705. declare module BABYLON {
  115706. /** @hidden */
  115707. export var _forceSceneHelpersToBundle: boolean;
  115708. interface Scene {
  115709. /**
  115710. * Creates a default light for the scene.
  115711. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  115712. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  115713. */
  115714. createDefaultLight(replace?: boolean): void;
  115715. /**
  115716. * Creates a default camera for the scene.
  115717. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  115718. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115719. * @param replace has default false, when true replaces the active camera in the scene
  115720. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  115721. */
  115722. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115723. /**
  115724. * Creates a default camera and a default light.
  115725. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  115726. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115727. * @param replace has the default false, when true replaces the active camera/light in the scene
  115728. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  115729. */
  115730. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115731. /**
  115732. * Creates a new sky box
  115733. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  115734. * @param environmentTexture defines the texture to use as environment texture
  115735. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  115736. * @param scale defines the overall scale of the skybox
  115737. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  115738. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  115739. * @returns a new mesh holding the sky box
  115740. */
  115741. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  115742. /**
  115743. * Creates a new environment
  115744. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  115745. * @param options defines the options you can use to configure the environment
  115746. * @returns the new EnvironmentHelper
  115747. */
  115748. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  115749. /**
  115750. * Creates a new VREXperienceHelper
  115751. * @see http://doc.babylonjs.com/how_to/webvr_helper
  115752. * @param webVROptions defines the options used to create the new VREXperienceHelper
  115753. * @returns a new VREXperienceHelper
  115754. */
  115755. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  115756. /**
  115757. * Creates a new WebXRDefaultExperience
  115758. * @see http://doc.babylonjs.com/how_to/webxr
  115759. * @param options experience options
  115760. * @returns a promise for a new WebXRDefaultExperience
  115761. */
  115762. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115763. }
  115764. }
  115765. declare module BABYLON {
  115766. /**
  115767. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  115768. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  115769. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  115770. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115771. */
  115772. export class VideoDome extends TransformNode {
  115773. /**
  115774. * Define the video source as a Monoscopic panoramic 360 video.
  115775. */
  115776. static readonly MODE_MONOSCOPIC: number;
  115777. /**
  115778. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115779. */
  115780. static readonly MODE_TOPBOTTOM: number;
  115781. /**
  115782. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115783. */
  115784. static readonly MODE_SIDEBYSIDE: number;
  115785. private _halfDome;
  115786. private _useDirectMapping;
  115787. /**
  115788. * The video texture being displayed on the sphere
  115789. */
  115790. protected _videoTexture: VideoTexture;
  115791. /**
  115792. * Gets the video texture being displayed on the sphere
  115793. */
  115794. readonly videoTexture: VideoTexture;
  115795. /**
  115796. * The skybox material
  115797. */
  115798. protected _material: BackgroundMaterial;
  115799. /**
  115800. * The surface used for the skybox
  115801. */
  115802. protected _mesh: Mesh;
  115803. /**
  115804. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  115805. */
  115806. private _halfDomeMask;
  115807. /**
  115808. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115809. * Also see the options.resolution property.
  115810. */
  115811. fovMultiplier: number;
  115812. private _videoMode;
  115813. /**
  115814. * Gets or set the current video mode for the video. It can be:
  115815. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  115816. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115817. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115818. */
  115819. videoMode: number;
  115820. /**
  115821. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  115822. *
  115823. */
  115824. /**
  115825. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  115826. */
  115827. halfDome: boolean;
  115828. /**
  115829. * Oberserver used in Stereoscopic VR Mode.
  115830. */
  115831. private _onBeforeCameraRenderObserver;
  115832. /**
  115833. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  115834. * @param name Element's name, child elements will append suffixes for their own names.
  115835. * @param urlsOrVideo defines the url(s) or the video element to use
  115836. * @param options An object containing optional or exposed sub element properties
  115837. */
  115838. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  115839. resolution?: number;
  115840. clickToPlay?: boolean;
  115841. autoPlay?: boolean;
  115842. loop?: boolean;
  115843. size?: number;
  115844. poster?: string;
  115845. faceForward?: boolean;
  115846. useDirectMapping?: boolean;
  115847. halfDomeMode?: boolean;
  115848. }, scene: Scene);
  115849. private _changeVideoMode;
  115850. /**
  115851. * Releases resources associated with this node.
  115852. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115853. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115854. */
  115855. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115856. }
  115857. }
  115858. declare module BABYLON {
  115859. /**
  115860. * This class can be used to get instrumentation data from a Babylon engine
  115861. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115862. */
  115863. export class EngineInstrumentation implements IDisposable {
  115864. /**
  115865. * Define the instrumented engine.
  115866. */
  115867. engine: Engine;
  115868. private _captureGPUFrameTime;
  115869. private _gpuFrameTimeToken;
  115870. private _gpuFrameTime;
  115871. private _captureShaderCompilationTime;
  115872. private _shaderCompilationTime;
  115873. private _onBeginFrameObserver;
  115874. private _onEndFrameObserver;
  115875. private _onBeforeShaderCompilationObserver;
  115876. private _onAfterShaderCompilationObserver;
  115877. /**
  115878. * Gets the perf counter used for GPU frame time
  115879. */
  115880. readonly gpuFrameTimeCounter: PerfCounter;
  115881. /**
  115882. * Gets the GPU frame time capture status
  115883. */
  115884. /**
  115885. * Enable or disable the GPU frame time capture
  115886. */
  115887. captureGPUFrameTime: boolean;
  115888. /**
  115889. * Gets the perf counter used for shader compilation time
  115890. */
  115891. readonly shaderCompilationTimeCounter: PerfCounter;
  115892. /**
  115893. * Gets the shader compilation time capture status
  115894. */
  115895. /**
  115896. * Enable or disable the shader compilation time capture
  115897. */
  115898. captureShaderCompilationTime: boolean;
  115899. /**
  115900. * Instantiates a new engine instrumentation.
  115901. * This class can be used to get instrumentation data from a Babylon engine
  115902. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115903. * @param engine Defines the engine to instrument
  115904. */
  115905. constructor(
  115906. /**
  115907. * Define the instrumented engine.
  115908. */
  115909. engine: Engine);
  115910. /**
  115911. * Dispose and release associated resources.
  115912. */
  115913. dispose(): void;
  115914. }
  115915. }
  115916. declare module BABYLON {
  115917. /**
  115918. * This class can be used to get instrumentation data from a Babylon engine
  115919. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115920. */
  115921. export class SceneInstrumentation implements IDisposable {
  115922. /**
  115923. * Defines the scene to instrument
  115924. */
  115925. scene: Scene;
  115926. private _captureActiveMeshesEvaluationTime;
  115927. private _activeMeshesEvaluationTime;
  115928. private _captureRenderTargetsRenderTime;
  115929. private _renderTargetsRenderTime;
  115930. private _captureFrameTime;
  115931. private _frameTime;
  115932. private _captureRenderTime;
  115933. private _renderTime;
  115934. private _captureInterFrameTime;
  115935. private _interFrameTime;
  115936. private _captureParticlesRenderTime;
  115937. private _particlesRenderTime;
  115938. private _captureSpritesRenderTime;
  115939. private _spritesRenderTime;
  115940. private _capturePhysicsTime;
  115941. private _physicsTime;
  115942. private _captureAnimationsTime;
  115943. private _animationsTime;
  115944. private _captureCameraRenderTime;
  115945. private _cameraRenderTime;
  115946. private _onBeforeActiveMeshesEvaluationObserver;
  115947. private _onAfterActiveMeshesEvaluationObserver;
  115948. private _onBeforeRenderTargetsRenderObserver;
  115949. private _onAfterRenderTargetsRenderObserver;
  115950. private _onAfterRenderObserver;
  115951. private _onBeforeDrawPhaseObserver;
  115952. private _onAfterDrawPhaseObserver;
  115953. private _onBeforeAnimationsObserver;
  115954. private _onBeforeParticlesRenderingObserver;
  115955. private _onAfterParticlesRenderingObserver;
  115956. private _onBeforeSpritesRenderingObserver;
  115957. private _onAfterSpritesRenderingObserver;
  115958. private _onBeforePhysicsObserver;
  115959. private _onAfterPhysicsObserver;
  115960. private _onAfterAnimationsObserver;
  115961. private _onBeforeCameraRenderObserver;
  115962. private _onAfterCameraRenderObserver;
  115963. /**
  115964. * Gets the perf counter used for active meshes evaluation time
  115965. */
  115966. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  115967. /**
  115968. * Gets the active meshes evaluation time capture status
  115969. */
  115970. /**
  115971. * Enable or disable the active meshes evaluation time capture
  115972. */
  115973. captureActiveMeshesEvaluationTime: boolean;
  115974. /**
  115975. * Gets the perf counter used for render targets render time
  115976. */
  115977. readonly renderTargetsRenderTimeCounter: PerfCounter;
  115978. /**
  115979. * Gets the render targets render time capture status
  115980. */
  115981. /**
  115982. * Enable or disable the render targets render time capture
  115983. */
  115984. captureRenderTargetsRenderTime: boolean;
  115985. /**
  115986. * Gets the perf counter used for particles render time
  115987. */
  115988. readonly particlesRenderTimeCounter: PerfCounter;
  115989. /**
  115990. * Gets the particles render time capture status
  115991. */
  115992. /**
  115993. * Enable or disable the particles render time capture
  115994. */
  115995. captureParticlesRenderTime: boolean;
  115996. /**
  115997. * Gets the perf counter used for sprites render time
  115998. */
  115999. readonly spritesRenderTimeCounter: PerfCounter;
  116000. /**
  116001. * Gets the sprites render time capture status
  116002. */
  116003. /**
  116004. * Enable or disable the sprites render time capture
  116005. */
  116006. captureSpritesRenderTime: boolean;
  116007. /**
  116008. * Gets the perf counter used for physics time
  116009. */
  116010. readonly physicsTimeCounter: PerfCounter;
  116011. /**
  116012. * Gets the physics time capture status
  116013. */
  116014. /**
  116015. * Enable or disable the physics time capture
  116016. */
  116017. capturePhysicsTime: boolean;
  116018. /**
  116019. * Gets the perf counter used for animations time
  116020. */
  116021. readonly animationsTimeCounter: PerfCounter;
  116022. /**
  116023. * Gets the animations time capture status
  116024. */
  116025. /**
  116026. * Enable or disable the animations time capture
  116027. */
  116028. captureAnimationsTime: boolean;
  116029. /**
  116030. * Gets the perf counter used for frame time capture
  116031. */
  116032. readonly frameTimeCounter: PerfCounter;
  116033. /**
  116034. * Gets the frame time capture status
  116035. */
  116036. /**
  116037. * Enable or disable the frame time capture
  116038. */
  116039. captureFrameTime: boolean;
  116040. /**
  116041. * Gets the perf counter used for inter-frames time capture
  116042. */
  116043. readonly interFrameTimeCounter: PerfCounter;
  116044. /**
  116045. * Gets the inter-frames time capture status
  116046. */
  116047. /**
  116048. * Enable or disable the inter-frames time capture
  116049. */
  116050. captureInterFrameTime: boolean;
  116051. /**
  116052. * Gets the perf counter used for render time capture
  116053. */
  116054. readonly renderTimeCounter: PerfCounter;
  116055. /**
  116056. * Gets the render time capture status
  116057. */
  116058. /**
  116059. * Enable or disable the render time capture
  116060. */
  116061. captureRenderTime: boolean;
  116062. /**
  116063. * Gets the perf counter used for camera render time capture
  116064. */
  116065. readonly cameraRenderTimeCounter: PerfCounter;
  116066. /**
  116067. * Gets the camera render time capture status
  116068. */
  116069. /**
  116070. * Enable or disable the camera render time capture
  116071. */
  116072. captureCameraRenderTime: boolean;
  116073. /**
  116074. * Gets the perf counter used for draw calls
  116075. */
  116076. readonly drawCallsCounter: PerfCounter;
  116077. /**
  116078. * Instantiates a new scene instrumentation.
  116079. * This class can be used to get instrumentation data from a Babylon engine
  116080. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116081. * @param scene Defines the scene to instrument
  116082. */
  116083. constructor(
  116084. /**
  116085. * Defines the scene to instrument
  116086. */
  116087. scene: Scene);
  116088. /**
  116089. * Dispose and release associated resources.
  116090. */
  116091. dispose(): void;
  116092. }
  116093. }
  116094. declare module BABYLON {
  116095. /** @hidden */
  116096. export var glowMapGenerationPixelShader: {
  116097. name: string;
  116098. shader: string;
  116099. };
  116100. }
  116101. declare module BABYLON {
  116102. /** @hidden */
  116103. export var glowMapGenerationVertexShader: {
  116104. name: string;
  116105. shader: string;
  116106. };
  116107. }
  116108. declare module BABYLON {
  116109. /**
  116110. * Effect layer options. This helps customizing the behaviour
  116111. * of the effect layer.
  116112. */
  116113. export interface IEffectLayerOptions {
  116114. /**
  116115. * Multiplication factor apply to the canvas size to compute the render target size
  116116. * used to generated the objects (the smaller the faster).
  116117. */
  116118. mainTextureRatio: number;
  116119. /**
  116120. * Enforces a fixed size texture to ensure effect stability across devices.
  116121. */
  116122. mainTextureFixedSize?: number;
  116123. /**
  116124. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  116125. */
  116126. alphaBlendingMode: number;
  116127. /**
  116128. * The camera attached to the layer.
  116129. */
  116130. camera: Nullable<Camera>;
  116131. /**
  116132. * The rendering group to draw the layer in.
  116133. */
  116134. renderingGroupId: number;
  116135. }
  116136. /**
  116137. * The effect layer Helps adding post process effect blended with the main pass.
  116138. *
  116139. * This can be for instance use to generate glow or higlight effects on the scene.
  116140. *
  116141. * The effect layer class can not be used directly and is intented to inherited from to be
  116142. * customized per effects.
  116143. */
  116144. export abstract class EffectLayer {
  116145. private _vertexBuffers;
  116146. private _indexBuffer;
  116147. private _cachedDefines;
  116148. private _effectLayerMapGenerationEffect;
  116149. private _effectLayerOptions;
  116150. private _mergeEffect;
  116151. protected _scene: Scene;
  116152. protected _engine: Engine;
  116153. protected _maxSize: number;
  116154. protected _mainTextureDesiredSize: ISize;
  116155. protected _mainTexture: RenderTargetTexture;
  116156. protected _shouldRender: boolean;
  116157. protected _postProcesses: PostProcess[];
  116158. protected _textures: BaseTexture[];
  116159. protected _emissiveTextureAndColor: {
  116160. texture: Nullable<BaseTexture>;
  116161. color: Color4;
  116162. };
  116163. /**
  116164. * The name of the layer
  116165. */
  116166. name: string;
  116167. /**
  116168. * The clear color of the texture used to generate the glow map.
  116169. */
  116170. neutralColor: Color4;
  116171. /**
  116172. * Specifies wether the highlight layer is enabled or not.
  116173. */
  116174. isEnabled: boolean;
  116175. /**
  116176. * Gets the camera attached to the layer.
  116177. */
  116178. readonly camera: Nullable<Camera>;
  116179. /**
  116180. * Gets the rendering group id the layer should render in.
  116181. */
  116182. renderingGroupId: number;
  116183. /**
  116184. * An event triggered when the effect layer has been disposed.
  116185. */
  116186. onDisposeObservable: Observable<EffectLayer>;
  116187. /**
  116188. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  116189. */
  116190. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  116191. /**
  116192. * An event triggered when the generated texture is being merged in the scene.
  116193. */
  116194. onBeforeComposeObservable: Observable<EffectLayer>;
  116195. /**
  116196. * An event triggered when the generated texture has been merged in the scene.
  116197. */
  116198. onAfterComposeObservable: Observable<EffectLayer>;
  116199. /**
  116200. * An event triggered when the efffect layer changes its size.
  116201. */
  116202. onSizeChangedObservable: Observable<EffectLayer>;
  116203. /** @hidden */
  116204. static _SceneComponentInitialization: (scene: Scene) => void;
  116205. /**
  116206. * Instantiates a new effect Layer and references it in the scene.
  116207. * @param name The name of the layer
  116208. * @param scene The scene to use the layer in
  116209. */
  116210. constructor(
  116211. /** The Friendly of the effect in the scene */
  116212. name: string, scene: Scene);
  116213. /**
  116214. * Get the effect name of the layer.
  116215. * @return The effect name
  116216. */
  116217. abstract getEffectName(): string;
  116218. /**
  116219. * Checks for the readiness of the element composing the layer.
  116220. * @param subMesh the mesh to check for
  116221. * @param useInstances specify wether or not to use instances to render the mesh
  116222. * @return true if ready otherwise, false
  116223. */
  116224. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116225. /**
  116226. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116227. * @returns true if the effect requires stencil during the main canvas render pass.
  116228. */
  116229. abstract needStencil(): boolean;
  116230. /**
  116231. * Create the merge effect. This is the shader use to blit the information back
  116232. * to the main canvas at the end of the scene rendering.
  116233. * @returns The effect containing the shader used to merge the effect on the main canvas
  116234. */
  116235. protected abstract _createMergeEffect(): Effect;
  116236. /**
  116237. * Creates the render target textures and post processes used in the effect layer.
  116238. */
  116239. protected abstract _createTextureAndPostProcesses(): void;
  116240. /**
  116241. * Implementation specific of rendering the generating effect on the main canvas.
  116242. * @param effect The effect used to render through
  116243. */
  116244. protected abstract _internalRender(effect: Effect): void;
  116245. /**
  116246. * Sets the required values for both the emissive texture and and the main color.
  116247. */
  116248. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116249. /**
  116250. * Free any resources and references associated to a mesh.
  116251. * Internal use
  116252. * @param mesh The mesh to free.
  116253. */
  116254. abstract _disposeMesh(mesh: Mesh): void;
  116255. /**
  116256. * Serializes this layer (Glow or Highlight for example)
  116257. * @returns a serialized layer object
  116258. */
  116259. abstract serialize?(): any;
  116260. /**
  116261. * Initializes the effect layer with the required options.
  116262. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  116263. */
  116264. protected _init(options: Partial<IEffectLayerOptions>): void;
  116265. /**
  116266. * Generates the index buffer of the full screen quad blending to the main canvas.
  116267. */
  116268. private _generateIndexBuffer;
  116269. /**
  116270. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  116271. */
  116272. private _generateVertexBuffer;
  116273. /**
  116274. * Sets the main texture desired size which is the closest power of two
  116275. * of the engine canvas size.
  116276. */
  116277. private _setMainTextureSize;
  116278. /**
  116279. * Creates the main texture for the effect layer.
  116280. */
  116281. protected _createMainTexture(): void;
  116282. /**
  116283. * Adds specific effects defines.
  116284. * @param defines The defines to add specifics to.
  116285. */
  116286. protected _addCustomEffectDefines(defines: string[]): void;
  116287. /**
  116288. * Checks for the readiness of the element composing the layer.
  116289. * @param subMesh the mesh to check for
  116290. * @param useInstances specify wether or not to use instances to render the mesh
  116291. * @param emissiveTexture the associated emissive texture used to generate the glow
  116292. * @return true if ready otherwise, false
  116293. */
  116294. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  116295. /**
  116296. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  116297. */
  116298. render(): void;
  116299. /**
  116300. * Determine if a given mesh will be used in the current effect.
  116301. * @param mesh mesh to test
  116302. * @returns true if the mesh will be used
  116303. */
  116304. hasMesh(mesh: AbstractMesh): boolean;
  116305. /**
  116306. * Returns true if the layer contains information to display, otherwise false.
  116307. * @returns true if the glow layer should be rendered
  116308. */
  116309. shouldRender(): boolean;
  116310. /**
  116311. * Returns true if the mesh should render, otherwise false.
  116312. * @param mesh The mesh to render
  116313. * @returns true if it should render otherwise false
  116314. */
  116315. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  116316. /**
  116317. * Returns true if the mesh can be rendered, otherwise false.
  116318. * @param mesh The mesh to render
  116319. * @param material The material used on the mesh
  116320. * @returns true if it can be rendered otherwise false
  116321. */
  116322. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116323. /**
  116324. * Returns true if the mesh should render, otherwise false.
  116325. * @param mesh The mesh to render
  116326. * @returns true if it should render otherwise false
  116327. */
  116328. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  116329. /**
  116330. * Renders the submesh passed in parameter to the generation map.
  116331. */
  116332. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  116333. /**
  116334. * Rebuild the required buffers.
  116335. * @hidden Internal use only.
  116336. */
  116337. _rebuild(): void;
  116338. /**
  116339. * Dispose only the render target textures and post process.
  116340. */
  116341. private _disposeTextureAndPostProcesses;
  116342. /**
  116343. * Dispose the highlight layer and free resources.
  116344. */
  116345. dispose(): void;
  116346. /**
  116347. * Gets the class name of the effect layer
  116348. * @returns the string with the class name of the effect layer
  116349. */
  116350. getClassName(): string;
  116351. /**
  116352. * Creates an effect layer from parsed effect layer data
  116353. * @param parsedEffectLayer defines effect layer data
  116354. * @param scene defines the current scene
  116355. * @param rootUrl defines the root URL containing the effect layer information
  116356. * @returns a parsed effect Layer
  116357. */
  116358. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  116359. }
  116360. }
  116361. declare module BABYLON {
  116362. interface AbstractScene {
  116363. /**
  116364. * The list of effect layers (highlights/glow) added to the scene
  116365. * @see http://doc.babylonjs.com/how_to/highlight_layer
  116366. * @see http://doc.babylonjs.com/how_to/glow_layer
  116367. */
  116368. effectLayers: Array<EffectLayer>;
  116369. /**
  116370. * Removes the given effect layer from this scene.
  116371. * @param toRemove defines the effect layer to remove
  116372. * @returns the index of the removed effect layer
  116373. */
  116374. removeEffectLayer(toRemove: EffectLayer): number;
  116375. /**
  116376. * Adds the given effect layer to this scene
  116377. * @param newEffectLayer defines the effect layer to add
  116378. */
  116379. addEffectLayer(newEffectLayer: EffectLayer): void;
  116380. }
  116381. /**
  116382. * Defines the layer scene component responsible to manage any effect layers
  116383. * in a given scene.
  116384. */
  116385. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  116386. /**
  116387. * The component name helpfull to identify the component in the list of scene components.
  116388. */
  116389. readonly name: string;
  116390. /**
  116391. * The scene the component belongs to.
  116392. */
  116393. scene: Scene;
  116394. private _engine;
  116395. private _renderEffects;
  116396. private _needStencil;
  116397. private _previousStencilState;
  116398. /**
  116399. * Creates a new instance of the component for the given scene
  116400. * @param scene Defines the scene to register the component in
  116401. */
  116402. constructor(scene: Scene);
  116403. /**
  116404. * Registers the component in a given scene
  116405. */
  116406. register(): void;
  116407. /**
  116408. * Rebuilds the elements related to this component in case of
  116409. * context lost for instance.
  116410. */
  116411. rebuild(): void;
  116412. /**
  116413. * Serializes the component data to the specified json object
  116414. * @param serializationObject The object to serialize to
  116415. */
  116416. serialize(serializationObject: any): void;
  116417. /**
  116418. * Adds all the elements from the container to the scene
  116419. * @param container the container holding the elements
  116420. */
  116421. addFromContainer(container: AbstractScene): void;
  116422. /**
  116423. * Removes all the elements in the container from the scene
  116424. * @param container contains the elements to remove
  116425. * @param dispose if the removed element should be disposed (default: false)
  116426. */
  116427. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116428. /**
  116429. * Disposes the component and the associated ressources.
  116430. */
  116431. dispose(): void;
  116432. private _isReadyForMesh;
  116433. private _renderMainTexture;
  116434. private _setStencil;
  116435. private _setStencilBack;
  116436. private _draw;
  116437. private _drawCamera;
  116438. private _drawRenderingGroup;
  116439. }
  116440. }
  116441. declare module BABYLON {
  116442. /** @hidden */
  116443. export var glowMapMergePixelShader: {
  116444. name: string;
  116445. shader: string;
  116446. };
  116447. }
  116448. declare module BABYLON {
  116449. /** @hidden */
  116450. export var glowMapMergeVertexShader: {
  116451. name: string;
  116452. shader: string;
  116453. };
  116454. }
  116455. declare module BABYLON {
  116456. interface AbstractScene {
  116457. /**
  116458. * Return a the first highlight layer of the scene with a given name.
  116459. * @param name The name of the highlight layer to look for.
  116460. * @return The highlight layer if found otherwise null.
  116461. */
  116462. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  116463. }
  116464. /**
  116465. * Glow layer options. This helps customizing the behaviour
  116466. * of the glow layer.
  116467. */
  116468. export interface IGlowLayerOptions {
  116469. /**
  116470. * Multiplication factor apply to the canvas size to compute the render target size
  116471. * used to generated the glowing objects (the smaller the faster).
  116472. */
  116473. mainTextureRatio: number;
  116474. /**
  116475. * Enforces a fixed size texture to ensure resize independant blur.
  116476. */
  116477. mainTextureFixedSize?: number;
  116478. /**
  116479. * How big is the kernel of the blur texture.
  116480. */
  116481. blurKernelSize: number;
  116482. /**
  116483. * The camera attached to the layer.
  116484. */
  116485. camera: Nullable<Camera>;
  116486. /**
  116487. * Enable MSAA by chosing the number of samples.
  116488. */
  116489. mainTextureSamples?: number;
  116490. /**
  116491. * The rendering group to draw the layer in.
  116492. */
  116493. renderingGroupId: number;
  116494. }
  116495. /**
  116496. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  116497. *
  116498. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116499. * glowy meshes to your scene.
  116500. *
  116501. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  116502. */
  116503. export class GlowLayer extends EffectLayer {
  116504. /**
  116505. * Effect Name of the layer.
  116506. */
  116507. static readonly EffectName: string;
  116508. /**
  116509. * The default blur kernel size used for the glow.
  116510. */
  116511. static DefaultBlurKernelSize: number;
  116512. /**
  116513. * The default texture size ratio used for the glow.
  116514. */
  116515. static DefaultTextureRatio: number;
  116516. /**
  116517. * Sets the kernel size of the blur.
  116518. */
  116519. /**
  116520. * Gets the kernel size of the blur.
  116521. */
  116522. blurKernelSize: number;
  116523. /**
  116524. * Sets the glow intensity.
  116525. */
  116526. /**
  116527. * Gets the glow intensity.
  116528. */
  116529. intensity: number;
  116530. private _options;
  116531. private _intensity;
  116532. private _horizontalBlurPostprocess1;
  116533. private _verticalBlurPostprocess1;
  116534. private _horizontalBlurPostprocess2;
  116535. private _verticalBlurPostprocess2;
  116536. private _blurTexture1;
  116537. private _blurTexture2;
  116538. private _postProcesses1;
  116539. private _postProcesses2;
  116540. private _includedOnlyMeshes;
  116541. private _excludedMeshes;
  116542. /**
  116543. * Callback used to let the user override the color selection on a per mesh basis
  116544. */
  116545. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  116546. /**
  116547. * Callback used to let the user override the texture selection on a per mesh basis
  116548. */
  116549. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  116550. /**
  116551. * Instantiates a new glow Layer and references it to the scene.
  116552. * @param name The name of the layer
  116553. * @param scene The scene to use the layer in
  116554. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  116555. */
  116556. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  116557. /**
  116558. * Get the effect name of the layer.
  116559. * @return The effect name
  116560. */
  116561. getEffectName(): string;
  116562. /**
  116563. * Create the merge effect. This is the shader use to blit the information back
  116564. * to the main canvas at the end of the scene rendering.
  116565. */
  116566. protected _createMergeEffect(): Effect;
  116567. /**
  116568. * Creates the render target textures and post processes used in the glow layer.
  116569. */
  116570. protected _createTextureAndPostProcesses(): void;
  116571. /**
  116572. * Checks for the readiness of the element composing the layer.
  116573. * @param subMesh the mesh to check for
  116574. * @param useInstances specify wether or not to use instances to render the mesh
  116575. * @param emissiveTexture the associated emissive texture used to generate the glow
  116576. * @return true if ready otherwise, false
  116577. */
  116578. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116579. /**
  116580. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116581. */
  116582. needStencil(): boolean;
  116583. /**
  116584. * Returns true if the mesh can be rendered, otherwise false.
  116585. * @param mesh The mesh to render
  116586. * @param material The material used on the mesh
  116587. * @returns true if it can be rendered otherwise false
  116588. */
  116589. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116590. /**
  116591. * Implementation specific of rendering the generating effect on the main canvas.
  116592. * @param effect The effect used to render through
  116593. */
  116594. protected _internalRender(effect: Effect): void;
  116595. /**
  116596. * Sets the required values for both the emissive texture and and the main color.
  116597. */
  116598. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116599. /**
  116600. * Returns true if the mesh should render, otherwise false.
  116601. * @param mesh The mesh to render
  116602. * @returns true if it should render otherwise false
  116603. */
  116604. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116605. /**
  116606. * Adds specific effects defines.
  116607. * @param defines The defines to add specifics to.
  116608. */
  116609. protected _addCustomEffectDefines(defines: string[]): void;
  116610. /**
  116611. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  116612. * @param mesh The mesh to exclude from the glow layer
  116613. */
  116614. addExcludedMesh(mesh: Mesh): void;
  116615. /**
  116616. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  116617. * @param mesh The mesh to remove
  116618. */
  116619. removeExcludedMesh(mesh: Mesh): void;
  116620. /**
  116621. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  116622. * @param mesh The mesh to include in the glow layer
  116623. */
  116624. addIncludedOnlyMesh(mesh: Mesh): void;
  116625. /**
  116626. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  116627. * @param mesh The mesh to remove
  116628. */
  116629. removeIncludedOnlyMesh(mesh: Mesh): void;
  116630. /**
  116631. * Determine if a given mesh will be used in the glow layer
  116632. * @param mesh The mesh to test
  116633. * @returns true if the mesh will be highlighted by the current glow layer
  116634. */
  116635. hasMesh(mesh: AbstractMesh): boolean;
  116636. /**
  116637. * Free any resources and references associated to a mesh.
  116638. * Internal use
  116639. * @param mesh The mesh to free.
  116640. * @hidden
  116641. */
  116642. _disposeMesh(mesh: Mesh): void;
  116643. /**
  116644. * Gets the class name of the effect layer
  116645. * @returns the string with the class name of the effect layer
  116646. */
  116647. getClassName(): string;
  116648. /**
  116649. * Serializes this glow layer
  116650. * @returns a serialized glow layer object
  116651. */
  116652. serialize(): any;
  116653. /**
  116654. * Creates a Glow Layer from parsed glow layer data
  116655. * @param parsedGlowLayer defines glow layer data
  116656. * @param scene defines the current scene
  116657. * @param rootUrl defines the root URL containing the glow layer information
  116658. * @returns a parsed Glow Layer
  116659. */
  116660. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  116661. }
  116662. }
  116663. declare module BABYLON {
  116664. /** @hidden */
  116665. export var glowBlurPostProcessPixelShader: {
  116666. name: string;
  116667. shader: string;
  116668. };
  116669. }
  116670. declare module BABYLON {
  116671. interface AbstractScene {
  116672. /**
  116673. * Return a the first highlight layer of the scene with a given name.
  116674. * @param name The name of the highlight layer to look for.
  116675. * @return The highlight layer if found otherwise null.
  116676. */
  116677. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  116678. }
  116679. /**
  116680. * Highlight layer options. This helps customizing the behaviour
  116681. * of the highlight layer.
  116682. */
  116683. export interface IHighlightLayerOptions {
  116684. /**
  116685. * Multiplication factor apply to the canvas size to compute the render target size
  116686. * used to generated the glowing objects (the smaller the faster).
  116687. */
  116688. mainTextureRatio: number;
  116689. /**
  116690. * Enforces a fixed size texture to ensure resize independant blur.
  116691. */
  116692. mainTextureFixedSize?: number;
  116693. /**
  116694. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  116695. * of the picture to blur (the smaller the faster).
  116696. */
  116697. blurTextureSizeRatio: number;
  116698. /**
  116699. * How big in texel of the blur texture is the vertical blur.
  116700. */
  116701. blurVerticalSize: number;
  116702. /**
  116703. * How big in texel of the blur texture is the horizontal blur.
  116704. */
  116705. blurHorizontalSize: number;
  116706. /**
  116707. * Alpha blending mode used to apply the blur. Default is combine.
  116708. */
  116709. alphaBlendingMode: number;
  116710. /**
  116711. * The camera attached to the layer.
  116712. */
  116713. camera: Nullable<Camera>;
  116714. /**
  116715. * Should we display highlight as a solid stroke?
  116716. */
  116717. isStroke?: boolean;
  116718. /**
  116719. * The rendering group to draw the layer in.
  116720. */
  116721. renderingGroupId: number;
  116722. }
  116723. /**
  116724. * The highlight layer Helps adding a glow effect around a mesh.
  116725. *
  116726. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116727. * glowy meshes to your scene.
  116728. *
  116729. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  116730. */
  116731. export class HighlightLayer extends EffectLayer {
  116732. name: string;
  116733. /**
  116734. * Effect Name of the highlight layer.
  116735. */
  116736. static readonly EffectName: string;
  116737. /**
  116738. * The neutral color used during the preparation of the glow effect.
  116739. * This is black by default as the blend operation is a blend operation.
  116740. */
  116741. static NeutralColor: Color4;
  116742. /**
  116743. * Stencil value used for glowing meshes.
  116744. */
  116745. static GlowingMeshStencilReference: number;
  116746. /**
  116747. * Stencil value used for the other meshes in the scene.
  116748. */
  116749. static NormalMeshStencilReference: number;
  116750. /**
  116751. * Specifies whether or not the inner glow is ACTIVE in the layer.
  116752. */
  116753. innerGlow: boolean;
  116754. /**
  116755. * Specifies whether or not the outer glow is ACTIVE in the layer.
  116756. */
  116757. outerGlow: boolean;
  116758. /**
  116759. * Specifies the horizontal size of the blur.
  116760. */
  116761. /**
  116762. * Gets the horizontal size of the blur.
  116763. */
  116764. blurHorizontalSize: number;
  116765. /**
  116766. * Specifies the vertical size of the blur.
  116767. */
  116768. /**
  116769. * Gets the vertical size of the blur.
  116770. */
  116771. blurVerticalSize: number;
  116772. /**
  116773. * An event triggered when the highlight layer is being blurred.
  116774. */
  116775. onBeforeBlurObservable: Observable<HighlightLayer>;
  116776. /**
  116777. * An event triggered when the highlight layer has been blurred.
  116778. */
  116779. onAfterBlurObservable: Observable<HighlightLayer>;
  116780. private _instanceGlowingMeshStencilReference;
  116781. private _options;
  116782. private _downSamplePostprocess;
  116783. private _horizontalBlurPostprocess;
  116784. private _verticalBlurPostprocess;
  116785. private _blurTexture;
  116786. private _meshes;
  116787. private _excludedMeshes;
  116788. /**
  116789. * Instantiates a new highlight Layer and references it to the scene..
  116790. * @param name The name of the layer
  116791. * @param scene The scene to use the layer in
  116792. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  116793. */
  116794. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  116795. /**
  116796. * Get the effect name of the layer.
  116797. * @return The effect name
  116798. */
  116799. getEffectName(): string;
  116800. /**
  116801. * Create the merge effect. This is the shader use to blit the information back
  116802. * to the main canvas at the end of the scene rendering.
  116803. */
  116804. protected _createMergeEffect(): Effect;
  116805. /**
  116806. * Creates the render target textures and post processes used in the highlight layer.
  116807. */
  116808. protected _createTextureAndPostProcesses(): void;
  116809. /**
  116810. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116811. */
  116812. needStencil(): boolean;
  116813. /**
  116814. * Checks for the readiness of the element composing the layer.
  116815. * @param subMesh the mesh to check for
  116816. * @param useInstances specify wether or not to use instances to render the mesh
  116817. * @param emissiveTexture the associated emissive texture used to generate the glow
  116818. * @return true if ready otherwise, false
  116819. */
  116820. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116821. /**
  116822. * Implementation specific of rendering the generating effect on the main canvas.
  116823. * @param effect The effect used to render through
  116824. */
  116825. protected _internalRender(effect: Effect): void;
  116826. /**
  116827. * Returns true if the layer contains information to display, otherwise false.
  116828. */
  116829. shouldRender(): boolean;
  116830. /**
  116831. * Returns true if the mesh should render, otherwise false.
  116832. * @param mesh The mesh to render
  116833. * @returns true if it should render otherwise false
  116834. */
  116835. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116836. /**
  116837. * Sets the required values for both the emissive texture and and the main color.
  116838. */
  116839. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116840. /**
  116841. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  116842. * @param mesh The mesh to exclude from the highlight layer
  116843. */
  116844. addExcludedMesh(mesh: Mesh): void;
  116845. /**
  116846. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  116847. * @param mesh The mesh to highlight
  116848. */
  116849. removeExcludedMesh(mesh: Mesh): void;
  116850. /**
  116851. * Determine if a given mesh will be highlighted by the current HighlightLayer
  116852. * @param mesh mesh to test
  116853. * @returns true if the mesh will be highlighted by the current HighlightLayer
  116854. */
  116855. hasMesh(mesh: AbstractMesh): boolean;
  116856. /**
  116857. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  116858. * @param mesh The mesh to highlight
  116859. * @param color The color of the highlight
  116860. * @param glowEmissiveOnly Extract the glow from the emissive texture
  116861. */
  116862. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  116863. /**
  116864. * Remove a mesh from the highlight layer in order to make it stop glowing.
  116865. * @param mesh The mesh to highlight
  116866. */
  116867. removeMesh(mesh: Mesh): void;
  116868. /**
  116869. * Force the stencil to the normal expected value for none glowing parts
  116870. */
  116871. private _defaultStencilReference;
  116872. /**
  116873. * Free any resources and references associated to a mesh.
  116874. * Internal use
  116875. * @param mesh The mesh to free.
  116876. * @hidden
  116877. */
  116878. _disposeMesh(mesh: Mesh): void;
  116879. /**
  116880. * Dispose the highlight layer and free resources.
  116881. */
  116882. dispose(): void;
  116883. /**
  116884. * Gets the class name of the effect layer
  116885. * @returns the string with the class name of the effect layer
  116886. */
  116887. getClassName(): string;
  116888. /**
  116889. * Serializes this Highlight layer
  116890. * @returns a serialized Highlight layer object
  116891. */
  116892. serialize(): any;
  116893. /**
  116894. * Creates a Highlight layer from parsed Highlight layer data
  116895. * @param parsedHightlightLayer defines the Highlight layer data
  116896. * @param scene defines the current scene
  116897. * @param rootUrl defines the root URL containing the Highlight layer information
  116898. * @returns a parsed Highlight layer
  116899. */
  116900. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  116901. }
  116902. }
  116903. declare module BABYLON {
  116904. interface AbstractScene {
  116905. /**
  116906. * The list of layers (background and foreground) of the scene
  116907. */
  116908. layers: Array<Layer>;
  116909. }
  116910. /**
  116911. * Defines the layer scene component responsible to manage any layers
  116912. * in a given scene.
  116913. */
  116914. export class LayerSceneComponent implements ISceneComponent {
  116915. /**
  116916. * The component name helpfull to identify the component in the list of scene components.
  116917. */
  116918. readonly name: string;
  116919. /**
  116920. * The scene the component belongs to.
  116921. */
  116922. scene: Scene;
  116923. private _engine;
  116924. /**
  116925. * Creates a new instance of the component for the given scene
  116926. * @param scene Defines the scene to register the component in
  116927. */
  116928. constructor(scene: Scene);
  116929. /**
  116930. * Registers the component in a given scene
  116931. */
  116932. register(): void;
  116933. /**
  116934. * Rebuilds the elements related to this component in case of
  116935. * context lost for instance.
  116936. */
  116937. rebuild(): void;
  116938. /**
  116939. * Disposes the component and the associated ressources.
  116940. */
  116941. dispose(): void;
  116942. private _draw;
  116943. private _drawCameraPredicate;
  116944. private _drawCameraBackground;
  116945. private _drawCameraForeground;
  116946. private _drawRenderTargetPredicate;
  116947. private _drawRenderTargetBackground;
  116948. private _drawRenderTargetForeground;
  116949. /**
  116950. * Adds all the elements from the container to the scene
  116951. * @param container the container holding the elements
  116952. */
  116953. addFromContainer(container: AbstractScene): void;
  116954. /**
  116955. * Removes all the elements in the container from the scene
  116956. * @param container contains the elements to remove
  116957. * @param dispose if the removed element should be disposed (default: false)
  116958. */
  116959. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116960. }
  116961. }
  116962. declare module BABYLON {
  116963. /** @hidden */
  116964. export var layerPixelShader: {
  116965. name: string;
  116966. shader: string;
  116967. };
  116968. }
  116969. declare module BABYLON {
  116970. /** @hidden */
  116971. export var layerVertexShader: {
  116972. name: string;
  116973. shader: string;
  116974. };
  116975. }
  116976. declare module BABYLON {
  116977. /**
  116978. * This represents a full screen 2d layer.
  116979. * This can be useful to display a picture in the background of your scene for instance.
  116980. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116981. */
  116982. export class Layer {
  116983. /**
  116984. * Define the name of the layer.
  116985. */
  116986. name: string;
  116987. /**
  116988. * Define the texture the layer should display.
  116989. */
  116990. texture: Nullable<Texture>;
  116991. /**
  116992. * Is the layer in background or foreground.
  116993. */
  116994. isBackground: boolean;
  116995. /**
  116996. * Define the color of the layer (instead of texture).
  116997. */
  116998. color: Color4;
  116999. /**
  117000. * Define the scale of the layer in order to zoom in out of the texture.
  117001. */
  117002. scale: Vector2;
  117003. /**
  117004. * Define an offset for the layer in order to shift the texture.
  117005. */
  117006. offset: Vector2;
  117007. /**
  117008. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  117009. */
  117010. alphaBlendingMode: number;
  117011. /**
  117012. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  117013. * Alpha test will not mix with the background color in case of transparency.
  117014. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  117015. */
  117016. alphaTest: boolean;
  117017. /**
  117018. * Define a mask to restrict the layer to only some of the scene cameras.
  117019. */
  117020. layerMask: number;
  117021. /**
  117022. * Define the list of render target the layer is visible into.
  117023. */
  117024. renderTargetTextures: RenderTargetTexture[];
  117025. /**
  117026. * Define if the layer is only used in renderTarget or if it also
  117027. * renders in the main frame buffer of the canvas.
  117028. */
  117029. renderOnlyInRenderTargetTextures: boolean;
  117030. private _scene;
  117031. private _vertexBuffers;
  117032. private _indexBuffer;
  117033. private _effect;
  117034. private _alphaTestEffect;
  117035. /**
  117036. * An event triggered when the layer is disposed.
  117037. */
  117038. onDisposeObservable: Observable<Layer>;
  117039. private _onDisposeObserver;
  117040. /**
  117041. * Back compatibility with callback before the onDisposeObservable existed.
  117042. * The set callback will be triggered when the layer has been disposed.
  117043. */
  117044. onDispose: () => void;
  117045. /**
  117046. * An event triggered before rendering the scene
  117047. */
  117048. onBeforeRenderObservable: Observable<Layer>;
  117049. private _onBeforeRenderObserver;
  117050. /**
  117051. * Back compatibility with callback before the onBeforeRenderObservable existed.
  117052. * The set callback will be triggered just before rendering the layer.
  117053. */
  117054. onBeforeRender: () => void;
  117055. /**
  117056. * An event triggered after rendering the scene
  117057. */
  117058. onAfterRenderObservable: Observable<Layer>;
  117059. private _onAfterRenderObserver;
  117060. /**
  117061. * Back compatibility with callback before the onAfterRenderObservable existed.
  117062. * The set callback will be triggered just after rendering the layer.
  117063. */
  117064. onAfterRender: () => void;
  117065. /**
  117066. * Instantiates a new layer.
  117067. * This represents a full screen 2d layer.
  117068. * This can be useful to display a picture in the background of your scene for instance.
  117069. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117070. * @param name Define the name of the layer in the scene
  117071. * @param imgUrl Define the url of the texture to display in the layer
  117072. * @param scene Define the scene the layer belongs to
  117073. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  117074. * @param color Defines a color for the layer
  117075. */
  117076. constructor(
  117077. /**
  117078. * Define the name of the layer.
  117079. */
  117080. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  117081. private _createIndexBuffer;
  117082. /** @hidden */
  117083. _rebuild(): void;
  117084. /**
  117085. * Renders the layer in the scene.
  117086. */
  117087. render(): void;
  117088. /**
  117089. * Disposes and releases the associated ressources.
  117090. */
  117091. dispose(): void;
  117092. }
  117093. }
  117094. declare module BABYLON {
  117095. /** @hidden */
  117096. export var lensFlarePixelShader: {
  117097. name: string;
  117098. shader: string;
  117099. };
  117100. }
  117101. declare module BABYLON {
  117102. /** @hidden */
  117103. export var lensFlareVertexShader: {
  117104. name: string;
  117105. shader: string;
  117106. };
  117107. }
  117108. declare module BABYLON {
  117109. /**
  117110. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117111. * It is usually composed of several `lensFlare`.
  117112. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117113. */
  117114. export class LensFlareSystem {
  117115. /**
  117116. * Define the name of the lens flare system
  117117. */
  117118. name: string;
  117119. /**
  117120. * List of lens flares used in this system.
  117121. */
  117122. lensFlares: LensFlare[];
  117123. /**
  117124. * Define a limit from the border the lens flare can be visible.
  117125. */
  117126. borderLimit: number;
  117127. /**
  117128. * Define a viewport border we do not want to see the lens flare in.
  117129. */
  117130. viewportBorder: number;
  117131. /**
  117132. * Define a predicate which could limit the list of meshes able to occlude the effect.
  117133. */
  117134. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117135. /**
  117136. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  117137. */
  117138. layerMask: number;
  117139. /**
  117140. * Define the id of the lens flare system in the scene.
  117141. * (equal to name by default)
  117142. */
  117143. id: string;
  117144. private _scene;
  117145. private _emitter;
  117146. private _vertexBuffers;
  117147. private _indexBuffer;
  117148. private _effect;
  117149. private _positionX;
  117150. private _positionY;
  117151. private _isEnabled;
  117152. /** @hidden */
  117153. static _SceneComponentInitialization: (scene: Scene) => void;
  117154. /**
  117155. * Instantiates a lens flare system.
  117156. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117157. * It is usually composed of several `lensFlare`.
  117158. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117159. * @param name Define the name of the lens flare system in the scene
  117160. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  117161. * @param scene Define the scene the lens flare system belongs to
  117162. */
  117163. constructor(
  117164. /**
  117165. * Define the name of the lens flare system
  117166. */
  117167. name: string, emitter: any, scene: Scene);
  117168. /**
  117169. * Define if the lens flare system is enabled.
  117170. */
  117171. isEnabled: boolean;
  117172. /**
  117173. * Get the scene the effects belongs to.
  117174. * @returns the scene holding the lens flare system
  117175. */
  117176. getScene(): Scene;
  117177. /**
  117178. * Get the emitter of the lens flare system.
  117179. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117180. * @returns the emitter of the lens flare system
  117181. */
  117182. getEmitter(): any;
  117183. /**
  117184. * Set the emitter of the lens flare system.
  117185. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117186. * @param newEmitter Define the new emitter of the system
  117187. */
  117188. setEmitter(newEmitter: any): void;
  117189. /**
  117190. * Get the lens flare system emitter position.
  117191. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  117192. * @returns the position
  117193. */
  117194. getEmitterPosition(): Vector3;
  117195. /**
  117196. * @hidden
  117197. */
  117198. computeEffectivePosition(globalViewport: Viewport): boolean;
  117199. /** @hidden */
  117200. _isVisible(): boolean;
  117201. /**
  117202. * @hidden
  117203. */
  117204. render(): boolean;
  117205. /**
  117206. * Dispose and release the lens flare with its associated resources.
  117207. */
  117208. dispose(): void;
  117209. /**
  117210. * Parse a lens flare system from a JSON repressentation
  117211. * @param parsedLensFlareSystem Define the JSON to parse
  117212. * @param scene Define the scene the parsed system should be instantiated in
  117213. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  117214. * @returns the parsed system
  117215. */
  117216. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  117217. /**
  117218. * Serialize the current Lens Flare System into a JSON representation.
  117219. * @returns the serialized JSON
  117220. */
  117221. serialize(): any;
  117222. }
  117223. }
  117224. declare module BABYLON {
  117225. /**
  117226. * This represents one of the lens effect in a `lensFlareSystem`.
  117227. * It controls one of the indiviual texture used in the effect.
  117228. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117229. */
  117230. export class LensFlare {
  117231. /**
  117232. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117233. */
  117234. size: number;
  117235. /**
  117236. * 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.
  117237. */
  117238. position: number;
  117239. /**
  117240. * Define the lens color.
  117241. */
  117242. color: Color3;
  117243. /**
  117244. * Define the lens texture.
  117245. */
  117246. texture: Nullable<Texture>;
  117247. /**
  117248. * Define the alpha mode to render this particular lens.
  117249. */
  117250. alphaMode: number;
  117251. private _system;
  117252. /**
  117253. * Creates a new Lens Flare.
  117254. * This represents one of the lens effect in a `lensFlareSystem`.
  117255. * It controls one of the indiviual texture used in the effect.
  117256. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117257. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  117258. * @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.
  117259. * @param color Define the lens color
  117260. * @param imgUrl Define the lens texture url
  117261. * @param system Define the `lensFlareSystem` this flare is part of
  117262. * @returns The newly created Lens Flare
  117263. */
  117264. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  117265. /**
  117266. * Instantiates a new Lens Flare.
  117267. * This represents one of the lens effect in a `lensFlareSystem`.
  117268. * It controls one of the indiviual texture used in the effect.
  117269. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117270. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  117271. * @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.
  117272. * @param color Define the lens color
  117273. * @param imgUrl Define the lens texture url
  117274. * @param system Define the `lensFlareSystem` this flare is part of
  117275. */
  117276. constructor(
  117277. /**
  117278. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117279. */
  117280. size: number,
  117281. /**
  117282. * 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.
  117283. */
  117284. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  117285. /**
  117286. * Dispose and release the lens flare with its associated resources.
  117287. */
  117288. dispose(): void;
  117289. }
  117290. }
  117291. declare module BABYLON {
  117292. interface AbstractScene {
  117293. /**
  117294. * The list of lens flare system added to the scene
  117295. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117296. */
  117297. lensFlareSystems: Array<LensFlareSystem>;
  117298. /**
  117299. * Removes the given lens flare system from this scene.
  117300. * @param toRemove The lens flare system to remove
  117301. * @returns The index of the removed lens flare system
  117302. */
  117303. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  117304. /**
  117305. * Adds the given lens flare system to this scene
  117306. * @param newLensFlareSystem The lens flare system to add
  117307. */
  117308. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  117309. /**
  117310. * Gets a lens flare system using its name
  117311. * @param name defines the name to look for
  117312. * @returns the lens flare system or null if not found
  117313. */
  117314. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  117315. /**
  117316. * Gets a lens flare system using its id
  117317. * @param id defines the id to look for
  117318. * @returns the lens flare system or null if not found
  117319. */
  117320. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  117321. }
  117322. /**
  117323. * Defines the lens flare scene component responsible to manage any lens flares
  117324. * in a given scene.
  117325. */
  117326. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  117327. /**
  117328. * The component name helpfull to identify the component in the list of scene components.
  117329. */
  117330. readonly name: string;
  117331. /**
  117332. * The scene the component belongs to.
  117333. */
  117334. scene: Scene;
  117335. /**
  117336. * Creates a new instance of the component for the given scene
  117337. * @param scene Defines the scene to register the component in
  117338. */
  117339. constructor(scene: Scene);
  117340. /**
  117341. * Registers the component in a given scene
  117342. */
  117343. register(): void;
  117344. /**
  117345. * Rebuilds the elements related to this component in case of
  117346. * context lost for instance.
  117347. */
  117348. rebuild(): void;
  117349. /**
  117350. * Adds all the elements from the container to the scene
  117351. * @param container the container holding the elements
  117352. */
  117353. addFromContainer(container: AbstractScene): void;
  117354. /**
  117355. * Removes all the elements in the container from the scene
  117356. * @param container contains the elements to remove
  117357. * @param dispose if the removed element should be disposed (default: false)
  117358. */
  117359. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117360. /**
  117361. * Serializes the component data to the specified json object
  117362. * @param serializationObject The object to serialize to
  117363. */
  117364. serialize(serializationObject: any): void;
  117365. /**
  117366. * Disposes the component and the associated ressources.
  117367. */
  117368. dispose(): void;
  117369. private _draw;
  117370. }
  117371. }
  117372. declare module BABYLON {
  117373. /**
  117374. * Defines the shadow generator component responsible to manage any shadow generators
  117375. * in a given scene.
  117376. */
  117377. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  117378. /**
  117379. * The component name helpfull to identify the component in the list of scene components.
  117380. */
  117381. readonly name: string;
  117382. /**
  117383. * The scene the component belongs to.
  117384. */
  117385. scene: Scene;
  117386. /**
  117387. * Creates a new instance of the component for the given scene
  117388. * @param scene Defines the scene to register the component in
  117389. */
  117390. constructor(scene: Scene);
  117391. /**
  117392. * Registers the component in a given scene
  117393. */
  117394. register(): void;
  117395. /**
  117396. * Rebuilds the elements related to this component in case of
  117397. * context lost for instance.
  117398. */
  117399. rebuild(): void;
  117400. /**
  117401. * Serializes the component data to the specified json object
  117402. * @param serializationObject The object to serialize to
  117403. */
  117404. serialize(serializationObject: any): void;
  117405. /**
  117406. * Adds all the elements from the container to the scene
  117407. * @param container the container holding the elements
  117408. */
  117409. addFromContainer(container: AbstractScene): void;
  117410. /**
  117411. * Removes all the elements in the container from the scene
  117412. * @param container contains the elements to remove
  117413. * @param dispose if the removed element should be disposed (default: false)
  117414. */
  117415. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117416. /**
  117417. * Rebuilds the elements related to this component in case of
  117418. * context lost for instance.
  117419. */
  117420. dispose(): void;
  117421. private _gatherRenderTargets;
  117422. }
  117423. }
  117424. declare module BABYLON {
  117425. /**
  117426. * A point light is a light defined by an unique point in world space.
  117427. * The light is emitted in every direction from this point.
  117428. * A good example of a point light is a standard light bulb.
  117429. * Documentation: https://doc.babylonjs.com/babylon101/lights
  117430. */
  117431. export class PointLight extends ShadowLight {
  117432. private _shadowAngle;
  117433. /**
  117434. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117435. * This specifies what angle the shadow will use to be created.
  117436. *
  117437. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117438. */
  117439. /**
  117440. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117441. * This specifies what angle the shadow will use to be created.
  117442. *
  117443. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117444. */
  117445. shadowAngle: number;
  117446. /**
  117447. * Gets the direction if it has been set.
  117448. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117449. */
  117450. /**
  117451. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117452. */
  117453. direction: Vector3;
  117454. /**
  117455. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  117456. * A PointLight emits the light in every direction.
  117457. * It can cast shadows.
  117458. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  117459. * ```javascript
  117460. * var pointLight = new PointLight("pl", camera.position, scene);
  117461. * ```
  117462. * Documentation : https://doc.babylonjs.com/babylon101/lights
  117463. * @param name The light friendly name
  117464. * @param position The position of the point light in the scene
  117465. * @param scene The scene the lights belongs to
  117466. */
  117467. constructor(name: string, position: Vector3, scene: Scene);
  117468. /**
  117469. * Returns the string "PointLight"
  117470. * @returns the class name
  117471. */
  117472. getClassName(): string;
  117473. /**
  117474. * Returns the integer 0.
  117475. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  117476. */
  117477. getTypeID(): number;
  117478. /**
  117479. * Specifies wether or not the shadowmap should be a cube texture.
  117480. * @returns true if the shadowmap needs to be a cube texture.
  117481. */
  117482. needCube(): boolean;
  117483. /**
  117484. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  117485. * @param faceIndex The index of the face we are computed the direction to generate shadow
  117486. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  117487. */
  117488. getShadowDirection(faceIndex?: number): Vector3;
  117489. /**
  117490. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  117491. * - fov = PI / 2
  117492. * - aspect ratio : 1.0
  117493. * - z-near and far equal to the active camera minZ and maxZ.
  117494. * Returns the PointLight.
  117495. */
  117496. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  117497. protected _buildUniformLayout(): void;
  117498. /**
  117499. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  117500. * @param effect The effect to update
  117501. * @param lightIndex The index of the light in the effect to update
  117502. * @returns The point light
  117503. */
  117504. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  117505. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  117506. /**
  117507. * Prepares the list of defines specific to the light type.
  117508. * @param defines the list of defines
  117509. * @param lightIndex defines the index of the light for the effect
  117510. */
  117511. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  117512. }
  117513. }
  117514. declare module BABYLON {
  117515. /**
  117516. * Header information of HDR texture files.
  117517. */
  117518. export interface HDRInfo {
  117519. /**
  117520. * The height of the texture in pixels.
  117521. */
  117522. height: number;
  117523. /**
  117524. * The width of the texture in pixels.
  117525. */
  117526. width: number;
  117527. /**
  117528. * The index of the beginning of the data in the binary file.
  117529. */
  117530. dataPosition: number;
  117531. }
  117532. /**
  117533. * This groups tools to convert HDR texture to native colors array.
  117534. */
  117535. export class HDRTools {
  117536. private static Ldexp;
  117537. private static Rgbe2float;
  117538. private static readStringLine;
  117539. /**
  117540. * Reads header information from an RGBE texture stored in a native array.
  117541. * More information on this format are available here:
  117542. * https://en.wikipedia.org/wiki/RGBE_image_format
  117543. *
  117544. * @param uint8array The binary file stored in native array.
  117545. * @return The header information.
  117546. */
  117547. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  117548. /**
  117549. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  117550. * This RGBE texture needs to store the information as a panorama.
  117551. *
  117552. * More information on this format are available here:
  117553. * https://en.wikipedia.org/wiki/RGBE_image_format
  117554. *
  117555. * @param buffer The binary file stored in an array buffer.
  117556. * @param size The expected size of the extracted cubemap.
  117557. * @return The Cube Map information.
  117558. */
  117559. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  117560. /**
  117561. * Returns the pixels data extracted from an RGBE texture.
  117562. * This pixels will be stored left to right up to down in the R G B order in one array.
  117563. *
  117564. * More information on this format are available here:
  117565. * https://en.wikipedia.org/wiki/RGBE_image_format
  117566. *
  117567. * @param uint8array The binary file stored in an array buffer.
  117568. * @param hdrInfo The header information of the file.
  117569. * @return The pixels data in RGB right to left up to down order.
  117570. */
  117571. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  117572. private static RGBE_ReadPixels_RLE;
  117573. }
  117574. }
  117575. declare module BABYLON {
  117576. /**
  117577. * This represents a texture coming from an HDR input.
  117578. *
  117579. * The only supported format is currently panorama picture stored in RGBE format.
  117580. * Example of such files can be found on HDRLib: http://hdrlib.com/
  117581. */
  117582. export class HDRCubeTexture extends BaseTexture {
  117583. private static _facesMapping;
  117584. private _generateHarmonics;
  117585. private _noMipmap;
  117586. private _textureMatrix;
  117587. private _size;
  117588. private _onLoad;
  117589. private _onError;
  117590. /**
  117591. * The texture URL.
  117592. */
  117593. url: string;
  117594. /**
  117595. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  117596. */
  117597. coordinatesMode: number;
  117598. protected _isBlocking: boolean;
  117599. /**
  117600. * Sets wether or not the texture is blocking during loading.
  117601. */
  117602. /**
  117603. * Gets wether or not the texture is blocking during loading.
  117604. */
  117605. isBlocking: boolean;
  117606. protected _rotationY: number;
  117607. /**
  117608. * Sets texture matrix rotation angle around Y axis in radians.
  117609. */
  117610. /**
  117611. * Gets texture matrix rotation angle around Y axis radians.
  117612. */
  117613. rotationY: number;
  117614. /**
  117615. * Gets or sets the center of the bounding box associated with the cube texture
  117616. * It must define where the camera used to render the texture was set
  117617. */
  117618. boundingBoxPosition: Vector3;
  117619. private _boundingBoxSize;
  117620. /**
  117621. * Gets or sets the size of the bounding box associated with the cube texture
  117622. * When defined, the cubemap will switch to local mode
  117623. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  117624. * @example https://www.babylonjs-playground.com/#RNASML
  117625. */
  117626. boundingBoxSize: Vector3;
  117627. /**
  117628. * Instantiates an HDRTexture from the following parameters.
  117629. *
  117630. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  117631. * @param scene The scene the texture will be used in
  117632. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117633. * @param noMipmap Forces to not generate the mipmap if true
  117634. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  117635. * @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)
  117636. * @param reserved Reserved flag for internal use.
  117637. */
  117638. 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>);
  117639. /**
  117640. * Get the current class name of the texture useful for serialization or dynamic coding.
  117641. * @returns "HDRCubeTexture"
  117642. */
  117643. getClassName(): string;
  117644. /**
  117645. * Occurs when the file is raw .hdr file.
  117646. */
  117647. private loadTexture;
  117648. clone(): HDRCubeTexture;
  117649. delayLoad(): void;
  117650. /**
  117651. * Get the texture reflection matrix used to rotate/transform the reflection.
  117652. * @returns the reflection matrix
  117653. */
  117654. getReflectionTextureMatrix(): Matrix;
  117655. /**
  117656. * Set the texture reflection matrix used to rotate/transform the reflection.
  117657. * @param value Define the reflection matrix to set
  117658. */
  117659. setReflectionTextureMatrix(value: Matrix): void;
  117660. /**
  117661. * Parses a JSON representation of an HDR Texture in order to create the texture
  117662. * @param parsedTexture Define the JSON representation
  117663. * @param scene Define the scene the texture should be created in
  117664. * @param rootUrl Define the root url in case we need to load relative dependencies
  117665. * @returns the newly created texture after parsing
  117666. */
  117667. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  117668. serialize(): any;
  117669. }
  117670. }
  117671. declare module BABYLON {
  117672. /**
  117673. * Class used to control physics engine
  117674. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117675. */
  117676. export class PhysicsEngine implements IPhysicsEngine {
  117677. private _physicsPlugin;
  117678. /**
  117679. * Global value used to control the smallest number supported by the simulation
  117680. */
  117681. static Epsilon: number;
  117682. private _impostors;
  117683. private _joints;
  117684. /**
  117685. * Gets the gravity vector used by the simulation
  117686. */
  117687. gravity: Vector3;
  117688. /**
  117689. * Factory used to create the default physics plugin.
  117690. * @returns The default physics plugin
  117691. */
  117692. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  117693. /**
  117694. * Creates a new Physics Engine
  117695. * @param gravity defines the gravity vector used by the simulation
  117696. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  117697. */
  117698. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  117699. /**
  117700. * Sets the gravity vector used by the simulation
  117701. * @param gravity defines the gravity vector to use
  117702. */
  117703. setGravity(gravity: Vector3): void;
  117704. /**
  117705. * Set the time step of the physics engine.
  117706. * Default is 1/60.
  117707. * To slow it down, enter 1/600 for example.
  117708. * To speed it up, 1/30
  117709. * @param newTimeStep defines the new timestep to apply to this world.
  117710. */
  117711. setTimeStep(newTimeStep?: number): void;
  117712. /**
  117713. * Get the time step of the physics engine.
  117714. * @returns the current time step
  117715. */
  117716. getTimeStep(): number;
  117717. /**
  117718. * Release all resources
  117719. */
  117720. dispose(): void;
  117721. /**
  117722. * Gets the name of the current physics plugin
  117723. * @returns the name of the plugin
  117724. */
  117725. getPhysicsPluginName(): string;
  117726. /**
  117727. * Adding a new impostor for the impostor tracking.
  117728. * This will be done by the impostor itself.
  117729. * @param impostor the impostor to add
  117730. */
  117731. addImpostor(impostor: PhysicsImpostor): void;
  117732. /**
  117733. * Remove an impostor from the engine.
  117734. * This impostor and its mesh will not longer be updated by the physics engine.
  117735. * @param impostor the impostor to remove
  117736. */
  117737. removeImpostor(impostor: PhysicsImpostor): void;
  117738. /**
  117739. * Add a joint to the physics engine
  117740. * @param mainImpostor defines the main impostor to which the joint is added.
  117741. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  117742. * @param joint defines the joint that will connect both impostors.
  117743. */
  117744. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117745. /**
  117746. * Removes a joint from the simulation
  117747. * @param mainImpostor defines the impostor used with the joint
  117748. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  117749. * @param joint defines the joint to remove
  117750. */
  117751. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117752. /**
  117753. * Called by the scene. No need to call it.
  117754. * @param delta defines the timespam between frames
  117755. */
  117756. _step(delta: number): void;
  117757. /**
  117758. * Gets the current plugin used to run the simulation
  117759. * @returns current plugin
  117760. */
  117761. getPhysicsPlugin(): IPhysicsEnginePlugin;
  117762. /**
  117763. * Gets the list of physic impostors
  117764. * @returns an array of PhysicsImpostor
  117765. */
  117766. getImpostors(): Array<PhysicsImpostor>;
  117767. /**
  117768. * Gets the impostor for a physics enabled object
  117769. * @param object defines the object impersonated by the impostor
  117770. * @returns the PhysicsImpostor or null if not found
  117771. */
  117772. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117773. /**
  117774. * Gets the impostor for a physics body object
  117775. * @param body defines physics body used by the impostor
  117776. * @returns the PhysicsImpostor or null if not found
  117777. */
  117778. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  117779. /**
  117780. * Does a raycast in the physics world
  117781. * @param from when should the ray start?
  117782. * @param to when should the ray end?
  117783. * @returns PhysicsRaycastResult
  117784. */
  117785. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117786. }
  117787. }
  117788. declare module BABYLON {
  117789. /** @hidden */
  117790. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  117791. private _useDeltaForWorldStep;
  117792. world: any;
  117793. name: string;
  117794. private _physicsMaterials;
  117795. private _fixedTimeStep;
  117796. private _cannonRaycastResult;
  117797. private _raycastResult;
  117798. private _physicsBodysToRemoveAfterStep;
  117799. BJSCANNON: any;
  117800. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  117801. setGravity(gravity: Vector3): void;
  117802. setTimeStep(timeStep: number): void;
  117803. getTimeStep(): number;
  117804. executeStep(delta: number): void;
  117805. private _removeMarkedPhysicsBodiesFromWorld;
  117806. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117807. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117808. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117809. private _processChildMeshes;
  117810. removePhysicsBody(impostor: PhysicsImpostor): void;
  117811. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117812. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117813. private _addMaterial;
  117814. private _checkWithEpsilon;
  117815. private _createShape;
  117816. private _createHeightmap;
  117817. private _minus90X;
  117818. private _plus90X;
  117819. private _tmpPosition;
  117820. private _tmpDeltaPosition;
  117821. private _tmpUnityRotation;
  117822. private _updatePhysicsBodyTransformation;
  117823. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117824. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117825. isSupported(): boolean;
  117826. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117827. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117828. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117829. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117830. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117831. getBodyMass(impostor: PhysicsImpostor): number;
  117832. getBodyFriction(impostor: PhysicsImpostor): number;
  117833. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117834. getBodyRestitution(impostor: PhysicsImpostor): number;
  117835. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117836. sleepBody(impostor: PhysicsImpostor): void;
  117837. wakeUpBody(impostor: PhysicsImpostor): void;
  117838. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  117839. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  117840. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  117841. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117842. getRadius(impostor: PhysicsImpostor): number;
  117843. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117844. dispose(): void;
  117845. private _extendNamespace;
  117846. /**
  117847. * Does a raycast in the physics world
  117848. * @param from when should the ray start?
  117849. * @param to when should the ray end?
  117850. * @returns PhysicsRaycastResult
  117851. */
  117852. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117853. }
  117854. }
  117855. declare module BABYLON {
  117856. /** @hidden */
  117857. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  117858. world: any;
  117859. name: string;
  117860. BJSOIMO: any;
  117861. private _raycastResult;
  117862. constructor(iterations?: number, oimoInjection?: any);
  117863. setGravity(gravity: Vector3): void;
  117864. setTimeStep(timeStep: number): void;
  117865. getTimeStep(): number;
  117866. private _tmpImpostorsArray;
  117867. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117868. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117869. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117870. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117871. private _tmpPositionVector;
  117872. removePhysicsBody(impostor: PhysicsImpostor): void;
  117873. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117874. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117875. isSupported(): boolean;
  117876. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117877. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117878. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117879. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117880. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117881. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117882. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117883. getBodyMass(impostor: PhysicsImpostor): number;
  117884. getBodyFriction(impostor: PhysicsImpostor): number;
  117885. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117886. getBodyRestitution(impostor: PhysicsImpostor): number;
  117887. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117888. sleepBody(impostor: PhysicsImpostor): void;
  117889. wakeUpBody(impostor: PhysicsImpostor): void;
  117890. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117891. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  117892. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117893. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117894. getRadius(impostor: PhysicsImpostor): number;
  117895. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117896. dispose(): void;
  117897. /**
  117898. * Does a raycast in the physics world
  117899. * @param from when should the ray start?
  117900. * @param to when should the ray end?
  117901. * @returns PhysicsRaycastResult
  117902. */
  117903. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117904. }
  117905. }
  117906. declare module BABYLON {
  117907. /**
  117908. * Class containing static functions to help procedurally build meshes
  117909. */
  117910. export class RibbonBuilder {
  117911. /**
  117912. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117913. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117914. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117915. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117916. * * 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
  117917. * * 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
  117918. * * 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
  117919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117920. * * 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
  117921. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117922. * * 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
  117923. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117924. * * 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
  117925. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117927. * @param name defines the name of the mesh
  117928. * @param options defines the options used to create the mesh
  117929. * @param scene defines the hosting scene
  117930. * @returns the ribbon mesh
  117931. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117932. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117933. */
  117934. static CreateRibbon(name: string, options: {
  117935. pathArray: Vector3[][];
  117936. closeArray?: boolean;
  117937. closePath?: boolean;
  117938. offset?: number;
  117939. updatable?: boolean;
  117940. sideOrientation?: number;
  117941. frontUVs?: Vector4;
  117942. backUVs?: Vector4;
  117943. instance?: Mesh;
  117944. invertUV?: boolean;
  117945. uvs?: Vector2[];
  117946. colors?: Color4[];
  117947. }, scene?: Nullable<Scene>): Mesh;
  117948. }
  117949. }
  117950. declare module BABYLON {
  117951. /**
  117952. * Class containing static functions to help procedurally build meshes
  117953. */
  117954. export class ShapeBuilder {
  117955. /**
  117956. * 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.
  117957. * * 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.
  117958. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117959. * * 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.
  117960. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117961. * * 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
  117962. * * 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
  117963. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117965. * * 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
  117966. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117968. * @param name defines the name of the mesh
  117969. * @param options defines the options used to create the mesh
  117970. * @param scene defines the hosting scene
  117971. * @returns the extruded shape mesh
  117972. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117973. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117974. */
  117975. static ExtrudeShape(name: string, options: {
  117976. shape: Vector3[];
  117977. path: Vector3[];
  117978. scale?: number;
  117979. rotation?: number;
  117980. cap?: number;
  117981. updatable?: boolean;
  117982. sideOrientation?: number;
  117983. frontUVs?: Vector4;
  117984. backUVs?: Vector4;
  117985. instance?: Mesh;
  117986. invertUV?: boolean;
  117987. }, scene?: Nullable<Scene>): Mesh;
  117988. /**
  117989. * Creates an custom extruded shape mesh.
  117990. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  117991. * * 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.
  117992. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117993. * * 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
  117994. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  117995. * * 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
  117996. * * It must returns a float value that will be the scale value applied to the shape on each path point
  117997. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  117998. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  117999. * * 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
  118000. * * 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
  118001. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  118002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118003. * * 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
  118004. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118006. * @param name defines the name of the mesh
  118007. * @param options defines the options used to create the mesh
  118008. * @param scene defines the hosting scene
  118009. * @returns the custom extruded shape mesh
  118010. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  118011. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118012. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118013. */
  118014. static ExtrudeShapeCustom(name: string, options: {
  118015. shape: Vector3[];
  118016. path: Vector3[];
  118017. scaleFunction?: any;
  118018. rotationFunction?: any;
  118019. ribbonCloseArray?: boolean;
  118020. ribbonClosePath?: boolean;
  118021. cap?: number;
  118022. updatable?: boolean;
  118023. sideOrientation?: number;
  118024. frontUVs?: Vector4;
  118025. backUVs?: Vector4;
  118026. instance?: Mesh;
  118027. invertUV?: boolean;
  118028. }, scene?: Nullable<Scene>): Mesh;
  118029. private static _ExtrudeShapeGeneric;
  118030. }
  118031. }
  118032. declare module BABYLON {
  118033. /**
  118034. * AmmoJS Physics plugin
  118035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118036. * @see https://github.com/kripken/ammo.js/
  118037. */
  118038. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  118039. private _useDeltaForWorldStep;
  118040. /**
  118041. * Reference to the Ammo library
  118042. */
  118043. bjsAMMO: any;
  118044. /**
  118045. * Created ammoJS world which physics bodies are added to
  118046. */
  118047. world: any;
  118048. /**
  118049. * Name of the plugin
  118050. */
  118051. name: string;
  118052. private _timeStep;
  118053. private _fixedTimeStep;
  118054. private _maxSteps;
  118055. private _tmpQuaternion;
  118056. private _tmpAmmoTransform;
  118057. private _tmpAmmoQuaternion;
  118058. private _tmpAmmoConcreteContactResultCallback;
  118059. private _collisionConfiguration;
  118060. private _dispatcher;
  118061. private _overlappingPairCache;
  118062. private _solver;
  118063. private _softBodySolver;
  118064. private _tmpAmmoVectorA;
  118065. private _tmpAmmoVectorB;
  118066. private _tmpAmmoVectorC;
  118067. private _tmpAmmoVectorD;
  118068. private _tmpContactCallbackResult;
  118069. private _tmpAmmoVectorRCA;
  118070. private _tmpAmmoVectorRCB;
  118071. private _raycastResult;
  118072. private static readonly DISABLE_COLLISION_FLAG;
  118073. private static readonly KINEMATIC_FLAG;
  118074. private static readonly DISABLE_DEACTIVATION_FLAG;
  118075. /**
  118076. * Initializes the ammoJS plugin
  118077. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  118078. * @param ammoInjection can be used to inject your own ammo reference
  118079. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  118080. */
  118081. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  118082. /**
  118083. * Sets the gravity of the physics world (m/(s^2))
  118084. * @param gravity Gravity to set
  118085. */
  118086. setGravity(gravity: Vector3): void;
  118087. /**
  118088. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  118089. * @param timeStep timestep to use in seconds
  118090. */
  118091. setTimeStep(timeStep: number): void;
  118092. /**
  118093. * 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)
  118094. * @param fixedTimeStep fixedTimeStep to use in seconds
  118095. */
  118096. setFixedTimeStep(fixedTimeStep: number): void;
  118097. /**
  118098. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  118099. * @param maxSteps the maximum number of steps by the physics engine per frame
  118100. */
  118101. setMaxSteps(maxSteps: number): void;
  118102. /**
  118103. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  118104. * @returns the current timestep in seconds
  118105. */
  118106. getTimeStep(): number;
  118107. private _isImpostorInContact;
  118108. private _isImpostorPairInContact;
  118109. private _stepSimulation;
  118110. /**
  118111. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  118112. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  118113. * After the step the babylon meshes are set to the position of the physics imposters
  118114. * @param delta amount of time to step forward
  118115. * @param impostors array of imposters to update before/after the step
  118116. */
  118117. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118118. /**
  118119. * Update babylon mesh to match physics world object
  118120. * @param impostor imposter to match
  118121. */
  118122. private _afterSoftStep;
  118123. /**
  118124. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118125. * @param impostor imposter to match
  118126. */
  118127. private _ropeStep;
  118128. /**
  118129. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118130. * @param impostor imposter to match
  118131. */
  118132. private _softbodyOrClothStep;
  118133. private _tmpVector;
  118134. private _tmpMatrix;
  118135. /**
  118136. * Applies an impulse on the imposter
  118137. * @param impostor imposter to apply impulse to
  118138. * @param force amount of force to be applied to the imposter
  118139. * @param contactPoint the location to apply the impulse on the imposter
  118140. */
  118141. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118142. /**
  118143. * Applies a force on the imposter
  118144. * @param impostor imposter to apply force
  118145. * @param force amount of force to be applied to the imposter
  118146. * @param contactPoint the location to apply the force on the imposter
  118147. */
  118148. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118149. /**
  118150. * Creates a physics body using the plugin
  118151. * @param impostor the imposter to create the physics body on
  118152. */
  118153. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118154. /**
  118155. * Removes the physics body from the imposter and disposes of the body's memory
  118156. * @param impostor imposter to remove the physics body from
  118157. */
  118158. removePhysicsBody(impostor: PhysicsImpostor): void;
  118159. /**
  118160. * Generates a joint
  118161. * @param impostorJoint the imposter joint to create the joint with
  118162. */
  118163. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118164. /**
  118165. * Removes a joint
  118166. * @param impostorJoint the imposter joint to remove the joint from
  118167. */
  118168. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118169. private _addMeshVerts;
  118170. /**
  118171. * Initialise the soft body vertices to match its object's (mesh) vertices
  118172. * Softbody vertices (nodes) are in world space and to match this
  118173. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  118174. * @param impostor to create the softbody for
  118175. */
  118176. private _softVertexData;
  118177. /**
  118178. * Create an impostor's soft body
  118179. * @param impostor to create the softbody for
  118180. */
  118181. private _createSoftbody;
  118182. /**
  118183. * Create cloth for an impostor
  118184. * @param impostor to create the softbody for
  118185. */
  118186. private _createCloth;
  118187. /**
  118188. * Create rope for an impostor
  118189. * @param impostor to create the softbody for
  118190. */
  118191. private _createRope;
  118192. private _addHullVerts;
  118193. private _createShape;
  118194. /**
  118195. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  118196. * @param impostor imposter containing the physics body and babylon object
  118197. */
  118198. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118199. /**
  118200. * Sets the babylon object's position/rotation from the physics body's position/rotation
  118201. * @param impostor imposter containing the physics body and babylon object
  118202. * @param newPosition new position
  118203. * @param newRotation new rotation
  118204. */
  118205. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118206. /**
  118207. * If this plugin is supported
  118208. * @returns true if its supported
  118209. */
  118210. isSupported(): boolean;
  118211. /**
  118212. * Sets the linear velocity of the physics body
  118213. * @param impostor imposter to set the velocity on
  118214. * @param velocity velocity to set
  118215. */
  118216. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118217. /**
  118218. * Sets the angular velocity of the physics body
  118219. * @param impostor imposter to set the velocity on
  118220. * @param velocity velocity to set
  118221. */
  118222. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118223. /**
  118224. * gets the linear velocity
  118225. * @param impostor imposter to get linear velocity from
  118226. * @returns linear velocity
  118227. */
  118228. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118229. /**
  118230. * gets the angular velocity
  118231. * @param impostor imposter to get angular velocity from
  118232. * @returns angular velocity
  118233. */
  118234. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118235. /**
  118236. * Sets the mass of physics body
  118237. * @param impostor imposter to set the mass on
  118238. * @param mass mass to set
  118239. */
  118240. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118241. /**
  118242. * Gets the mass of the physics body
  118243. * @param impostor imposter to get the mass from
  118244. * @returns mass
  118245. */
  118246. getBodyMass(impostor: PhysicsImpostor): number;
  118247. /**
  118248. * Gets friction of the impostor
  118249. * @param impostor impostor to get friction from
  118250. * @returns friction value
  118251. */
  118252. getBodyFriction(impostor: PhysicsImpostor): number;
  118253. /**
  118254. * Sets friction of the impostor
  118255. * @param impostor impostor to set friction on
  118256. * @param friction friction value
  118257. */
  118258. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118259. /**
  118260. * Gets restitution of the impostor
  118261. * @param impostor impostor to get restitution from
  118262. * @returns restitution value
  118263. */
  118264. getBodyRestitution(impostor: PhysicsImpostor): number;
  118265. /**
  118266. * Sets resitution of the impostor
  118267. * @param impostor impostor to set resitution on
  118268. * @param restitution resitution value
  118269. */
  118270. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118271. /**
  118272. * Gets pressure inside the impostor
  118273. * @param impostor impostor to get pressure from
  118274. * @returns pressure value
  118275. */
  118276. getBodyPressure(impostor: PhysicsImpostor): number;
  118277. /**
  118278. * Sets pressure inside a soft body impostor
  118279. * Cloth and rope must remain 0 pressure
  118280. * @param impostor impostor to set pressure on
  118281. * @param pressure pressure value
  118282. */
  118283. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  118284. /**
  118285. * Gets stiffness of the impostor
  118286. * @param impostor impostor to get stiffness from
  118287. * @returns pressure value
  118288. */
  118289. getBodyStiffness(impostor: PhysicsImpostor): number;
  118290. /**
  118291. * Sets stiffness of the impostor
  118292. * @param impostor impostor to set stiffness on
  118293. * @param stiffness stiffness value from 0 to 1
  118294. */
  118295. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  118296. /**
  118297. * Gets velocityIterations of the impostor
  118298. * @param impostor impostor to get velocity iterations from
  118299. * @returns velocityIterations value
  118300. */
  118301. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  118302. /**
  118303. * Sets velocityIterations of the impostor
  118304. * @param impostor impostor to set velocity iterations on
  118305. * @param velocityIterations velocityIterations value
  118306. */
  118307. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  118308. /**
  118309. * Gets positionIterations of the impostor
  118310. * @param impostor impostor to get position iterations from
  118311. * @returns positionIterations value
  118312. */
  118313. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  118314. /**
  118315. * Sets positionIterations of the impostor
  118316. * @param impostor impostor to set position on
  118317. * @param positionIterations positionIterations value
  118318. */
  118319. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  118320. /**
  118321. * Append an anchor to a cloth object
  118322. * @param impostor is the cloth impostor to add anchor to
  118323. * @param otherImpostor is the rigid impostor to anchor to
  118324. * @param width ratio across width from 0 to 1
  118325. * @param height ratio up height from 0 to 1
  118326. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  118327. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118328. */
  118329. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118330. /**
  118331. * Append an hook to a rope object
  118332. * @param impostor is the rope impostor to add hook to
  118333. * @param otherImpostor is the rigid impostor to hook to
  118334. * @param length ratio along the rope from 0 to 1
  118335. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  118336. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118337. */
  118338. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118339. /**
  118340. * Sleeps the physics body and stops it from being active
  118341. * @param impostor impostor to sleep
  118342. */
  118343. sleepBody(impostor: PhysicsImpostor): void;
  118344. /**
  118345. * Activates the physics body
  118346. * @param impostor impostor to activate
  118347. */
  118348. wakeUpBody(impostor: PhysicsImpostor): void;
  118349. /**
  118350. * Updates the distance parameters of the joint
  118351. * @param joint joint to update
  118352. * @param maxDistance maximum distance of the joint
  118353. * @param minDistance minimum distance of the joint
  118354. */
  118355. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118356. /**
  118357. * Sets a motor on the joint
  118358. * @param joint joint to set motor on
  118359. * @param speed speed of the motor
  118360. * @param maxForce maximum force of the motor
  118361. * @param motorIndex index of the motor
  118362. */
  118363. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118364. /**
  118365. * Sets the motors limit
  118366. * @param joint joint to set limit on
  118367. * @param upperLimit upper limit
  118368. * @param lowerLimit lower limit
  118369. */
  118370. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118371. /**
  118372. * Syncs the position and rotation of a mesh with the impostor
  118373. * @param mesh mesh to sync
  118374. * @param impostor impostor to update the mesh with
  118375. */
  118376. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118377. /**
  118378. * Gets the radius of the impostor
  118379. * @param impostor impostor to get radius from
  118380. * @returns the radius
  118381. */
  118382. getRadius(impostor: PhysicsImpostor): number;
  118383. /**
  118384. * Gets the box size of the impostor
  118385. * @param impostor impostor to get box size from
  118386. * @param result the resulting box size
  118387. */
  118388. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118389. /**
  118390. * Disposes of the impostor
  118391. */
  118392. dispose(): void;
  118393. /**
  118394. * Does a raycast in the physics world
  118395. * @param from when should the ray start?
  118396. * @param to when should the ray end?
  118397. * @returns PhysicsRaycastResult
  118398. */
  118399. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118400. }
  118401. }
  118402. declare module BABYLON {
  118403. interface AbstractScene {
  118404. /**
  118405. * The list of reflection probes added to the scene
  118406. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118407. */
  118408. reflectionProbes: Array<ReflectionProbe>;
  118409. /**
  118410. * Removes the given reflection probe from this scene.
  118411. * @param toRemove The reflection probe to remove
  118412. * @returns The index of the removed reflection probe
  118413. */
  118414. removeReflectionProbe(toRemove: ReflectionProbe): number;
  118415. /**
  118416. * Adds the given reflection probe to this scene.
  118417. * @param newReflectionProbe The reflection probe to add
  118418. */
  118419. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  118420. }
  118421. /**
  118422. * Class used to generate realtime reflection / refraction cube textures
  118423. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118424. */
  118425. export class ReflectionProbe {
  118426. /** defines the name of the probe */
  118427. name: string;
  118428. private _scene;
  118429. private _renderTargetTexture;
  118430. private _projectionMatrix;
  118431. private _viewMatrix;
  118432. private _target;
  118433. private _add;
  118434. private _attachedMesh;
  118435. private _invertYAxis;
  118436. /** Gets or sets probe position (center of the cube map) */
  118437. position: Vector3;
  118438. /**
  118439. * Creates a new reflection probe
  118440. * @param name defines the name of the probe
  118441. * @param size defines the texture resolution (for each face)
  118442. * @param scene defines the hosting scene
  118443. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  118444. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  118445. */
  118446. constructor(
  118447. /** defines the name of the probe */
  118448. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  118449. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  118450. samples: number;
  118451. /** Gets or sets the refresh rate to use (on every frame by default) */
  118452. refreshRate: number;
  118453. /**
  118454. * Gets the hosting scene
  118455. * @returns a Scene
  118456. */
  118457. getScene(): Scene;
  118458. /** Gets the internal CubeTexture used to render to */
  118459. readonly cubeTexture: RenderTargetTexture;
  118460. /** Gets the list of meshes to render */
  118461. readonly renderList: Nullable<AbstractMesh[]>;
  118462. /**
  118463. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  118464. * @param mesh defines the mesh to attach to
  118465. */
  118466. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118467. /**
  118468. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  118469. * @param renderingGroupId The rendering group id corresponding to its index
  118470. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118471. */
  118472. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  118473. /**
  118474. * Clean all associated resources
  118475. */
  118476. dispose(): void;
  118477. /**
  118478. * Converts the reflection probe information to a readable string for debug purpose.
  118479. * @param fullDetails Supports for multiple levels of logging within scene loading
  118480. * @returns the human readable reflection probe info
  118481. */
  118482. toString(fullDetails?: boolean): string;
  118483. /**
  118484. * Get the class name of the relfection probe.
  118485. * @returns "ReflectionProbe"
  118486. */
  118487. getClassName(): string;
  118488. /**
  118489. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  118490. * @returns The JSON representation of the texture
  118491. */
  118492. serialize(): any;
  118493. /**
  118494. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  118495. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  118496. * @param scene Define the scene the parsed reflection probe should be instantiated in
  118497. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  118498. * @returns The parsed reflection probe if successful
  118499. */
  118500. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  118501. }
  118502. }
  118503. declare module BABYLON {
  118504. /** @hidden */
  118505. export var _BabylonLoaderRegistered: boolean;
  118506. }
  118507. declare module BABYLON {
  118508. /**
  118509. * The Physically based simple base material of BJS.
  118510. *
  118511. * This enables better naming and convention enforcements on top of the pbrMaterial.
  118512. * It is used as the base class for both the specGloss and metalRough conventions.
  118513. */
  118514. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  118515. /**
  118516. * Number of Simultaneous lights allowed on the material.
  118517. */
  118518. maxSimultaneousLights: number;
  118519. /**
  118520. * If sets to true, disables all the lights affecting the material.
  118521. */
  118522. disableLighting: boolean;
  118523. /**
  118524. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  118525. */
  118526. environmentTexture: BaseTexture;
  118527. /**
  118528. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118529. */
  118530. invertNormalMapX: boolean;
  118531. /**
  118532. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118533. */
  118534. invertNormalMapY: boolean;
  118535. /**
  118536. * Normal map used in the model.
  118537. */
  118538. normalTexture: BaseTexture;
  118539. /**
  118540. * Emissivie color used to self-illuminate the model.
  118541. */
  118542. emissiveColor: Color3;
  118543. /**
  118544. * Emissivie texture used to self-illuminate the model.
  118545. */
  118546. emissiveTexture: BaseTexture;
  118547. /**
  118548. * Occlusion Channel Strenght.
  118549. */
  118550. occlusionStrength: number;
  118551. /**
  118552. * Occlusion Texture of the material (adding extra occlusion effects).
  118553. */
  118554. occlusionTexture: BaseTexture;
  118555. /**
  118556. * Defines the alpha limits in alpha test mode.
  118557. */
  118558. alphaCutOff: number;
  118559. /**
  118560. * Gets the current double sided mode.
  118561. */
  118562. /**
  118563. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118564. */
  118565. doubleSided: boolean;
  118566. /**
  118567. * Stores the pre-calculated light information of a mesh in a texture.
  118568. */
  118569. lightmapTexture: BaseTexture;
  118570. /**
  118571. * If true, the light map contains occlusion information instead of lighting info.
  118572. */
  118573. useLightmapAsShadowmap: boolean;
  118574. /**
  118575. * Instantiates a new PBRMaterial instance.
  118576. *
  118577. * @param name The material name
  118578. * @param scene The scene the material will be use in.
  118579. */
  118580. constructor(name: string, scene: Scene);
  118581. getClassName(): string;
  118582. }
  118583. }
  118584. declare module BABYLON {
  118585. /**
  118586. * The PBR material of BJS following the metal roughness convention.
  118587. *
  118588. * This fits to the PBR convention in the GLTF definition:
  118589. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  118590. */
  118591. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  118592. /**
  118593. * The base color has two different interpretations depending on the value of metalness.
  118594. * When the material is a metal, the base color is the specific measured reflectance value
  118595. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  118596. * of the material.
  118597. */
  118598. baseColor: Color3;
  118599. /**
  118600. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  118601. * well as opacity information in the alpha channel.
  118602. */
  118603. baseTexture: BaseTexture;
  118604. /**
  118605. * Specifies the metallic scalar value of the material.
  118606. * Can also be used to scale the metalness values of the metallic texture.
  118607. */
  118608. metallic: number;
  118609. /**
  118610. * Specifies the roughness scalar value of the material.
  118611. * Can also be used to scale the roughness values of the metallic texture.
  118612. */
  118613. roughness: number;
  118614. /**
  118615. * Texture containing both the metallic value in the B channel and the
  118616. * roughness value in the G channel to keep better precision.
  118617. */
  118618. metallicRoughnessTexture: BaseTexture;
  118619. /**
  118620. * Instantiates a new PBRMetalRoughnessMaterial instance.
  118621. *
  118622. * @param name The material name
  118623. * @param scene The scene the material will be use in.
  118624. */
  118625. constructor(name: string, scene: Scene);
  118626. /**
  118627. * Return the currrent class name of the material.
  118628. */
  118629. getClassName(): string;
  118630. /**
  118631. * Makes a duplicate of the current material.
  118632. * @param name - name to use for the new material.
  118633. */
  118634. clone(name: string): PBRMetallicRoughnessMaterial;
  118635. /**
  118636. * Serialize the material to a parsable JSON object.
  118637. */
  118638. serialize(): any;
  118639. /**
  118640. * Parses a JSON object correponding to the serialize function.
  118641. */
  118642. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  118643. }
  118644. }
  118645. declare module BABYLON {
  118646. /**
  118647. * The PBR material of BJS following the specular glossiness convention.
  118648. *
  118649. * This fits to the PBR convention in the GLTF definition:
  118650. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  118651. */
  118652. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  118653. /**
  118654. * Specifies the diffuse color of the material.
  118655. */
  118656. diffuseColor: Color3;
  118657. /**
  118658. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  118659. * channel.
  118660. */
  118661. diffuseTexture: BaseTexture;
  118662. /**
  118663. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  118664. */
  118665. specularColor: Color3;
  118666. /**
  118667. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  118668. */
  118669. glossiness: number;
  118670. /**
  118671. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  118672. */
  118673. specularGlossinessTexture: BaseTexture;
  118674. /**
  118675. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  118676. *
  118677. * @param name The material name
  118678. * @param scene The scene the material will be use in.
  118679. */
  118680. constructor(name: string, scene: Scene);
  118681. /**
  118682. * Return the currrent class name of the material.
  118683. */
  118684. getClassName(): string;
  118685. /**
  118686. * Makes a duplicate of the current material.
  118687. * @param name - name to use for the new material.
  118688. */
  118689. clone(name: string): PBRSpecularGlossinessMaterial;
  118690. /**
  118691. * Serialize the material to a parsable JSON object.
  118692. */
  118693. serialize(): any;
  118694. /**
  118695. * Parses a JSON object correponding to the serialize function.
  118696. */
  118697. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  118698. }
  118699. }
  118700. declare module BABYLON {
  118701. /**
  118702. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  118703. * It can help converting any input color in a desired output one. This can then be used to create effects
  118704. * from sepia, black and white to sixties or futuristic rendering...
  118705. *
  118706. * The only supported format is currently 3dl.
  118707. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  118708. */
  118709. export class ColorGradingTexture extends BaseTexture {
  118710. /**
  118711. * The current texture matrix. (will always be identity in color grading texture)
  118712. */
  118713. private _textureMatrix;
  118714. /**
  118715. * The texture URL.
  118716. */
  118717. url: string;
  118718. /**
  118719. * Empty line regex stored for GC.
  118720. */
  118721. private static _noneEmptyLineRegex;
  118722. private _engine;
  118723. /**
  118724. * Instantiates a ColorGradingTexture from the following parameters.
  118725. *
  118726. * @param url The location of the color gradind data (currently only supporting 3dl)
  118727. * @param scene The scene the texture will be used in
  118728. */
  118729. constructor(url: string, scene: Scene);
  118730. /**
  118731. * Returns the texture matrix used in most of the material.
  118732. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  118733. */
  118734. getTextureMatrix(): Matrix;
  118735. /**
  118736. * Occurs when the file being loaded is a .3dl LUT file.
  118737. */
  118738. private load3dlTexture;
  118739. /**
  118740. * Starts the loading process of the texture.
  118741. */
  118742. private loadTexture;
  118743. /**
  118744. * Clones the color gradind texture.
  118745. */
  118746. clone(): ColorGradingTexture;
  118747. /**
  118748. * Called during delayed load for textures.
  118749. */
  118750. delayLoad(): void;
  118751. /**
  118752. * Parses a color grading texture serialized by Babylon.
  118753. * @param parsedTexture The texture information being parsedTexture
  118754. * @param scene The scene to load the texture in
  118755. * @param rootUrl The root url of the data assets to load
  118756. * @return A color gradind texture
  118757. */
  118758. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  118759. /**
  118760. * Serializes the LUT texture to json format.
  118761. */
  118762. serialize(): any;
  118763. }
  118764. }
  118765. declare module BABYLON {
  118766. /**
  118767. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  118768. */
  118769. export class EquiRectangularCubeTexture extends BaseTexture {
  118770. /** The six faces of the cube. */
  118771. private static _FacesMapping;
  118772. private _noMipmap;
  118773. private _onLoad;
  118774. private _onError;
  118775. /** The size of the cubemap. */
  118776. private _size;
  118777. /** The buffer of the image. */
  118778. private _buffer;
  118779. /** The width of the input image. */
  118780. private _width;
  118781. /** The height of the input image. */
  118782. private _height;
  118783. /** The URL to the image. */
  118784. url: string;
  118785. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  118786. coordinatesMode: number;
  118787. /**
  118788. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  118789. * @param url The location of the image
  118790. * @param scene The scene the texture will be used in
  118791. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118792. * @param noMipmap Forces to not generate the mipmap if true
  118793. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  118794. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  118795. * @param onLoad — defines a callback called when texture is loaded
  118796. * @param onError — defines a callback called if there is an error
  118797. */
  118798. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  118799. /**
  118800. * Load the image data, by putting the image on a canvas and extracting its buffer.
  118801. */
  118802. private loadImage;
  118803. /**
  118804. * Convert the image buffer into a cubemap and create a CubeTexture.
  118805. */
  118806. private loadTexture;
  118807. /**
  118808. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  118809. * @param buffer The ArrayBuffer that should be converted.
  118810. * @returns The buffer as Float32Array.
  118811. */
  118812. private getFloat32ArrayFromArrayBuffer;
  118813. /**
  118814. * Get the current class name of the texture useful for serialization or dynamic coding.
  118815. * @returns "EquiRectangularCubeTexture"
  118816. */
  118817. getClassName(): string;
  118818. /**
  118819. * Create a clone of the current EquiRectangularCubeTexture and return it.
  118820. * @returns A clone of the current EquiRectangularCubeTexture.
  118821. */
  118822. clone(): EquiRectangularCubeTexture;
  118823. }
  118824. }
  118825. declare module BABYLON {
  118826. /**
  118827. * Based on jsTGALoader - Javascript loader for TGA file
  118828. * By Vincent Thibault
  118829. * @see http://blog.robrowser.com/javascript-tga-loader.html
  118830. */
  118831. export class TGATools {
  118832. private static _TYPE_INDEXED;
  118833. private static _TYPE_RGB;
  118834. private static _TYPE_GREY;
  118835. private static _TYPE_RLE_INDEXED;
  118836. private static _TYPE_RLE_RGB;
  118837. private static _TYPE_RLE_GREY;
  118838. private static _ORIGIN_MASK;
  118839. private static _ORIGIN_SHIFT;
  118840. private static _ORIGIN_BL;
  118841. private static _ORIGIN_BR;
  118842. private static _ORIGIN_UL;
  118843. private static _ORIGIN_UR;
  118844. /**
  118845. * Gets the header of a TGA file
  118846. * @param data defines the TGA data
  118847. * @returns the header
  118848. */
  118849. static GetTGAHeader(data: Uint8Array): any;
  118850. /**
  118851. * Uploads TGA content to a Babylon Texture
  118852. * @hidden
  118853. */
  118854. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  118855. /** @hidden */
  118856. 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;
  118857. /** @hidden */
  118858. 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;
  118859. /** @hidden */
  118860. 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;
  118861. /** @hidden */
  118862. 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;
  118863. /** @hidden */
  118864. 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;
  118865. /** @hidden */
  118866. 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;
  118867. }
  118868. }
  118869. declare module BABYLON {
  118870. /**
  118871. * Implementation of the TGA Texture Loader.
  118872. * @hidden
  118873. */
  118874. export class _TGATextureLoader implements IInternalTextureLoader {
  118875. /**
  118876. * Defines wether the loader supports cascade loading the different faces.
  118877. */
  118878. readonly supportCascades: boolean;
  118879. /**
  118880. * This returns if the loader support the current file information.
  118881. * @param extension defines the file extension of the file being loaded
  118882. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118883. * @param fallback defines the fallback internal texture if any
  118884. * @param isBase64 defines whether the texture is encoded as a base64
  118885. * @param isBuffer defines whether the texture data are stored as a buffer
  118886. * @returns true if the loader can load the specified file
  118887. */
  118888. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118889. /**
  118890. * Transform the url before loading if required.
  118891. * @param rootUrl the url of the texture
  118892. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118893. * @returns the transformed texture
  118894. */
  118895. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118896. /**
  118897. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118898. * @param rootUrl the url of the texture
  118899. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118900. * @returns the fallback texture
  118901. */
  118902. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118903. /**
  118904. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118905. * @param data contains the texture data
  118906. * @param texture defines the BabylonJS internal texture
  118907. * @param createPolynomials will be true if polynomials have been requested
  118908. * @param onLoad defines the callback to trigger once the texture is ready
  118909. * @param onError defines the callback to trigger in case of error
  118910. */
  118911. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118912. /**
  118913. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118914. * @param data contains the texture data
  118915. * @param texture defines the BabylonJS internal texture
  118916. * @param callback defines the method to call once ready to upload
  118917. */
  118918. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118919. }
  118920. }
  118921. declare module BABYLON {
  118922. /**
  118923. * Info about the .basis files
  118924. */
  118925. class BasisFileInfo {
  118926. /**
  118927. * If the file has alpha
  118928. */
  118929. hasAlpha: boolean;
  118930. /**
  118931. * Info about each image of the basis file
  118932. */
  118933. images: Array<{
  118934. levels: Array<{
  118935. width: number;
  118936. height: number;
  118937. transcodedPixels: ArrayBufferView;
  118938. }>;
  118939. }>;
  118940. }
  118941. /**
  118942. * Result of transcoding a basis file
  118943. */
  118944. class TranscodeResult {
  118945. /**
  118946. * Info about the .basis file
  118947. */
  118948. fileInfo: BasisFileInfo;
  118949. /**
  118950. * Format to use when loading the file
  118951. */
  118952. format: number;
  118953. }
  118954. /**
  118955. * Configuration options for the Basis transcoder
  118956. */
  118957. export class BasisTranscodeConfiguration {
  118958. /**
  118959. * Supported compression formats used to determine the supported output format of the transcoder
  118960. */
  118961. supportedCompressionFormats?: {
  118962. /**
  118963. * etc1 compression format
  118964. */
  118965. etc1?: boolean;
  118966. /**
  118967. * s3tc compression format
  118968. */
  118969. s3tc?: boolean;
  118970. /**
  118971. * pvrtc compression format
  118972. */
  118973. pvrtc?: boolean;
  118974. /**
  118975. * etc2 compression format
  118976. */
  118977. etc2?: boolean;
  118978. };
  118979. /**
  118980. * If mipmap levels should be loaded for transcoded images (Default: true)
  118981. */
  118982. loadMipmapLevels?: boolean;
  118983. /**
  118984. * Index of a single image to load (Default: all images)
  118985. */
  118986. loadSingleImage?: number;
  118987. }
  118988. /**
  118989. * Used to load .Basis files
  118990. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  118991. */
  118992. export class BasisTools {
  118993. private static _IgnoreSupportedFormats;
  118994. /**
  118995. * URL to use when loading the basis transcoder
  118996. */
  118997. static JSModuleURL: string;
  118998. /**
  118999. * URL to use when loading the wasm module for the transcoder
  119000. */
  119001. static WasmModuleURL: string;
  119002. /**
  119003. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  119004. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  119005. * @returns internal format corresponding to the Basis format
  119006. */
  119007. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  119008. private static _WorkerPromise;
  119009. private static _Worker;
  119010. private static _actionId;
  119011. private static _CreateWorkerAsync;
  119012. /**
  119013. * Transcodes a loaded image file to compressed pixel data
  119014. * @param imageData image data to transcode
  119015. * @param config configuration options for the transcoding
  119016. * @returns a promise resulting in the transcoded image
  119017. */
  119018. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  119019. /**
  119020. * Loads a texture from the transcode result
  119021. * @param texture texture load to
  119022. * @param transcodeResult the result of transcoding the basis file to load from
  119023. */
  119024. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  119025. }
  119026. }
  119027. declare module BABYLON {
  119028. /**
  119029. * Loader for .basis file format
  119030. */
  119031. export class _BasisTextureLoader implements IInternalTextureLoader {
  119032. /**
  119033. * Defines whether the loader supports cascade loading the different faces.
  119034. */
  119035. readonly supportCascades: boolean;
  119036. /**
  119037. * This returns if the loader support the current file information.
  119038. * @param extension defines the file extension of the file being loaded
  119039. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119040. * @param fallback defines the fallback internal texture if any
  119041. * @param isBase64 defines whether the texture is encoded as a base64
  119042. * @param isBuffer defines whether the texture data are stored as a buffer
  119043. * @returns true if the loader can load the specified file
  119044. */
  119045. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119046. /**
  119047. * Transform the url before loading if required.
  119048. * @param rootUrl the url of the texture
  119049. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119050. * @returns the transformed texture
  119051. */
  119052. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119053. /**
  119054. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119055. * @param rootUrl the url of the texture
  119056. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119057. * @returns the fallback texture
  119058. */
  119059. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119060. /**
  119061. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  119062. * @param data contains the texture data
  119063. * @param texture defines the BabylonJS internal texture
  119064. * @param createPolynomials will be true if polynomials have been requested
  119065. * @param onLoad defines the callback to trigger once the texture is ready
  119066. * @param onError defines the callback to trigger in case of error
  119067. */
  119068. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119069. /**
  119070. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119071. * @param data contains the texture data
  119072. * @param texture defines the BabylonJS internal texture
  119073. * @param callback defines the method to call once ready to upload
  119074. */
  119075. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119076. }
  119077. }
  119078. declare module BABYLON {
  119079. /**
  119080. * 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.
  119081. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119082. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119083. */
  119084. export class CustomProceduralTexture extends ProceduralTexture {
  119085. private _animate;
  119086. private _time;
  119087. private _config;
  119088. private _texturePath;
  119089. /**
  119090. * Instantiates a new Custom Procedural Texture.
  119091. * 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.
  119092. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119093. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119094. * @param name Define the name of the texture
  119095. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  119096. * @param size Define the size of the texture to create
  119097. * @param scene Define the scene the texture belongs to
  119098. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  119099. * @param generateMipMaps Define if the texture should creates mip maps or not
  119100. */
  119101. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119102. private _loadJson;
  119103. /**
  119104. * Is the texture ready to be used ? (rendered at least once)
  119105. * @returns true if ready, otherwise, false.
  119106. */
  119107. isReady(): boolean;
  119108. /**
  119109. * Render the texture to its associated render target.
  119110. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  119111. */
  119112. render(useCameraPostProcess?: boolean): void;
  119113. /**
  119114. * Update the list of dependant textures samplers in the shader.
  119115. */
  119116. updateTextures(): void;
  119117. /**
  119118. * Update the uniform values of the procedural texture in the shader.
  119119. */
  119120. updateShaderUniforms(): void;
  119121. /**
  119122. * Define if the texture animates or not.
  119123. */
  119124. animate: boolean;
  119125. }
  119126. }
  119127. declare module BABYLON {
  119128. /** @hidden */
  119129. export var noisePixelShader: {
  119130. name: string;
  119131. shader: string;
  119132. };
  119133. }
  119134. declare module BABYLON {
  119135. /**
  119136. * Class used to generate noise procedural textures
  119137. */
  119138. export class NoiseProceduralTexture extends ProceduralTexture {
  119139. private _time;
  119140. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  119141. brightness: number;
  119142. /** Defines the number of octaves to process */
  119143. octaves: number;
  119144. /** Defines the level of persistence (0.8 by default) */
  119145. persistence: number;
  119146. /** Gets or sets animation speed factor (default is 1) */
  119147. animationSpeedFactor: number;
  119148. /**
  119149. * Creates a new NoiseProceduralTexture
  119150. * @param name defines the name fo the texture
  119151. * @param size defines the size of the texture (default is 256)
  119152. * @param scene defines the hosting scene
  119153. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  119154. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  119155. */
  119156. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119157. private _updateShaderUniforms;
  119158. protected _getDefines(): string;
  119159. /** Generate the current state of the procedural texture */
  119160. render(useCameraPostProcess?: boolean): void;
  119161. /**
  119162. * Serializes this noise procedural texture
  119163. * @returns a serialized noise procedural texture object
  119164. */
  119165. serialize(): any;
  119166. /**
  119167. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  119168. * @param parsedTexture defines parsed texture data
  119169. * @param scene defines the current scene
  119170. * @param rootUrl defines the root URL containing noise procedural texture information
  119171. * @returns a parsed NoiseProceduralTexture
  119172. */
  119173. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  119174. }
  119175. }
  119176. declare module BABYLON {
  119177. /**
  119178. * Raw cube texture where the raw buffers are passed in
  119179. */
  119180. export class RawCubeTexture extends CubeTexture {
  119181. /**
  119182. * Creates a cube texture where the raw buffers are passed in.
  119183. * @param scene defines the scene the texture is attached to
  119184. * @param data defines the array of data to use to create each face
  119185. * @param size defines the size of the textures
  119186. * @param format defines the format of the data
  119187. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  119188. * @param generateMipMaps defines if the engine should generate the mip levels
  119189. * @param invertY defines if data must be stored with Y axis inverted
  119190. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  119191. * @param compression defines the compression used (null by default)
  119192. */
  119193. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  119194. /**
  119195. * Updates the raw cube texture.
  119196. * @param data defines the data to store
  119197. * @param format defines the data format
  119198. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119199. * @param invertY defines if data must be stored with Y axis inverted
  119200. * @param compression defines the compression used (null by default)
  119201. * @param level defines which level of the texture to update
  119202. */
  119203. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  119204. /**
  119205. * Updates a raw cube texture with RGBD encoded data.
  119206. * @param data defines the array of data [mipmap][face] to use to create each face
  119207. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  119208. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  119209. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  119210. * @returns a promsie that resolves when the operation is complete
  119211. */
  119212. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  119213. /**
  119214. * Clones the raw cube texture.
  119215. * @return a new cube texture
  119216. */
  119217. clone(): CubeTexture;
  119218. /** @hidden */
  119219. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  119220. }
  119221. }
  119222. declare module BABYLON {
  119223. /**
  119224. * Class used to store 3D textures containing user data
  119225. */
  119226. export class RawTexture3D extends Texture {
  119227. /** Gets or sets the texture format to use */
  119228. format: number;
  119229. private _engine;
  119230. /**
  119231. * Create a new RawTexture3D
  119232. * @param data defines the data of the texture
  119233. * @param width defines the width of the texture
  119234. * @param height defines the height of the texture
  119235. * @param depth defines the depth of the texture
  119236. * @param format defines the texture format to use
  119237. * @param scene defines the hosting scene
  119238. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  119239. * @param invertY defines if texture must be stored with Y axis inverted
  119240. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  119241. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  119242. */
  119243. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  119244. /** Gets or sets the texture format to use */
  119245. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  119246. /**
  119247. * Update the texture with new data
  119248. * @param data defines the data to store in the texture
  119249. */
  119250. update(data: ArrayBufferView): void;
  119251. }
  119252. }
  119253. declare module BABYLON {
  119254. /**
  119255. * Creates a refraction texture used by refraction channel of the standard material.
  119256. * It is like a mirror but to see through a material.
  119257. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119258. */
  119259. export class RefractionTexture extends RenderTargetTexture {
  119260. /**
  119261. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  119262. * 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.
  119263. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119264. */
  119265. refractionPlane: Plane;
  119266. /**
  119267. * Define how deep under the surface we should see.
  119268. */
  119269. depth: number;
  119270. /**
  119271. * Creates a refraction texture used by refraction channel of the standard material.
  119272. * It is like a mirror but to see through a material.
  119273. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119274. * @param name Define the texture name
  119275. * @param size Define the size of the underlying texture
  119276. * @param scene Define the scene the refraction belongs to
  119277. * @param generateMipMaps Define if we need to generate mips level for the refraction
  119278. */
  119279. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  119280. /**
  119281. * Clone the refraction texture.
  119282. * @returns the cloned texture
  119283. */
  119284. clone(): RefractionTexture;
  119285. /**
  119286. * Serialize the texture to a JSON representation you could use in Parse later on
  119287. * @returns the serialized JSON representation
  119288. */
  119289. serialize(): any;
  119290. }
  119291. }
  119292. declare module BABYLON {
  119293. /**
  119294. * Defines the options related to the creation of an HtmlElementTexture
  119295. */
  119296. export interface IHtmlElementTextureOptions {
  119297. /**
  119298. * Defines wether mip maps should be created or not.
  119299. */
  119300. generateMipMaps?: boolean;
  119301. /**
  119302. * Defines the sampling mode of the texture.
  119303. */
  119304. samplingMode?: number;
  119305. /**
  119306. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  119307. */
  119308. engine: Nullable<ThinEngine>;
  119309. /**
  119310. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  119311. */
  119312. scene: Nullable<Scene>;
  119313. }
  119314. /**
  119315. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  119316. * To be as efficient as possible depending on your constraints nothing aside the first upload
  119317. * is automatically managed.
  119318. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  119319. * in your application.
  119320. *
  119321. * As the update is not automatic, you need to call them manually.
  119322. */
  119323. export class HtmlElementTexture extends BaseTexture {
  119324. /**
  119325. * The texture URL.
  119326. */
  119327. element: HTMLVideoElement | HTMLCanvasElement;
  119328. private static readonly DefaultOptions;
  119329. private _textureMatrix;
  119330. private _engine;
  119331. private _isVideo;
  119332. private _generateMipMaps;
  119333. private _samplingMode;
  119334. /**
  119335. * Instantiates a HtmlElementTexture from the following parameters.
  119336. *
  119337. * @param name Defines the name of the texture
  119338. * @param element Defines the video or canvas the texture is filled with
  119339. * @param options Defines the other none mandatory texture creation options
  119340. */
  119341. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  119342. private _createInternalTexture;
  119343. /**
  119344. * Returns the texture matrix used in most of the material.
  119345. */
  119346. getTextureMatrix(): Matrix;
  119347. /**
  119348. * Updates the content of the texture.
  119349. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  119350. */
  119351. update(invertY?: Nullable<boolean>): void;
  119352. }
  119353. }
  119354. declare module BABYLON {
  119355. /**
  119356. * Enum used to define the target of a block
  119357. */
  119358. export enum NodeMaterialBlockTargets {
  119359. /** Vertex shader */
  119360. Vertex = 1,
  119361. /** Fragment shader */
  119362. Fragment = 2,
  119363. /** Neutral */
  119364. Neutral = 4,
  119365. /** Vertex and Fragment */
  119366. VertexAndFragment = 3
  119367. }
  119368. }
  119369. declare module BABYLON {
  119370. /**
  119371. * Defines the kind of connection point for node based material
  119372. */
  119373. export enum NodeMaterialBlockConnectionPointTypes {
  119374. /** Float */
  119375. Float = 1,
  119376. /** Int */
  119377. Int = 2,
  119378. /** Vector2 */
  119379. Vector2 = 4,
  119380. /** Vector3 */
  119381. Vector3 = 8,
  119382. /** Vector4 */
  119383. Vector4 = 16,
  119384. /** Color3 */
  119385. Color3 = 32,
  119386. /** Color4 */
  119387. Color4 = 64,
  119388. /** Matrix */
  119389. Matrix = 128,
  119390. /** Detect type based on connection */
  119391. AutoDetect = 1024,
  119392. /** Output type that will be defined by input type */
  119393. BasedOnInput = 2048
  119394. }
  119395. }
  119396. declare module BABYLON {
  119397. /**
  119398. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  119399. */
  119400. export enum NodeMaterialBlockConnectionPointMode {
  119401. /** Value is an uniform */
  119402. Uniform = 0,
  119403. /** Value is a mesh attribute */
  119404. Attribute = 1,
  119405. /** Value is a varying between vertex and fragment shaders */
  119406. Varying = 2,
  119407. /** Mode is undefined */
  119408. Undefined = 3
  119409. }
  119410. }
  119411. declare module BABYLON {
  119412. /**
  119413. * Enum used to define system values e.g. values automatically provided by the system
  119414. */
  119415. export enum NodeMaterialSystemValues {
  119416. /** World */
  119417. World = 1,
  119418. /** View */
  119419. View = 2,
  119420. /** Projection */
  119421. Projection = 3,
  119422. /** ViewProjection */
  119423. ViewProjection = 4,
  119424. /** WorldView */
  119425. WorldView = 5,
  119426. /** WorldViewProjection */
  119427. WorldViewProjection = 6,
  119428. /** CameraPosition */
  119429. CameraPosition = 7,
  119430. /** Fog Color */
  119431. FogColor = 8,
  119432. /** Delta time */
  119433. DeltaTime = 9
  119434. }
  119435. }
  119436. declare module BABYLON {
  119437. /**
  119438. * Root class for all node material optimizers
  119439. */
  119440. export class NodeMaterialOptimizer {
  119441. /**
  119442. * Function used to optimize a NodeMaterial graph
  119443. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  119444. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  119445. */
  119446. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  119447. }
  119448. }
  119449. declare module BABYLON {
  119450. /**
  119451. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  119452. */
  119453. export class TransformBlock extends NodeMaterialBlock {
  119454. /**
  119455. * Defines the value to use to complement W value to transform it to a Vector4
  119456. */
  119457. complementW: number;
  119458. /**
  119459. * Defines the value to use to complement z value to transform it to a Vector4
  119460. */
  119461. complementZ: number;
  119462. /**
  119463. * Creates a new TransformBlock
  119464. * @param name defines the block name
  119465. */
  119466. constructor(name: string);
  119467. /**
  119468. * Gets the current class name
  119469. * @returns the class name
  119470. */
  119471. getClassName(): string;
  119472. /**
  119473. * Gets the vector input
  119474. */
  119475. readonly vector: NodeMaterialConnectionPoint;
  119476. /**
  119477. * Gets the output component
  119478. */
  119479. readonly output: NodeMaterialConnectionPoint;
  119480. /**
  119481. * Gets the matrix transform input
  119482. */
  119483. readonly transform: NodeMaterialConnectionPoint;
  119484. protected _buildBlock(state: NodeMaterialBuildState): this;
  119485. serialize(): any;
  119486. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119487. protected _dumpPropertiesCode(): string;
  119488. }
  119489. }
  119490. declare module BABYLON {
  119491. /**
  119492. * Block used to output the vertex position
  119493. */
  119494. export class VertexOutputBlock extends NodeMaterialBlock {
  119495. /**
  119496. * Creates a new VertexOutputBlock
  119497. * @param name defines the block name
  119498. */
  119499. constructor(name: string);
  119500. /**
  119501. * Gets the current class name
  119502. * @returns the class name
  119503. */
  119504. getClassName(): string;
  119505. /**
  119506. * Gets the vector input component
  119507. */
  119508. readonly vector: NodeMaterialConnectionPoint;
  119509. protected _buildBlock(state: NodeMaterialBuildState): this;
  119510. }
  119511. }
  119512. declare module BABYLON {
  119513. /**
  119514. * Block used to output the final color
  119515. */
  119516. export class FragmentOutputBlock extends NodeMaterialBlock {
  119517. /**
  119518. * Create a new FragmentOutputBlock
  119519. * @param name defines the block name
  119520. */
  119521. constructor(name: string);
  119522. /**
  119523. * Gets the current class name
  119524. * @returns the class name
  119525. */
  119526. getClassName(): string;
  119527. /**
  119528. * Gets the rgba input component
  119529. */
  119530. readonly rgba: NodeMaterialConnectionPoint;
  119531. /**
  119532. * Gets the rgb input component
  119533. */
  119534. readonly rgb: NodeMaterialConnectionPoint;
  119535. /**
  119536. * Gets the a input component
  119537. */
  119538. readonly a: NodeMaterialConnectionPoint;
  119539. protected _buildBlock(state: NodeMaterialBuildState): this;
  119540. }
  119541. }
  119542. declare module BABYLON {
  119543. /**
  119544. * Block used to read a reflection texture from a sampler
  119545. */
  119546. export class ReflectionTextureBlock extends NodeMaterialBlock {
  119547. private _define3DName;
  119548. private _defineCubicName;
  119549. private _defineExplicitName;
  119550. private _defineProjectionName;
  119551. private _defineLocalCubicName;
  119552. private _defineSphericalName;
  119553. private _definePlanarName;
  119554. private _defineEquirectangularName;
  119555. private _defineMirroredEquirectangularFixedName;
  119556. private _defineEquirectangularFixedName;
  119557. private _defineSkyboxName;
  119558. private _cubeSamplerName;
  119559. private _2DSamplerName;
  119560. private _positionUVWName;
  119561. private _directionWName;
  119562. private _reflectionCoordsName;
  119563. private _reflection2DCoordsName;
  119564. private _reflectionColorName;
  119565. private _reflectionMatrixName;
  119566. /**
  119567. * Gets or sets the texture associated with the node
  119568. */
  119569. texture: Nullable<BaseTexture>;
  119570. /**
  119571. * Create a new TextureBlock
  119572. * @param name defines the block name
  119573. */
  119574. constructor(name: string);
  119575. /**
  119576. * Gets the current class name
  119577. * @returns the class name
  119578. */
  119579. getClassName(): string;
  119580. /**
  119581. * Gets the world position input component
  119582. */
  119583. readonly position: NodeMaterialConnectionPoint;
  119584. /**
  119585. * Gets the world position input component
  119586. */
  119587. readonly worldPosition: NodeMaterialConnectionPoint;
  119588. /**
  119589. * Gets the world normal input component
  119590. */
  119591. readonly worldNormal: NodeMaterialConnectionPoint;
  119592. /**
  119593. * Gets the world input component
  119594. */
  119595. readonly world: NodeMaterialConnectionPoint;
  119596. /**
  119597. * Gets the camera (or eye) position component
  119598. */
  119599. readonly cameraPosition: NodeMaterialConnectionPoint;
  119600. /**
  119601. * Gets the view input component
  119602. */
  119603. readonly view: NodeMaterialConnectionPoint;
  119604. /**
  119605. * Gets the rgb output component
  119606. */
  119607. readonly rgb: NodeMaterialConnectionPoint;
  119608. /**
  119609. * Gets the r output component
  119610. */
  119611. readonly r: NodeMaterialConnectionPoint;
  119612. /**
  119613. * Gets the g output component
  119614. */
  119615. readonly g: NodeMaterialConnectionPoint;
  119616. /**
  119617. * Gets the b output component
  119618. */
  119619. readonly b: NodeMaterialConnectionPoint;
  119620. autoConfigure(material: NodeMaterial): void;
  119621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119622. isReady(): boolean;
  119623. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119624. private _injectVertexCode;
  119625. private _writeOutput;
  119626. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119627. serialize(): any;
  119628. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119629. }
  119630. }
  119631. declare module BABYLON {
  119632. /**
  119633. * Interface used to configure the node material editor
  119634. */
  119635. export interface INodeMaterialEditorOptions {
  119636. /** Define the URl to load node editor script */
  119637. editorURL?: string;
  119638. }
  119639. /** @hidden */
  119640. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  119641. /** BONES */
  119642. NUM_BONE_INFLUENCERS: number;
  119643. BonesPerMesh: number;
  119644. BONETEXTURE: boolean;
  119645. /** MORPH TARGETS */
  119646. MORPHTARGETS: boolean;
  119647. MORPHTARGETS_NORMAL: boolean;
  119648. MORPHTARGETS_TANGENT: boolean;
  119649. MORPHTARGETS_UV: boolean;
  119650. NUM_MORPH_INFLUENCERS: number;
  119651. /** IMAGE PROCESSING */
  119652. IMAGEPROCESSING: boolean;
  119653. VIGNETTE: boolean;
  119654. VIGNETTEBLENDMODEMULTIPLY: boolean;
  119655. VIGNETTEBLENDMODEOPAQUE: boolean;
  119656. TONEMAPPING: boolean;
  119657. TONEMAPPING_ACES: boolean;
  119658. CONTRAST: boolean;
  119659. EXPOSURE: boolean;
  119660. COLORCURVES: boolean;
  119661. COLORGRADING: boolean;
  119662. COLORGRADING3D: boolean;
  119663. SAMPLER3DGREENDEPTH: boolean;
  119664. SAMPLER3DBGRMAP: boolean;
  119665. IMAGEPROCESSINGPOSTPROCESS: boolean;
  119666. /** MISC. */
  119667. BUMPDIRECTUV: number;
  119668. constructor();
  119669. setValue(name: string, value: boolean): void;
  119670. }
  119671. /**
  119672. * Class used to configure NodeMaterial
  119673. */
  119674. export interface INodeMaterialOptions {
  119675. /**
  119676. * Defines if blocks should emit comments
  119677. */
  119678. emitComments: boolean;
  119679. }
  119680. /**
  119681. * Class used to create a node based material built by assembling shader blocks
  119682. */
  119683. export class NodeMaterial extends PushMaterial {
  119684. private static _BuildIdGenerator;
  119685. private _options;
  119686. private _vertexCompilationState;
  119687. private _fragmentCompilationState;
  119688. private _sharedData;
  119689. private _buildId;
  119690. private _buildWasSuccessful;
  119691. private _cachedWorldViewMatrix;
  119692. private _cachedWorldViewProjectionMatrix;
  119693. private _optimizers;
  119694. private _animationFrame;
  119695. /** Define the URl to load node editor script */
  119696. static EditorURL: string;
  119697. private BJSNODEMATERIALEDITOR;
  119698. /** Get the inspector from bundle or global */
  119699. private _getGlobalNodeMaterialEditor;
  119700. /**
  119701. * 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)
  119702. */
  119703. ignoreAlpha: boolean;
  119704. /**
  119705. * Defines the maximum number of lights that can be used in the material
  119706. */
  119707. maxSimultaneousLights: number;
  119708. /**
  119709. * Observable raised when the material is built
  119710. */
  119711. onBuildObservable: Observable<NodeMaterial>;
  119712. /**
  119713. * Gets or sets the root nodes of the material vertex shader
  119714. */
  119715. _vertexOutputNodes: NodeMaterialBlock[];
  119716. /**
  119717. * Gets or sets the root nodes of the material fragment (pixel) shader
  119718. */
  119719. _fragmentOutputNodes: NodeMaterialBlock[];
  119720. /** Gets or sets options to control the node material overall behavior */
  119721. options: INodeMaterialOptions;
  119722. /**
  119723. * Default configuration related to image processing available in the standard Material.
  119724. */
  119725. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119726. /**
  119727. * Gets the image processing configuration used either in this material.
  119728. */
  119729. /**
  119730. * Sets the Default image processing configuration used either in the this material.
  119731. *
  119732. * If sets to null, the scene one is in use.
  119733. */
  119734. imageProcessingConfiguration: ImageProcessingConfiguration;
  119735. /**
  119736. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  119737. */
  119738. attachedBlocks: NodeMaterialBlock[];
  119739. /**
  119740. * Create a new node based material
  119741. * @param name defines the material name
  119742. * @param scene defines the hosting scene
  119743. * @param options defines creation option
  119744. */
  119745. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  119746. /**
  119747. * Gets the current class name of the material e.g. "NodeMaterial"
  119748. * @returns the class name
  119749. */
  119750. getClassName(): string;
  119751. /**
  119752. * Keep track of the image processing observer to allow dispose and replace.
  119753. */
  119754. private _imageProcessingObserver;
  119755. /**
  119756. * Attaches a new image processing configuration to the Standard Material.
  119757. * @param configuration
  119758. */
  119759. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  119760. /**
  119761. * Get a block by its name
  119762. * @param name defines the name of the block to retrieve
  119763. * @returns the required block or null if not found
  119764. */
  119765. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  119766. /**
  119767. * Get a block by its name
  119768. * @param predicate defines the predicate used to find the good candidate
  119769. * @returns the required block or null if not found
  119770. */
  119771. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  119772. /**
  119773. * Get an input block by its name
  119774. * @param predicate defines the predicate used to find the good candidate
  119775. * @returns the required input block or null if not found
  119776. */
  119777. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  119778. /**
  119779. * Gets the list of input blocks attached to this material
  119780. * @returns an array of InputBlocks
  119781. */
  119782. getInputBlocks(): InputBlock[];
  119783. /**
  119784. * Adds a new optimizer to the list of optimizers
  119785. * @param optimizer defines the optimizers to add
  119786. * @returns the current material
  119787. */
  119788. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119789. /**
  119790. * Remove an optimizer from the list of optimizers
  119791. * @param optimizer defines the optimizers to remove
  119792. * @returns the current material
  119793. */
  119794. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119795. /**
  119796. * Add a new block to the list of output nodes
  119797. * @param node defines the node to add
  119798. * @returns the current material
  119799. */
  119800. addOutputNode(node: NodeMaterialBlock): this;
  119801. /**
  119802. * Remove a block from the list of root nodes
  119803. * @param node defines the node to remove
  119804. * @returns the current material
  119805. */
  119806. removeOutputNode(node: NodeMaterialBlock): this;
  119807. private _addVertexOutputNode;
  119808. private _removeVertexOutputNode;
  119809. private _addFragmentOutputNode;
  119810. private _removeFragmentOutputNode;
  119811. /**
  119812. * Specifies if the material will require alpha blending
  119813. * @returns a boolean specifying if alpha blending is needed
  119814. */
  119815. needAlphaBlending(): boolean;
  119816. /**
  119817. * Specifies if this material should be rendered in alpha test mode
  119818. * @returns a boolean specifying if an alpha test is needed.
  119819. */
  119820. needAlphaTesting(): boolean;
  119821. private _initializeBlock;
  119822. private _resetDualBlocks;
  119823. /**
  119824. * Build the material and generates the inner effect
  119825. * @param verbose defines if the build should log activity
  119826. */
  119827. build(verbose?: boolean): void;
  119828. /**
  119829. * Runs an otpimization phase to try to improve the shader code
  119830. */
  119831. optimize(): void;
  119832. private _prepareDefinesForAttributes;
  119833. /**
  119834. * Get if the submesh is ready to be used and all its information available.
  119835. * Child classes can use it to update shaders
  119836. * @param mesh defines the mesh to check
  119837. * @param subMesh defines which submesh to check
  119838. * @param useInstances specifies that instances should be used
  119839. * @returns a boolean indicating that the submesh is ready or not
  119840. */
  119841. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119842. /**
  119843. * Get a string representing the shaders built by the current node graph
  119844. */
  119845. readonly compiledShaders: string;
  119846. /**
  119847. * Binds the world matrix to the material
  119848. * @param world defines the world transformation matrix
  119849. */
  119850. bindOnlyWorldMatrix(world: Matrix): void;
  119851. /**
  119852. * Binds the submesh to this material by preparing the effect and shader to draw
  119853. * @param world defines the world transformation matrix
  119854. * @param mesh defines the mesh containing the submesh
  119855. * @param subMesh defines the submesh to bind the material to
  119856. */
  119857. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119858. /**
  119859. * Gets the active textures from the material
  119860. * @returns an array of textures
  119861. */
  119862. getActiveTextures(): BaseTexture[];
  119863. /**
  119864. * Gets the list of texture blocks
  119865. * @returns an array of texture blocks
  119866. */
  119867. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  119868. /**
  119869. * Specifies if the material uses a texture
  119870. * @param texture defines the texture to check against the material
  119871. * @returns a boolean specifying if the material uses the texture
  119872. */
  119873. hasTexture(texture: BaseTexture): boolean;
  119874. /**
  119875. * Disposes the material
  119876. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  119877. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  119878. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  119879. */
  119880. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  119881. /** Creates the node editor window. */
  119882. private _createNodeEditor;
  119883. /**
  119884. * Launch the node material editor
  119885. * @param config Define the configuration of the editor
  119886. * @return a promise fulfilled when the node editor is visible
  119887. */
  119888. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  119889. /**
  119890. * Clear the current material
  119891. */
  119892. clear(): void;
  119893. /**
  119894. * Clear the current material and set it to a default state
  119895. */
  119896. setToDefault(): void;
  119897. /**
  119898. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  119899. * @param url defines the url to load from
  119900. * @returns a promise that will fullfil when the material is fully loaded
  119901. */
  119902. loadAsync(url: string): Promise<unknown>;
  119903. private _gatherBlocks;
  119904. /**
  119905. * Generate a string containing the code declaration required to create an equivalent of this material
  119906. * @returns a string
  119907. */
  119908. generateCode(): string;
  119909. /**
  119910. * Serializes this material in a JSON representation
  119911. * @returns the serialized material object
  119912. */
  119913. serialize(): any;
  119914. private _restoreConnections;
  119915. /**
  119916. * Clear the current graph and load a new one from a serialization object
  119917. * @param source defines the JSON representation of the material
  119918. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119919. */
  119920. loadFromSerialization(source: any, rootUrl?: string): void;
  119921. /**
  119922. * Creates a node material from parsed material data
  119923. * @param source defines the JSON representation of the material
  119924. * @param scene defines the hosting scene
  119925. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119926. * @returns a new node material
  119927. */
  119928. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  119929. /**
  119930. * Creates a new node material set to default basic configuration
  119931. * @param name defines the name of the material
  119932. * @param scene defines the hosting scene
  119933. * @returns a new NodeMaterial
  119934. */
  119935. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  119936. }
  119937. }
  119938. declare module BABYLON {
  119939. /**
  119940. * Block used to read a texture from a sampler
  119941. */
  119942. export class TextureBlock extends NodeMaterialBlock {
  119943. private _defineName;
  119944. private _linearDefineName;
  119945. private _samplerName;
  119946. private _transformedUVName;
  119947. private _textureTransformName;
  119948. private _textureInfoName;
  119949. private _mainUVName;
  119950. private _mainUVDefineName;
  119951. /**
  119952. * Gets or sets the texture associated with the node
  119953. */
  119954. texture: Nullable<Texture>;
  119955. /**
  119956. * Create a new TextureBlock
  119957. * @param name defines the block name
  119958. */
  119959. constructor(name: string);
  119960. /**
  119961. * Gets the current class name
  119962. * @returns the class name
  119963. */
  119964. getClassName(): string;
  119965. /**
  119966. * Gets the uv input component
  119967. */
  119968. readonly uv: NodeMaterialConnectionPoint;
  119969. /**
  119970. * Gets the rgba output component
  119971. */
  119972. readonly rgba: NodeMaterialConnectionPoint;
  119973. /**
  119974. * Gets the rgb output component
  119975. */
  119976. readonly rgb: NodeMaterialConnectionPoint;
  119977. /**
  119978. * Gets the r output component
  119979. */
  119980. readonly r: NodeMaterialConnectionPoint;
  119981. /**
  119982. * Gets the g output component
  119983. */
  119984. readonly g: NodeMaterialConnectionPoint;
  119985. /**
  119986. * Gets the b output component
  119987. */
  119988. readonly b: NodeMaterialConnectionPoint;
  119989. /**
  119990. * Gets the a output component
  119991. */
  119992. readonly a: NodeMaterialConnectionPoint;
  119993. readonly target: NodeMaterialBlockTargets;
  119994. autoConfigure(material: NodeMaterial): void;
  119995. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119996. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119997. isReady(): boolean;
  119998. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119999. private readonly _isMixed;
  120000. private _injectVertexCode;
  120001. private _writeOutput;
  120002. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120003. protected _dumpPropertiesCode(): string;
  120004. serialize(): any;
  120005. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120006. }
  120007. }
  120008. declare module BABYLON {
  120009. /**
  120010. * Class used to store shared data between 2 NodeMaterialBuildState
  120011. */
  120012. export class NodeMaterialBuildStateSharedData {
  120013. /**
  120014. * Gets the list of emitted varyings
  120015. */
  120016. temps: string[];
  120017. /**
  120018. * Gets the list of emitted varyings
  120019. */
  120020. varyings: string[];
  120021. /**
  120022. * Gets the varying declaration string
  120023. */
  120024. varyingDeclaration: string;
  120025. /**
  120026. * Input blocks
  120027. */
  120028. inputBlocks: InputBlock[];
  120029. /**
  120030. * Input blocks
  120031. */
  120032. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  120033. /**
  120034. * Bindable blocks (Blocks that need to set data to the effect)
  120035. */
  120036. bindableBlocks: NodeMaterialBlock[];
  120037. /**
  120038. * List of blocks that can provide a compilation fallback
  120039. */
  120040. blocksWithFallbacks: NodeMaterialBlock[];
  120041. /**
  120042. * List of blocks that can provide a define update
  120043. */
  120044. blocksWithDefines: NodeMaterialBlock[];
  120045. /**
  120046. * List of blocks that can provide a repeatable content
  120047. */
  120048. repeatableContentBlocks: NodeMaterialBlock[];
  120049. /**
  120050. * List of blocks that can provide a dynamic list of uniforms
  120051. */
  120052. dynamicUniformBlocks: NodeMaterialBlock[];
  120053. /**
  120054. * List of blocks that can block the isReady function for the material
  120055. */
  120056. blockingBlocks: NodeMaterialBlock[];
  120057. /**
  120058. * Gets the list of animated inputs
  120059. */
  120060. animatedInputs: InputBlock[];
  120061. /**
  120062. * Build Id used to avoid multiple recompilations
  120063. */
  120064. buildId: number;
  120065. /** List of emitted variables */
  120066. variableNames: {
  120067. [key: string]: number;
  120068. };
  120069. /** List of emitted defines */
  120070. defineNames: {
  120071. [key: string]: number;
  120072. };
  120073. /** Should emit comments? */
  120074. emitComments: boolean;
  120075. /** Emit build activity */
  120076. verbose: boolean;
  120077. /** Gets or sets the hosting scene */
  120078. scene: Scene;
  120079. /**
  120080. * Gets the compilation hints emitted at compilation time
  120081. */
  120082. hints: {
  120083. needWorldViewMatrix: boolean;
  120084. needWorldViewProjectionMatrix: boolean;
  120085. needAlphaBlending: boolean;
  120086. needAlphaTesting: boolean;
  120087. };
  120088. /**
  120089. * List of compilation checks
  120090. */
  120091. checks: {
  120092. emitVertex: boolean;
  120093. emitFragment: boolean;
  120094. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  120095. };
  120096. /** Creates a new shared data */
  120097. constructor();
  120098. /**
  120099. * Emits console errors and exceptions if there is a failing check
  120100. */
  120101. emitErrors(): void;
  120102. }
  120103. }
  120104. declare module BABYLON {
  120105. /**
  120106. * Class used to store node based material build state
  120107. */
  120108. export class NodeMaterialBuildState {
  120109. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  120110. supportUniformBuffers: boolean;
  120111. /**
  120112. * Gets the list of emitted attributes
  120113. */
  120114. attributes: string[];
  120115. /**
  120116. * Gets the list of emitted uniforms
  120117. */
  120118. uniforms: string[];
  120119. /**
  120120. * Gets the list of emitted constants
  120121. */
  120122. constants: string[];
  120123. /**
  120124. * Gets the list of emitted uniform buffers
  120125. */
  120126. uniformBuffers: string[];
  120127. /**
  120128. * Gets the list of emitted samplers
  120129. */
  120130. samplers: string[];
  120131. /**
  120132. * Gets the list of emitted functions
  120133. */
  120134. functions: {
  120135. [key: string]: string;
  120136. };
  120137. /**
  120138. * Gets the list of emitted extensions
  120139. */
  120140. extensions: {
  120141. [key: string]: string;
  120142. };
  120143. /**
  120144. * Gets the target of the compilation state
  120145. */
  120146. target: NodeMaterialBlockTargets;
  120147. /**
  120148. * Gets the list of emitted counters
  120149. */
  120150. counters: {
  120151. [key: string]: number;
  120152. };
  120153. /**
  120154. * Shared data between multiple NodeMaterialBuildState instances
  120155. */
  120156. sharedData: NodeMaterialBuildStateSharedData;
  120157. /** @hidden */
  120158. _vertexState: NodeMaterialBuildState;
  120159. /** @hidden */
  120160. _attributeDeclaration: string;
  120161. /** @hidden */
  120162. _uniformDeclaration: string;
  120163. /** @hidden */
  120164. _constantDeclaration: string;
  120165. /** @hidden */
  120166. _samplerDeclaration: string;
  120167. /** @hidden */
  120168. _varyingTransfer: string;
  120169. private _repeatableContentAnchorIndex;
  120170. /** @hidden */
  120171. _builtCompilationString: string;
  120172. /**
  120173. * Gets the emitted compilation strings
  120174. */
  120175. compilationString: string;
  120176. /**
  120177. * Finalize the compilation strings
  120178. * @param state defines the current compilation state
  120179. */
  120180. finalize(state: NodeMaterialBuildState): void;
  120181. /** @hidden */
  120182. readonly _repeatableContentAnchor: string;
  120183. /** @hidden */
  120184. _getFreeVariableName(prefix: string): string;
  120185. /** @hidden */
  120186. _getFreeDefineName(prefix: string): string;
  120187. /** @hidden */
  120188. _excludeVariableName(name: string): void;
  120189. /** @hidden */
  120190. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  120191. /** @hidden */
  120192. _emitExtension(name: string, extension: string): void;
  120193. /** @hidden */
  120194. _emitFunction(name: string, code: string, comments: string): void;
  120195. /** @hidden */
  120196. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  120197. replaceStrings?: {
  120198. search: RegExp;
  120199. replace: string;
  120200. }[];
  120201. repeatKey?: string;
  120202. }): string;
  120203. /** @hidden */
  120204. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  120205. repeatKey?: string;
  120206. removeAttributes?: boolean;
  120207. removeUniforms?: boolean;
  120208. removeVaryings?: boolean;
  120209. removeIfDef?: boolean;
  120210. replaceStrings?: {
  120211. search: RegExp;
  120212. replace: string;
  120213. }[];
  120214. }, storeKey?: string): void;
  120215. /** @hidden */
  120216. _registerTempVariable(name: string): boolean;
  120217. /** @hidden */
  120218. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  120219. /** @hidden */
  120220. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  120221. /** @hidden */
  120222. _emitFloat(value: number): string;
  120223. }
  120224. }
  120225. declare module BABYLON {
  120226. /**
  120227. * Defines a block that can be used inside a node based material
  120228. */
  120229. export class NodeMaterialBlock {
  120230. private _buildId;
  120231. private _buildTarget;
  120232. private _target;
  120233. private _isFinalMerger;
  120234. private _isInput;
  120235. /** @hidden */
  120236. _codeVariableName: string;
  120237. /** @hidden */
  120238. _inputs: NodeMaterialConnectionPoint[];
  120239. /** @hidden */
  120240. _outputs: NodeMaterialConnectionPoint[];
  120241. /** @hidden */
  120242. _preparationId: number;
  120243. /**
  120244. * Gets or sets the name of the block
  120245. */
  120246. name: string;
  120247. /**
  120248. * Gets or sets the unique id of the node
  120249. */
  120250. uniqueId: number;
  120251. /**
  120252. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  120253. */
  120254. readonly isFinalMerger: boolean;
  120255. /**
  120256. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  120257. */
  120258. readonly isInput: boolean;
  120259. /**
  120260. * Gets or sets the build Id
  120261. */
  120262. buildId: number;
  120263. /**
  120264. * Gets or sets the target of the block
  120265. */
  120266. target: NodeMaterialBlockTargets;
  120267. /**
  120268. * Gets the list of input points
  120269. */
  120270. readonly inputs: NodeMaterialConnectionPoint[];
  120271. /** Gets the list of output points */
  120272. readonly outputs: NodeMaterialConnectionPoint[];
  120273. /**
  120274. * Find an input by its name
  120275. * @param name defines the name of the input to look for
  120276. * @returns the input or null if not found
  120277. */
  120278. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120279. /**
  120280. * Find an output by its name
  120281. * @param name defines the name of the outputto look for
  120282. * @returns the output or null if not found
  120283. */
  120284. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120285. /**
  120286. * Creates a new NodeMaterialBlock
  120287. * @param name defines the block name
  120288. * @param target defines the target of that block (Vertex by default)
  120289. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  120290. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  120291. */
  120292. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  120293. /**
  120294. * Initialize the block and prepare the context for build
  120295. * @param state defines the state that will be used for the build
  120296. */
  120297. initialize(state: NodeMaterialBuildState): void;
  120298. /**
  120299. * Bind data to effect. Will only be called for blocks with isBindable === true
  120300. * @param effect defines the effect to bind data to
  120301. * @param nodeMaterial defines the hosting NodeMaterial
  120302. * @param mesh defines the mesh that will be rendered
  120303. */
  120304. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120305. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  120306. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  120307. protected _writeFloat(value: number): string;
  120308. /**
  120309. * Gets the current class name e.g. "NodeMaterialBlock"
  120310. * @returns the class name
  120311. */
  120312. getClassName(): string;
  120313. /**
  120314. * Register a new input. Must be called inside a block constructor
  120315. * @param name defines the connection point name
  120316. * @param type defines the connection point type
  120317. * @param isOptional defines a boolean indicating that this input can be omitted
  120318. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120319. * @returns the current block
  120320. */
  120321. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  120322. /**
  120323. * Register a new output. Must be called inside a block constructor
  120324. * @param name defines the connection point name
  120325. * @param type defines the connection point type
  120326. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120327. * @returns the current block
  120328. */
  120329. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  120330. /**
  120331. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  120332. * @param forOutput defines an optional connection point to check compatibility with
  120333. * @returns the first available input or null
  120334. */
  120335. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  120336. /**
  120337. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  120338. * @param forBlock defines an optional block to check compatibility with
  120339. * @returns the first available input or null
  120340. */
  120341. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  120342. /**
  120343. * Gets the sibling of the given output
  120344. * @param current defines the current output
  120345. * @returns the next output in the list or null
  120346. */
  120347. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  120348. /**
  120349. * Connect current block with another block
  120350. * @param other defines the block to connect with
  120351. * @param options define the various options to help pick the right connections
  120352. * @returns the current block
  120353. */
  120354. connectTo(other: NodeMaterialBlock, options?: {
  120355. input?: string;
  120356. output?: string;
  120357. outputSwizzle?: string;
  120358. }): this | undefined;
  120359. protected _buildBlock(state: NodeMaterialBuildState): void;
  120360. /**
  120361. * Add uniforms, samplers and uniform buffers at compilation time
  120362. * @param state defines the state to update
  120363. * @param nodeMaterial defines the node material requesting the update
  120364. * @param defines defines the material defines to update
  120365. */
  120366. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120367. /**
  120368. * Add potential fallbacks if shader compilation fails
  120369. * @param mesh defines the mesh to be rendered
  120370. * @param fallbacks defines the current prioritized list of fallbacks
  120371. */
  120372. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120373. /**
  120374. * Initialize defines for shader compilation
  120375. * @param mesh defines the mesh to be rendered
  120376. * @param nodeMaterial defines the node material requesting the update
  120377. * @param defines defines the material defines to update
  120378. * @param useInstances specifies that instances should be used
  120379. */
  120380. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120381. /**
  120382. * Update defines for shader compilation
  120383. * @param mesh defines the mesh to be rendered
  120384. * @param nodeMaterial defines the node material requesting the update
  120385. * @param defines defines the material defines to update
  120386. * @param useInstances specifies that instances should be used
  120387. */
  120388. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120389. /**
  120390. * Lets the block try to connect some inputs automatically
  120391. * @param material defines the hosting NodeMaterial
  120392. */
  120393. autoConfigure(material: NodeMaterial): void;
  120394. /**
  120395. * Function called when a block is declared as repeatable content generator
  120396. * @param vertexShaderState defines the current compilation state for the vertex shader
  120397. * @param fragmentShaderState defines the current compilation state for the fragment shader
  120398. * @param mesh defines the mesh to be rendered
  120399. * @param defines defines the material defines to update
  120400. */
  120401. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120402. /**
  120403. * Checks if the block is ready
  120404. * @param mesh defines the mesh to be rendered
  120405. * @param nodeMaterial defines the node material requesting the update
  120406. * @param defines defines the material defines to update
  120407. * @param useInstances specifies that instances should be used
  120408. * @returns true if the block is ready
  120409. */
  120410. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  120411. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  120412. private _processBuild;
  120413. /**
  120414. * Compile the current node and generate the shader code
  120415. * @param state defines the current compilation state (uniforms, samplers, current string)
  120416. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  120417. * @returns true if already built
  120418. */
  120419. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  120420. protected _inputRename(name: string): string;
  120421. protected _outputRename(name: string): string;
  120422. protected _dumpPropertiesCode(): string;
  120423. /** @hidden */
  120424. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  120425. /**
  120426. * Clone the current block to a new identical block
  120427. * @param scene defines the hosting scene
  120428. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120429. * @returns a copy of the current block
  120430. */
  120431. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  120432. /**
  120433. * Serializes this block in a JSON representation
  120434. * @returns the serialized block object
  120435. */
  120436. serialize(): any;
  120437. /** @hidden */
  120438. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120439. }
  120440. }
  120441. declare module BABYLON {
  120442. /**
  120443. * Enum defining the type of animations supported by InputBlock
  120444. */
  120445. export enum AnimatedInputBlockTypes {
  120446. /** No animation */
  120447. None = 0,
  120448. /** Time based animation. Will only work for floats */
  120449. Time = 1
  120450. }
  120451. }
  120452. declare module BABYLON {
  120453. /**
  120454. * Block used to expose an input value
  120455. */
  120456. export class InputBlock extends NodeMaterialBlock {
  120457. private _mode;
  120458. private _associatedVariableName;
  120459. private _storedValue;
  120460. private _valueCallback;
  120461. private _type;
  120462. private _animationType;
  120463. /** Gets or set a value used to limit the range of float values */
  120464. min: number;
  120465. /** Gets or set a value used to limit the range of float values */
  120466. max: number;
  120467. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  120468. matrixMode: number;
  120469. /** @hidden */
  120470. _systemValue: Nullable<NodeMaterialSystemValues>;
  120471. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  120472. visibleInInspector: boolean;
  120473. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  120474. isConstant: boolean;
  120475. /**
  120476. * Gets or sets the connection point type (default is float)
  120477. */
  120478. readonly type: NodeMaterialBlockConnectionPointTypes;
  120479. /**
  120480. * Creates a new InputBlock
  120481. * @param name defines the block name
  120482. * @param target defines the target of that block (Vertex by default)
  120483. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  120484. */
  120485. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  120486. /**
  120487. * Gets the output component
  120488. */
  120489. readonly output: NodeMaterialConnectionPoint;
  120490. /**
  120491. * Set the source of this connection point to a vertex attribute
  120492. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  120493. * @returns the current connection point
  120494. */
  120495. setAsAttribute(attributeName?: string): InputBlock;
  120496. /**
  120497. * Set the source of this connection point to a system value
  120498. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  120499. * @returns the current connection point
  120500. */
  120501. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  120502. /**
  120503. * Gets or sets the value of that point.
  120504. * Please note that this value will be ignored if valueCallback is defined
  120505. */
  120506. value: any;
  120507. /**
  120508. * Gets or sets a callback used to get the value of that point.
  120509. * Please note that setting this value will force the connection point to ignore the value property
  120510. */
  120511. valueCallback: () => any;
  120512. /**
  120513. * Gets or sets the associated variable name in the shader
  120514. */
  120515. associatedVariableName: string;
  120516. /** Gets or sets the type of animation applied to the input */
  120517. animationType: AnimatedInputBlockTypes;
  120518. /**
  120519. * Gets a boolean indicating that this connection point not defined yet
  120520. */
  120521. readonly isUndefined: boolean;
  120522. /**
  120523. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  120524. * In this case the connection point name must be the name of the uniform to use.
  120525. * Can only be set on inputs
  120526. */
  120527. isUniform: boolean;
  120528. /**
  120529. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  120530. * In this case the connection point name must be the name of the attribute to use
  120531. * Can only be set on inputs
  120532. */
  120533. isAttribute: boolean;
  120534. /**
  120535. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  120536. * Can only be set on exit points
  120537. */
  120538. isVarying: boolean;
  120539. /**
  120540. * Gets a boolean indicating that the current connection point is a system value
  120541. */
  120542. readonly isSystemValue: boolean;
  120543. /**
  120544. * Gets or sets the current well known value or null if not defined as a system value
  120545. */
  120546. systemValue: Nullable<NodeMaterialSystemValues>;
  120547. /**
  120548. * Gets the current class name
  120549. * @returns the class name
  120550. */
  120551. getClassName(): string;
  120552. /**
  120553. * Animate the input if animationType !== None
  120554. * @param scene defines the rendering scene
  120555. */
  120556. animate(scene: Scene): void;
  120557. private _emitDefine;
  120558. initialize(state: NodeMaterialBuildState): void;
  120559. /**
  120560. * Set the input block to its default value (based on its type)
  120561. */
  120562. setDefaultValue(): void;
  120563. private _emitConstant;
  120564. private _emit;
  120565. /** @hidden */
  120566. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  120567. /** @hidden */
  120568. _transmit(effect: Effect, scene: Scene): void;
  120569. protected _buildBlock(state: NodeMaterialBuildState): void;
  120570. protected _dumpPropertiesCode(): string;
  120571. serialize(): any;
  120572. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120573. }
  120574. }
  120575. declare module BABYLON {
  120576. /**
  120577. * Defines a connection point for a block
  120578. */
  120579. export class NodeMaterialConnectionPoint {
  120580. /** @hidden */
  120581. _ownerBlock: NodeMaterialBlock;
  120582. /** @hidden */
  120583. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120584. private _endpoints;
  120585. private _associatedVariableName;
  120586. /** @hidden */
  120587. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120588. /** @hidden */
  120589. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120590. private _type;
  120591. /** @hidden */
  120592. _enforceAssociatedVariableName: boolean;
  120593. /**
  120594. * Gets or sets the additional types supported by this connection point
  120595. */
  120596. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120597. /**
  120598. * Gets or sets the additional types excluded by this connection point
  120599. */
  120600. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120601. /**
  120602. * Gets or sets the associated variable name in the shader
  120603. */
  120604. associatedVariableName: string;
  120605. /**
  120606. * Gets or sets the connection point type (default is float)
  120607. */
  120608. type: NodeMaterialBlockConnectionPointTypes;
  120609. /**
  120610. * Gets or sets the connection point name
  120611. */
  120612. name: string;
  120613. /**
  120614. * Gets or sets a boolean indicating that this connection point can be omitted
  120615. */
  120616. isOptional: boolean;
  120617. /**
  120618. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  120619. */
  120620. define: string;
  120621. /** Gets or sets the target of that connection point */
  120622. target: NodeMaterialBlockTargets;
  120623. /**
  120624. * Gets a boolean indicating that the current point is connected
  120625. */
  120626. readonly isConnected: boolean;
  120627. /**
  120628. * Gets a boolean indicating that the current point is connected to an input block
  120629. */
  120630. readonly isConnectedToInputBlock: boolean;
  120631. /**
  120632. * Gets a the connected input block (if any)
  120633. */
  120634. readonly connectInputBlock: Nullable<InputBlock>;
  120635. /** Get the other side of the connection (if any) */
  120636. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120637. /** Get the block that owns this connection point */
  120638. readonly ownerBlock: NodeMaterialBlock;
  120639. /** Get the block connected on the other side of this connection (if any) */
  120640. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  120641. /** Get the block connected on the endpoints of this connection (if any) */
  120642. readonly connectedBlocks: Array<NodeMaterialBlock>;
  120643. /** Gets the list of connected endpoints */
  120644. readonly endpoints: NodeMaterialConnectionPoint[];
  120645. /** Gets a boolean indicating if that output point is connected to at least one input */
  120646. readonly hasEndpoints: boolean;
  120647. /**
  120648. * Creates a new connection point
  120649. * @param name defines the connection point name
  120650. * @param ownerBlock defines the block hosting this connection point
  120651. */
  120652. constructor(name: string, ownerBlock: NodeMaterialBlock);
  120653. /**
  120654. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  120655. * @returns the class name
  120656. */
  120657. getClassName(): string;
  120658. /**
  120659. * Gets an boolean indicating if the current point can be connected to another point
  120660. * @param connectionPoint defines the other connection point
  120661. * @returns true if the connection is possible
  120662. */
  120663. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  120664. /**
  120665. * Connect this point to another connection point
  120666. * @param connectionPoint defines the other connection point
  120667. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  120668. * @returns the current connection point
  120669. */
  120670. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  120671. /**
  120672. * Disconnect this point from one of his endpoint
  120673. * @param endpoint defines the other connection point
  120674. * @returns the current connection point
  120675. */
  120676. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  120677. /**
  120678. * Serializes this point in a JSON representation
  120679. * @returns the serialized point object
  120680. */
  120681. serialize(): any;
  120682. }
  120683. }
  120684. declare module BABYLON {
  120685. /**
  120686. * Block used to add support for vertex skinning (bones)
  120687. */
  120688. export class BonesBlock extends NodeMaterialBlock {
  120689. /**
  120690. * Creates a new BonesBlock
  120691. * @param name defines the block name
  120692. */
  120693. constructor(name: string);
  120694. /**
  120695. * Initialize the block and prepare the context for build
  120696. * @param state defines the state that will be used for the build
  120697. */
  120698. initialize(state: NodeMaterialBuildState): void;
  120699. /**
  120700. * Gets the current class name
  120701. * @returns the class name
  120702. */
  120703. getClassName(): string;
  120704. /**
  120705. * Gets the matrix indices input component
  120706. */
  120707. readonly matricesIndices: NodeMaterialConnectionPoint;
  120708. /**
  120709. * Gets the matrix weights input component
  120710. */
  120711. readonly matricesWeights: NodeMaterialConnectionPoint;
  120712. /**
  120713. * Gets the extra matrix indices input component
  120714. */
  120715. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  120716. /**
  120717. * Gets the extra matrix weights input component
  120718. */
  120719. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  120720. /**
  120721. * Gets the world input component
  120722. */
  120723. readonly world: NodeMaterialConnectionPoint;
  120724. /**
  120725. * Gets the output component
  120726. */
  120727. readonly output: NodeMaterialConnectionPoint;
  120728. autoConfigure(material: NodeMaterial): void;
  120729. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120730. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120731. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120732. protected _buildBlock(state: NodeMaterialBuildState): this;
  120733. }
  120734. }
  120735. declare module BABYLON {
  120736. /**
  120737. * Block used to add support for instances
  120738. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  120739. */
  120740. export class InstancesBlock extends NodeMaterialBlock {
  120741. /**
  120742. * Creates a new InstancesBlock
  120743. * @param name defines the block name
  120744. */
  120745. constructor(name: string);
  120746. /**
  120747. * Gets the current class name
  120748. * @returns the class name
  120749. */
  120750. getClassName(): string;
  120751. /**
  120752. * Gets the first world row input component
  120753. */
  120754. readonly world0: NodeMaterialConnectionPoint;
  120755. /**
  120756. * Gets the second world row input component
  120757. */
  120758. readonly world1: NodeMaterialConnectionPoint;
  120759. /**
  120760. * Gets the third world row input component
  120761. */
  120762. readonly world2: NodeMaterialConnectionPoint;
  120763. /**
  120764. * Gets the forth world row input component
  120765. */
  120766. readonly world3: NodeMaterialConnectionPoint;
  120767. /**
  120768. * Gets the world input component
  120769. */
  120770. readonly world: NodeMaterialConnectionPoint;
  120771. /**
  120772. * Gets the output component
  120773. */
  120774. readonly output: NodeMaterialConnectionPoint;
  120775. autoConfigure(material: NodeMaterial): void;
  120776. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120777. protected _buildBlock(state: NodeMaterialBuildState): this;
  120778. }
  120779. }
  120780. declare module BABYLON {
  120781. /**
  120782. * Block used to add morph targets support to vertex shader
  120783. */
  120784. export class MorphTargetsBlock extends NodeMaterialBlock {
  120785. private _repeatableContentAnchor;
  120786. private _repeatebleContentGenerated;
  120787. /**
  120788. * Create a new MorphTargetsBlock
  120789. * @param name defines the block name
  120790. */
  120791. constructor(name: string);
  120792. /**
  120793. * Gets the current class name
  120794. * @returns the class name
  120795. */
  120796. getClassName(): string;
  120797. /**
  120798. * Gets the position input component
  120799. */
  120800. readonly position: NodeMaterialConnectionPoint;
  120801. /**
  120802. * Gets the normal input component
  120803. */
  120804. readonly normal: NodeMaterialConnectionPoint;
  120805. /**
  120806. * Gets the tangent input component
  120807. */
  120808. readonly tangent: NodeMaterialConnectionPoint;
  120809. /**
  120810. * Gets the tangent input component
  120811. */
  120812. readonly uv: NodeMaterialConnectionPoint;
  120813. /**
  120814. * Gets the position output component
  120815. */
  120816. readonly positionOutput: NodeMaterialConnectionPoint;
  120817. /**
  120818. * Gets the normal output component
  120819. */
  120820. readonly normalOutput: NodeMaterialConnectionPoint;
  120821. /**
  120822. * Gets the tangent output component
  120823. */
  120824. readonly tangentOutput: NodeMaterialConnectionPoint;
  120825. /**
  120826. * Gets the tangent output component
  120827. */
  120828. readonly uvOutput: NodeMaterialConnectionPoint;
  120829. initialize(state: NodeMaterialBuildState): void;
  120830. autoConfigure(material: NodeMaterial): void;
  120831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120832. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120833. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120834. protected _buildBlock(state: NodeMaterialBuildState): this;
  120835. }
  120836. }
  120837. declare module BABYLON {
  120838. /**
  120839. * Block used to get data information from a light
  120840. */
  120841. export class LightInformationBlock extends NodeMaterialBlock {
  120842. private _lightDataUniformName;
  120843. private _lightColorUniformName;
  120844. private _lightTypeDefineName;
  120845. /**
  120846. * Gets or sets the light associated with this block
  120847. */
  120848. light: Nullable<Light>;
  120849. /**
  120850. * Creates a new LightInformationBlock
  120851. * @param name defines the block name
  120852. */
  120853. constructor(name: string);
  120854. /**
  120855. * Gets the current class name
  120856. * @returns the class name
  120857. */
  120858. getClassName(): string;
  120859. /**
  120860. * Gets the world position input component
  120861. */
  120862. readonly worldPosition: NodeMaterialConnectionPoint;
  120863. /**
  120864. * Gets the direction output component
  120865. */
  120866. readonly direction: NodeMaterialConnectionPoint;
  120867. /**
  120868. * Gets the direction output component
  120869. */
  120870. readonly color: NodeMaterialConnectionPoint;
  120871. /**
  120872. * Gets the direction output component
  120873. */
  120874. readonly intensity: NodeMaterialConnectionPoint;
  120875. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120876. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120877. protected _buildBlock(state: NodeMaterialBuildState): this;
  120878. serialize(): any;
  120879. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120880. }
  120881. }
  120882. declare module BABYLON {
  120883. /**
  120884. * Block used to add image processing support to fragment shader
  120885. */
  120886. export class ImageProcessingBlock extends NodeMaterialBlock {
  120887. /**
  120888. * Create a new ImageProcessingBlock
  120889. * @param name defines the block name
  120890. */
  120891. constructor(name: string);
  120892. /**
  120893. * Gets the current class name
  120894. * @returns the class name
  120895. */
  120896. getClassName(): string;
  120897. /**
  120898. * Gets the color input component
  120899. */
  120900. readonly color: NodeMaterialConnectionPoint;
  120901. /**
  120902. * Gets the output component
  120903. */
  120904. readonly output: NodeMaterialConnectionPoint;
  120905. /**
  120906. * Initialize the block and prepare the context for build
  120907. * @param state defines the state that will be used for the build
  120908. */
  120909. initialize(state: NodeMaterialBuildState): void;
  120910. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  120911. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120912. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120913. protected _buildBlock(state: NodeMaterialBuildState): this;
  120914. }
  120915. }
  120916. declare module BABYLON {
  120917. /**
  120918. * Block used to pertub normals based on a normal map
  120919. */
  120920. export class PerturbNormalBlock extends NodeMaterialBlock {
  120921. private _tangentSpaceParameterName;
  120922. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  120923. invertX: boolean;
  120924. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  120925. invertY: boolean;
  120926. /**
  120927. * Create a new PerturbNormalBlock
  120928. * @param name defines the block name
  120929. */
  120930. constructor(name: string);
  120931. /**
  120932. * Gets the current class name
  120933. * @returns the class name
  120934. */
  120935. getClassName(): string;
  120936. /**
  120937. * Gets the world position input component
  120938. */
  120939. readonly worldPosition: NodeMaterialConnectionPoint;
  120940. /**
  120941. * Gets the world normal input component
  120942. */
  120943. readonly worldNormal: NodeMaterialConnectionPoint;
  120944. /**
  120945. * Gets the uv input component
  120946. */
  120947. readonly uv: NodeMaterialConnectionPoint;
  120948. /**
  120949. * Gets the normal map color input component
  120950. */
  120951. readonly normalMapColor: NodeMaterialConnectionPoint;
  120952. /**
  120953. * Gets the strength input component
  120954. */
  120955. readonly strength: NodeMaterialConnectionPoint;
  120956. /**
  120957. * Gets the output component
  120958. */
  120959. readonly output: NodeMaterialConnectionPoint;
  120960. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120961. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120962. autoConfigure(material: NodeMaterial): void;
  120963. protected _buildBlock(state: NodeMaterialBuildState): this;
  120964. protected _dumpPropertiesCode(): string;
  120965. serialize(): any;
  120966. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120967. }
  120968. }
  120969. declare module BABYLON {
  120970. /**
  120971. * Block used to discard a pixel if a value is smaller than a cutoff
  120972. */
  120973. export class DiscardBlock extends NodeMaterialBlock {
  120974. /**
  120975. * Create a new DiscardBlock
  120976. * @param name defines the block name
  120977. */
  120978. constructor(name: string);
  120979. /**
  120980. * Gets the current class name
  120981. * @returns the class name
  120982. */
  120983. getClassName(): string;
  120984. /**
  120985. * Gets the color input component
  120986. */
  120987. readonly value: NodeMaterialConnectionPoint;
  120988. /**
  120989. * Gets the cutoff input component
  120990. */
  120991. readonly cutoff: NodeMaterialConnectionPoint;
  120992. protected _buildBlock(state: NodeMaterialBuildState): this;
  120993. }
  120994. }
  120995. declare module BABYLON {
  120996. /**
  120997. * Block used to add support for scene fog
  120998. */
  120999. export class FogBlock extends NodeMaterialBlock {
  121000. private _fogDistanceName;
  121001. private _fogParameters;
  121002. /**
  121003. * Create a new FogBlock
  121004. * @param name defines the block name
  121005. */
  121006. constructor(name: string);
  121007. /**
  121008. * Gets the current class name
  121009. * @returns the class name
  121010. */
  121011. getClassName(): string;
  121012. /**
  121013. * Gets the world position input component
  121014. */
  121015. readonly worldPosition: NodeMaterialConnectionPoint;
  121016. /**
  121017. * Gets the view input component
  121018. */
  121019. readonly view: NodeMaterialConnectionPoint;
  121020. /**
  121021. * Gets the color input component
  121022. */
  121023. readonly input: NodeMaterialConnectionPoint;
  121024. /**
  121025. * Gets the fog color input component
  121026. */
  121027. readonly fogColor: NodeMaterialConnectionPoint;
  121028. /**
  121029. * Gets the output component
  121030. */
  121031. readonly output: NodeMaterialConnectionPoint;
  121032. autoConfigure(material: NodeMaterial): void;
  121033. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121034. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121035. protected _buildBlock(state: NodeMaterialBuildState): this;
  121036. }
  121037. }
  121038. declare module BABYLON {
  121039. /**
  121040. * Block used to add light in the fragment shader
  121041. */
  121042. export class LightBlock extends NodeMaterialBlock {
  121043. private _lightId;
  121044. /**
  121045. * Gets or sets the light associated with this block
  121046. */
  121047. light: Nullable<Light>;
  121048. /**
  121049. * Create a new LightBlock
  121050. * @param name defines the block name
  121051. */
  121052. constructor(name: string);
  121053. /**
  121054. * Gets the current class name
  121055. * @returns the class name
  121056. */
  121057. getClassName(): string;
  121058. /**
  121059. * Gets the world position input component
  121060. */
  121061. readonly worldPosition: NodeMaterialConnectionPoint;
  121062. /**
  121063. * Gets the world normal input component
  121064. */
  121065. readonly worldNormal: NodeMaterialConnectionPoint;
  121066. /**
  121067. * Gets the camera (or eye) position component
  121068. */
  121069. readonly cameraPosition: NodeMaterialConnectionPoint;
  121070. /**
  121071. * Gets the glossiness component
  121072. */
  121073. readonly glossiness: NodeMaterialConnectionPoint;
  121074. /**
  121075. * Gets the glossinness power component
  121076. */
  121077. readonly glossPower: NodeMaterialConnectionPoint;
  121078. /**
  121079. * Gets the diffuse color component
  121080. */
  121081. readonly diffuseColor: NodeMaterialConnectionPoint;
  121082. /**
  121083. * Gets the specular color component
  121084. */
  121085. readonly specularColor: NodeMaterialConnectionPoint;
  121086. /**
  121087. * Gets the diffuse output component
  121088. */
  121089. readonly diffuseOutput: NodeMaterialConnectionPoint;
  121090. /**
  121091. * Gets the specular output component
  121092. */
  121093. readonly specularOutput: NodeMaterialConnectionPoint;
  121094. autoConfigure(material: NodeMaterial): void;
  121095. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121096. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121097. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121098. private _injectVertexCode;
  121099. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121100. serialize(): any;
  121101. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121102. }
  121103. }
  121104. declare module BABYLON {
  121105. /**
  121106. * Block used to multiply 2 values
  121107. */
  121108. export class MultiplyBlock extends NodeMaterialBlock {
  121109. /**
  121110. * Creates a new MultiplyBlock
  121111. * @param name defines the block name
  121112. */
  121113. constructor(name: string);
  121114. /**
  121115. * Gets the current class name
  121116. * @returns the class name
  121117. */
  121118. getClassName(): string;
  121119. /**
  121120. * Gets the left operand input component
  121121. */
  121122. readonly left: NodeMaterialConnectionPoint;
  121123. /**
  121124. * Gets the right operand input component
  121125. */
  121126. readonly right: NodeMaterialConnectionPoint;
  121127. /**
  121128. * Gets the output component
  121129. */
  121130. readonly output: NodeMaterialConnectionPoint;
  121131. protected _buildBlock(state: NodeMaterialBuildState): this;
  121132. }
  121133. }
  121134. declare module BABYLON {
  121135. /**
  121136. * Block used to add 2 vectors
  121137. */
  121138. export class AddBlock extends NodeMaterialBlock {
  121139. /**
  121140. * Creates a new AddBlock
  121141. * @param name defines the block name
  121142. */
  121143. constructor(name: string);
  121144. /**
  121145. * Gets the current class name
  121146. * @returns the class name
  121147. */
  121148. getClassName(): string;
  121149. /**
  121150. * Gets the left operand input component
  121151. */
  121152. readonly left: NodeMaterialConnectionPoint;
  121153. /**
  121154. * Gets the right operand input component
  121155. */
  121156. readonly right: NodeMaterialConnectionPoint;
  121157. /**
  121158. * Gets the output component
  121159. */
  121160. readonly output: NodeMaterialConnectionPoint;
  121161. protected _buildBlock(state: NodeMaterialBuildState): this;
  121162. }
  121163. }
  121164. declare module BABYLON {
  121165. /**
  121166. * Block used to scale a vector by a float
  121167. */
  121168. export class ScaleBlock extends NodeMaterialBlock {
  121169. /**
  121170. * Creates a new ScaleBlock
  121171. * @param name defines the block name
  121172. */
  121173. constructor(name: string);
  121174. /**
  121175. * Gets the current class name
  121176. * @returns the class name
  121177. */
  121178. getClassName(): string;
  121179. /**
  121180. * Gets the input component
  121181. */
  121182. readonly input: NodeMaterialConnectionPoint;
  121183. /**
  121184. * Gets the factor input component
  121185. */
  121186. readonly factor: NodeMaterialConnectionPoint;
  121187. /**
  121188. * Gets the output component
  121189. */
  121190. readonly output: NodeMaterialConnectionPoint;
  121191. protected _buildBlock(state: NodeMaterialBuildState): this;
  121192. }
  121193. }
  121194. declare module BABYLON {
  121195. /**
  121196. * Block used to clamp a float
  121197. */
  121198. export class ClampBlock extends NodeMaterialBlock {
  121199. /** Gets or sets the minimum range */
  121200. minimum: number;
  121201. /** Gets or sets the maximum range */
  121202. maximum: number;
  121203. /**
  121204. * Creates a new ClampBlock
  121205. * @param name defines the block name
  121206. */
  121207. constructor(name: string);
  121208. /**
  121209. * Gets the current class name
  121210. * @returns the class name
  121211. */
  121212. getClassName(): string;
  121213. /**
  121214. * Gets the value input component
  121215. */
  121216. readonly value: NodeMaterialConnectionPoint;
  121217. /**
  121218. * Gets the output component
  121219. */
  121220. readonly output: NodeMaterialConnectionPoint;
  121221. protected _buildBlock(state: NodeMaterialBuildState): this;
  121222. protected _dumpPropertiesCode(): string;
  121223. serialize(): any;
  121224. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121225. }
  121226. }
  121227. declare module BABYLON {
  121228. /**
  121229. * Block used to apply a cross product between 2 vectors
  121230. */
  121231. export class CrossBlock extends NodeMaterialBlock {
  121232. /**
  121233. * Creates a new CrossBlock
  121234. * @param name defines the block name
  121235. */
  121236. constructor(name: string);
  121237. /**
  121238. * Gets the current class name
  121239. * @returns the class name
  121240. */
  121241. getClassName(): string;
  121242. /**
  121243. * Gets the left operand input component
  121244. */
  121245. readonly left: NodeMaterialConnectionPoint;
  121246. /**
  121247. * Gets the right operand input component
  121248. */
  121249. readonly right: NodeMaterialConnectionPoint;
  121250. /**
  121251. * Gets the output component
  121252. */
  121253. readonly output: NodeMaterialConnectionPoint;
  121254. protected _buildBlock(state: NodeMaterialBuildState): this;
  121255. }
  121256. }
  121257. declare module BABYLON {
  121258. /**
  121259. * Block used to apply a dot product between 2 vectors
  121260. */
  121261. export class DotBlock extends NodeMaterialBlock {
  121262. /**
  121263. * Creates a new DotBlock
  121264. * @param name defines the block name
  121265. */
  121266. constructor(name: string);
  121267. /**
  121268. * Gets the current class name
  121269. * @returns the class name
  121270. */
  121271. getClassName(): string;
  121272. /**
  121273. * Gets the left operand input component
  121274. */
  121275. readonly left: NodeMaterialConnectionPoint;
  121276. /**
  121277. * Gets the right operand input component
  121278. */
  121279. readonly right: NodeMaterialConnectionPoint;
  121280. /**
  121281. * Gets the output component
  121282. */
  121283. readonly output: NodeMaterialConnectionPoint;
  121284. protected _buildBlock(state: NodeMaterialBuildState): this;
  121285. }
  121286. }
  121287. declare module BABYLON {
  121288. /**
  121289. * Block used to remap a float from a range to a new one
  121290. */
  121291. export class RemapBlock extends NodeMaterialBlock {
  121292. /**
  121293. * Gets or sets the source range
  121294. */
  121295. sourceRange: Vector2;
  121296. /**
  121297. * Gets or sets the target range
  121298. */
  121299. targetRange: Vector2;
  121300. /**
  121301. * Creates a new RemapBlock
  121302. * @param name defines the block name
  121303. */
  121304. constructor(name: string);
  121305. /**
  121306. * Gets the current class name
  121307. * @returns the class name
  121308. */
  121309. getClassName(): string;
  121310. /**
  121311. * Gets the input component
  121312. */
  121313. readonly input: NodeMaterialConnectionPoint;
  121314. /**
  121315. * Gets the source min input component
  121316. */
  121317. readonly sourceMin: NodeMaterialConnectionPoint;
  121318. /**
  121319. * Gets the source max input component
  121320. */
  121321. readonly sourceMax: NodeMaterialConnectionPoint;
  121322. /**
  121323. * Gets the target min input component
  121324. */
  121325. readonly targetMin: NodeMaterialConnectionPoint;
  121326. /**
  121327. * Gets the target max input component
  121328. */
  121329. readonly targetMax: NodeMaterialConnectionPoint;
  121330. /**
  121331. * Gets the output component
  121332. */
  121333. readonly output: NodeMaterialConnectionPoint;
  121334. protected _buildBlock(state: NodeMaterialBuildState): this;
  121335. protected _dumpPropertiesCode(): string;
  121336. serialize(): any;
  121337. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121338. }
  121339. }
  121340. declare module BABYLON {
  121341. /**
  121342. * Block used to normalize a vector
  121343. */
  121344. export class NormalizeBlock extends NodeMaterialBlock {
  121345. /**
  121346. * Creates a new NormalizeBlock
  121347. * @param name defines the block name
  121348. */
  121349. constructor(name: string);
  121350. /**
  121351. * Gets the current class name
  121352. * @returns the class name
  121353. */
  121354. getClassName(): string;
  121355. /**
  121356. * Gets the input component
  121357. */
  121358. readonly input: NodeMaterialConnectionPoint;
  121359. /**
  121360. * Gets the output component
  121361. */
  121362. readonly output: NodeMaterialConnectionPoint;
  121363. protected _buildBlock(state: NodeMaterialBuildState): this;
  121364. }
  121365. }
  121366. declare module BABYLON {
  121367. /**
  121368. * Operations supported by the Trigonometry block
  121369. */
  121370. export enum TrigonometryBlockOperations {
  121371. /** Cos */
  121372. Cos = 0,
  121373. /** Sin */
  121374. Sin = 1,
  121375. /** Abs */
  121376. Abs = 2,
  121377. /** Exp */
  121378. Exp = 3,
  121379. /** Exp2 */
  121380. Exp2 = 4,
  121381. /** Round */
  121382. Round = 5,
  121383. /** Floor */
  121384. Floor = 6,
  121385. /** Ceiling */
  121386. Ceiling = 7,
  121387. /** Square root */
  121388. Sqrt = 8,
  121389. /** Log */
  121390. Log = 9,
  121391. /** Tangent */
  121392. Tan = 10,
  121393. /** Arc tangent */
  121394. ArcTan = 11,
  121395. /** Arc cosinus */
  121396. ArcCos = 12,
  121397. /** Arc sinus */
  121398. ArcSin = 13,
  121399. /** Fraction */
  121400. Fract = 14,
  121401. /** Sign */
  121402. Sign = 15,
  121403. /** To radians (from degrees) */
  121404. Radians = 16,
  121405. /** To degrees (from radians) */
  121406. Degrees = 17
  121407. }
  121408. /**
  121409. * Block used to apply trigonometry operation to floats
  121410. */
  121411. export class TrigonometryBlock extends NodeMaterialBlock {
  121412. /**
  121413. * Gets or sets the operation applied by the block
  121414. */
  121415. operation: TrigonometryBlockOperations;
  121416. /**
  121417. * Creates a new TrigonometryBlock
  121418. * @param name defines the block name
  121419. */
  121420. constructor(name: string);
  121421. /**
  121422. * Gets the current class name
  121423. * @returns the class name
  121424. */
  121425. getClassName(): string;
  121426. /**
  121427. * Gets the input component
  121428. */
  121429. readonly input: NodeMaterialConnectionPoint;
  121430. /**
  121431. * Gets the output component
  121432. */
  121433. readonly output: NodeMaterialConnectionPoint;
  121434. protected _buildBlock(state: NodeMaterialBuildState): this;
  121435. serialize(): any;
  121436. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121437. }
  121438. }
  121439. declare module BABYLON {
  121440. /**
  121441. * Block used to create a Color3/4 out of individual inputs (one for each component)
  121442. */
  121443. export class ColorMergerBlock extends NodeMaterialBlock {
  121444. /**
  121445. * Create a new ColorMergerBlock
  121446. * @param name defines the block name
  121447. */
  121448. constructor(name: string);
  121449. /**
  121450. * Gets the current class name
  121451. * @returns the class name
  121452. */
  121453. getClassName(): string;
  121454. /**
  121455. * Gets the r component (input)
  121456. */
  121457. readonly r: NodeMaterialConnectionPoint;
  121458. /**
  121459. * Gets the g component (input)
  121460. */
  121461. readonly g: NodeMaterialConnectionPoint;
  121462. /**
  121463. * Gets the b component (input)
  121464. */
  121465. readonly b: NodeMaterialConnectionPoint;
  121466. /**
  121467. * Gets the a component (input)
  121468. */
  121469. readonly a: NodeMaterialConnectionPoint;
  121470. /**
  121471. * Gets the rgba component (output)
  121472. */
  121473. readonly rgba: NodeMaterialConnectionPoint;
  121474. /**
  121475. * Gets the rgb component (output)
  121476. */
  121477. readonly rgb: NodeMaterialConnectionPoint;
  121478. protected _buildBlock(state: NodeMaterialBuildState): this;
  121479. }
  121480. }
  121481. declare module BABYLON {
  121482. /**
  121483. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  121484. */
  121485. export class VectorMergerBlock extends NodeMaterialBlock {
  121486. /**
  121487. * Create a new VectorMergerBlock
  121488. * @param name defines the block name
  121489. */
  121490. constructor(name: string);
  121491. /**
  121492. * Gets the current class name
  121493. * @returns the class name
  121494. */
  121495. getClassName(): string;
  121496. /**
  121497. * Gets the x component (input)
  121498. */
  121499. readonly x: NodeMaterialConnectionPoint;
  121500. /**
  121501. * Gets the y component (input)
  121502. */
  121503. readonly y: NodeMaterialConnectionPoint;
  121504. /**
  121505. * Gets the z component (input)
  121506. */
  121507. readonly z: NodeMaterialConnectionPoint;
  121508. /**
  121509. * Gets the w component (input)
  121510. */
  121511. readonly w: NodeMaterialConnectionPoint;
  121512. /**
  121513. * Gets the xyzw component (output)
  121514. */
  121515. readonly xyzw: NodeMaterialConnectionPoint;
  121516. /**
  121517. * Gets the xyz component (output)
  121518. */
  121519. readonly xyz: NodeMaterialConnectionPoint;
  121520. /**
  121521. * Gets the xy component (output)
  121522. */
  121523. readonly xy: NodeMaterialConnectionPoint;
  121524. protected _buildBlock(state: NodeMaterialBuildState): this;
  121525. }
  121526. }
  121527. declare module BABYLON {
  121528. /**
  121529. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  121530. */
  121531. export class ColorSplitterBlock extends NodeMaterialBlock {
  121532. /**
  121533. * Create a new ColorSplitterBlock
  121534. * @param name defines the block name
  121535. */
  121536. constructor(name: string);
  121537. /**
  121538. * Gets the current class name
  121539. * @returns the class name
  121540. */
  121541. getClassName(): string;
  121542. /**
  121543. * Gets the rgba component (input)
  121544. */
  121545. readonly rgba: NodeMaterialConnectionPoint;
  121546. /**
  121547. * Gets the rgb component (input)
  121548. */
  121549. readonly rgbIn: NodeMaterialConnectionPoint;
  121550. /**
  121551. * Gets the rgb component (output)
  121552. */
  121553. readonly rgbOut: NodeMaterialConnectionPoint;
  121554. /**
  121555. * Gets the r component (output)
  121556. */
  121557. readonly r: NodeMaterialConnectionPoint;
  121558. /**
  121559. * Gets the g component (output)
  121560. */
  121561. readonly g: NodeMaterialConnectionPoint;
  121562. /**
  121563. * Gets the b component (output)
  121564. */
  121565. readonly b: NodeMaterialConnectionPoint;
  121566. /**
  121567. * Gets the a component (output)
  121568. */
  121569. readonly a: NodeMaterialConnectionPoint;
  121570. protected _inputRename(name: string): string;
  121571. protected _outputRename(name: string): string;
  121572. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121573. }
  121574. }
  121575. declare module BABYLON {
  121576. /**
  121577. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  121578. */
  121579. export class VectorSplitterBlock extends NodeMaterialBlock {
  121580. /**
  121581. * Create a new VectorSplitterBlock
  121582. * @param name defines the block name
  121583. */
  121584. constructor(name: string);
  121585. /**
  121586. * Gets the current class name
  121587. * @returns the class name
  121588. */
  121589. getClassName(): string;
  121590. /**
  121591. * Gets the xyzw component (input)
  121592. */
  121593. readonly xyzw: NodeMaterialConnectionPoint;
  121594. /**
  121595. * Gets the xyz component (input)
  121596. */
  121597. readonly xyzIn: NodeMaterialConnectionPoint;
  121598. /**
  121599. * Gets the xy component (input)
  121600. */
  121601. readonly xyIn: NodeMaterialConnectionPoint;
  121602. /**
  121603. * Gets the xyz component (output)
  121604. */
  121605. readonly xyzOut: NodeMaterialConnectionPoint;
  121606. /**
  121607. * Gets the xy component (output)
  121608. */
  121609. readonly xyOut: NodeMaterialConnectionPoint;
  121610. /**
  121611. * Gets the x component (output)
  121612. */
  121613. readonly x: NodeMaterialConnectionPoint;
  121614. /**
  121615. * Gets the y component (output)
  121616. */
  121617. readonly y: NodeMaterialConnectionPoint;
  121618. /**
  121619. * Gets the z component (output)
  121620. */
  121621. readonly z: NodeMaterialConnectionPoint;
  121622. /**
  121623. * Gets the w component (output)
  121624. */
  121625. readonly w: NodeMaterialConnectionPoint;
  121626. protected _inputRename(name: string): string;
  121627. protected _outputRename(name: string): string;
  121628. protected _buildBlock(state: NodeMaterialBuildState): this;
  121629. }
  121630. }
  121631. declare module BABYLON {
  121632. /**
  121633. * Block used to lerp between 2 values
  121634. */
  121635. export class LerpBlock extends NodeMaterialBlock {
  121636. /**
  121637. * Creates a new LerpBlock
  121638. * @param name defines the block name
  121639. */
  121640. constructor(name: string);
  121641. /**
  121642. * Gets the current class name
  121643. * @returns the class name
  121644. */
  121645. getClassName(): string;
  121646. /**
  121647. * Gets the left operand input component
  121648. */
  121649. readonly left: NodeMaterialConnectionPoint;
  121650. /**
  121651. * Gets the right operand input component
  121652. */
  121653. readonly right: NodeMaterialConnectionPoint;
  121654. /**
  121655. * Gets the gradient operand input component
  121656. */
  121657. readonly gradient: NodeMaterialConnectionPoint;
  121658. /**
  121659. * Gets the output component
  121660. */
  121661. readonly output: NodeMaterialConnectionPoint;
  121662. protected _buildBlock(state: NodeMaterialBuildState): this;
  121663. }
  121664. }
  121665. declare module BABYLON {
  121666. /**
  121667. * Block used to divide 2 vectors
  121668. */
  121669. export class DivideBlock extends NodeMaterialBlock {
  121670. /**
  121671. * Creates a new DivideBlock
  121672. * @param name defines the block name
  121673. */
  121674. constructor(name: string);
  121675. /**
  121676. * Gets the current class name
  121677. * @returns the class name
  121678. */
  121679. getClassName(): string;
  121680. /**
  121681. * Gets the left operand input component
  121682. */
  121683. readonly left: NodeMaterialConnectionPoint;
  121684. /**
  121685. * Gets the right operand input component
  121686. */
  121687. readonly right: NodeMaterialConnectionPoint;
  121688. /**
  121689. * Gets the output component
  121690. */
  121691. readonly output: NodeMaterialConnectionPoint;
  121692. protected _buildBlock(state: NodeMaterialBuildState): this;
  121693. }
  121694. }
  121695. declare module BABYLON {
  121696. /**
  121697. * Block used to subtract 2 vectors
  121698. */
  121699. export class SubtractBlock extends NodeMaterialBlock {
  121700. /**
  121701. * Creates a new SubtractBlock
  121702. * @param name defines the block name
  121703. */
  121704. constructor(name: string);
  121705. /**
  121706. * Gets the current class name
  121707. * @returns the class name
  121708. */
  121709. getClassName(): string;
  121710. /**
  121711. * Gets the left operand input component
  121712. */
  121713. readonly left: NodeMaterialConnectionPoint;
  121714. /**
  121715. * Gets the right operand input component
  121716. */
  121717. readonly right: NodeMaterialConnectionPoint;
  121718. /**
  121719. * Gets the output component
  121720. */
  121721. readonly output: NodeMaterialConnectionPoint;
  121722. protected _buildBlock(state: NodeMaterialBuildState): this;
  121723. }
  121724. }
  121725. declare module BABYLON {
  121726. /**
  121727. * Block used to step a value
  121728. */
  121729. export class StepBlock extends NodeMaterialBlock {
  121730. /**
  121731. * Creates a new StepBlock
  121732. * @param name defines the block name
  121733. */
  121734. constructor(name: string);
  121735. /**
  121736. * Gets the current class name
  121737. * @returns the class name
  121738. */
  121739. getClassName(): string;
  121740. /**
  121741. * Gets the value operand input component
  121742. */
  121743. readonly value: NodeMaterialConnectionPoint;
  121744. /**
  121745. * Gets the edge operand input component
  121746. */
  121747. readonly edge: NodeMaterialConnectionPoint;
  121748. /**
  121749. * Gets the output component
  121750. */
  121751. readonly output: NodeMaterialConnectionPoint;
  121752. protected _buildBlock(state: NodeMaterialBuildState): this;
  121753. }
  121754. }
  121755. declare module BABYLON {
  121756. /**
  121757. * Block used to get the opposite (1 - x) of a value
  121758. */
  121759. export class OneMinusBlock extends NodeMaterialBlock {
  121760. /**
  121761. * Creates a new OneMinusBlock
  121762. * @param name defines the block name
  121763. */
  121764. constructor(name: string);
  121765. /**
  121766. * Gets the current class name
  121767. * @returns the class name
  121768. */
  121769. getClassName(): string;
  121770. /**
  121771. * Gets the input component
  121772. */
  121773. readonly input: NodeMaterialConnectionPoint;
  121774. /**
  121775. * Gets the output component
  121776. */
  121777. readonly output: NodeMaterialConnectionPoint;
  121778. protected _buildBlock(state: NodeMaterialBuildState): this;
  121779. }
  121780. }
  121781. declare module BABYLON {
  121782. /**
  121783. * Block used to get the view direction
  121784. */
  121785. export class ViewDirectionBlock extends NodeMaterialBlock {
  121786. /**
  121787. * Creates a new ViewDirectionBlock
  121788. * @param name defines the block name
  121789. */
  121790. constructor(name: string);
  121791. /**
  121792. * Gets the current class name
  121793. * @returns the class name
  121794. */
  121795. getClassName(): string;
  121796. /**
  121797. * Gets the world position component
  121798. */
  121799. readonly worldPosition: NodeMaterialConnectionPoint;
  121800. /**
  121801. * Gets the camera position component
  121802. */
  121803. readonly cameraPosition: NodeMaterialConnectionPoint;
  121804. /**
  121805. * Gets the output component
  121806. */
  121807. readonly output: NodeMaterialConnectionPoint;
  121808. autoConfigure(material: NodeMaterial): void;
  121809. protected _buildBlock(state: NodeMaterialBuildState): this;
  121810. }
  121811. }
  121812. declare module BABYLON {
  121813. /**
  121814. * Block used to compute fresnel value
  121815. */
  121816. export class FresnelBlock extends NodeMaterialBlock {
  121817. /**
  121818. * Create a new FresnelBlock
  121819. * @param name defines the block name
  121820. */
  121821. constructor(name: string);
  121822. /**
  121823. * Gets the current class name
  121824. * @returns the class name
  121825. */
  121826. getClassName(): string;
  121827. /**
  121828. * Gets the world normal input component
  121829. */
  121830. readonly worldNormal: NodeMaterialConnectionPoint;
  121831. /**
  121832. * Gets the view direction input component
  121833. */
  121834. readonly viewDirection: NodeMaterialConnectionPoint;
  121835. /**
  121836. * Gets the bias input component
  121837. */
  121838. readonly bias: NodeMaterialConnectionPoint;
  121839. /**
  121840. * Gets the camera (or eye) position component
  121841. */
  121842. readonly power: NodeMaterialConnectionPoint;
  121843. /**
  121844. * Gets the fresnel output component
  121845. */
  121846. readonly fresnel: NodeMaterialConnectionPoint;
  121847. autoConfigure(material: NodeMaterial): void;
  121848. protected _buildBlock(state: NodeMaterialBuildState): this;
  121849. }
  121850. }
  121851. declare module BABYLON {
  121852. /**
  121853. * Block used to get the max of 2 values
  121854. */
  121855. export class MaxBlock extends NodeMaterialBlock {
  121856. /**
  121857. * Creates a new MaxBlock
  121858. * @param name defines the block name
  121859. */
  121860. constructor(name: string);
  121861. /**
  121862. * Gets the current class name
  121863. * @returns the class name
  121864. */
  121865. getClassName(): string;
  121866. /**
  121867. * Gets the left operand input component
  121868. */
  121869. readonly left: NodeMaterialConnectionPoint;
  121870. /**
  121871. * Gets the right operand input component
  121872. */
  121873. readonly right: NodeMaterialConnectionPoint;
  121874. /**
  121875. * Gets the output component
  121876. */
  121877. readonly output: NodeMaterialConnectionPoint;
  121878. protected _buildBlock(state: NodeMaterialBuildState): this;
  121879. }
  121880. }
  121881. declare module BABYLON {
  121882. /**
  121883. * Block used to get the min of 2 values
  121884. */
  121885. export class MinBlock extends NodeMaterialBlock {
  121886. /**
  121887. * Creates a new MinBlock
  121888. * @param name defines the block name
  121889. */
  121890. constructor(name: string);
  121891. /**
  121892. * Gets the current class name
  121893. * @returns the class name
  121894. */
  121895. getClassName(): string;
  121896. /**
  121897. * Gets the left operand input component
  121898. */
  121899. readonly left: NodeMaterialConnectionPoint;
  121900. /**
  121901. * Gets the right operand input component
  121902. */
  121903. readonly right: NodeMaterialConnectionPoint;
  121904. /**
  121905. * Gets the output component
  121906. */
  121907. readonly output: NodeMaterialConnectionPoint;
  121908. protected _buildBlock(state: NodeMaterialBuildState): this;
  121909. }
  121910. }
  121911. declare module BABYLON {
  121912. /**
  121913. * Block used to get the distance between 2 values
  121914. */
  121915. export class DistanceBlock extends NodeMaterialBlock {
  121916. /**
  121917. * Creates a new DistanceBlock
  121918. * @param name defines the block name
  121919. */
  121920. constructor(name: string);
  121921. /**
  121922. * Gets the current class name
  121923. * @returns the class name
  121924. */
  121925. getClassName(): string;
  121926. /**
  121927. * Gets the left operand input component
  121928. */
  121929. readonly left: NodeMaterialConnectionPoint;
  121930. /**
  121931. * Gets the right operand input component
  121932. */
  121933. readonly right: NodeMaterialConnectionPoint;
  121934. /**
  121935. * Gets the output component
  121936. */
  121937. readonly output: NodeMaterialConnectionPoint;
  121938. protected _buildBlock(state: NodeMaterialBuildState): this;
  121939. }
  121940. }
  121941. declare module BABYLON {
  121942. /**
  121943. * Block used to get the length of a vector
  121944. */
  121945. export class LengthBlock extends NodeMaterialBlock {
  121946. /**
  121947. * Creates a new LengthBlock
  121948. * @param name defines the block name
  121949. */
  121950. constructor(name: string);
  121951. /**
  121952. * Gets the current class name
  121953. * @returns the class name
  121954. */
  121955. getClassName(): string;
  121956. /**
  121957. * Gets the value input component
  121958. */
  121959. readonly value: NodeMaterialConnectionPoint;
  121960. /**
  121961. * Gets the output component
  121962. */
  121963. readonly output: NodeMaterialConnectionPoint;
  121964. protected _buildBlock(state: NodeMaterialBuildState): this;
  121965. }
  121966. }
  121967. declare module BABYLON {
  121968. /**
  121969. * Block used to get negative version of a value (i.e. x * -1)
  121970. */
  121971. export class NegateBlock extends NodeMaterialBlock {
  121972. /**
  121973. * Creates a new NegateBlock
  121974. * @param name defines the block name
  121975. */
  121976. constructor(name: string);
  121977. /**
  121978. * Gets the current class name
  121979. * @returns the class name
  121980. */
  121981. getClassName(): string;
  121982. /**
  121983. * Gets the value input component
  121984. */
  121985. readonly value: NodeMaterialConnectionPoint;
  121986. /**
  121987. * Gets the output component
  121988. */
  121989. readonly output: NodeMaterialConnectionPoint;
  121990. protected _buildBlock(state: NodeMaterialBuildState): this;
  121991. }
  121992. }
  121993. declare module BABYLON {
  121994. /**
  121995. * Block used to get the value of the first parameter raised to the power of the second
  121996. */
  121997. export class PowBlock extends NodeMaterialBlock {
  121998. /**
  121999. * Creates a new PowBlock
  122000. * @param name defines the block name
  122001. */
  122002. constructor(name: string);
  122003. /**
  122004. * Gets the current class name
  122005. * @returns the class name
  122006. */
  122007. getClassName(): string;
  122008. /**
  122009. * Gets the value operand input component
  122010. */
  122011. readonly value: NodeMaterialConnectionPoint;
  122012. /**
  122013. * Gets the power operand input component
  122014. */
  122015. readonly power: NodeMaterialConnectionPoint;
  122016. /**
  122017. * Gets the output component
  122018. */
  122019. readonly output: NodeMaterialConnectionPoint;
  122020. protected _buildBlock(state: NodeMaterialBuildState): this;
  122021. }
  122022. }
  122023. declare module BABYLON {
  122024. /**
  122025. * Block used to get a random number
  122026. */
  122027. export class RandomNumberBlock extends NodeMaterialBlock {
  122028. /**
  122029. * Creates a new RandomNumberBlock
  122030. * @param name defines the block name
  122031. */
  122032. constructor(name: string);
  122033. /**
  122034. * Gets the current class name
  122035. * @returns the class name
  122036. */
  122037. getClassName(): string;
  122038. /**
  122039. * Gets the seed input component
  122040. */
  122041. readonly seed: NodeMaterialConnectionPoint;
  122042. /**
  122043. * Gets the output component
  122044. */
  122045. readonly output: NodeMaterialConnectionPoint;
  122046. protected _buildBlock(state: NodeMaterialBuildState): this;
  122047. }
  122048. }
  122049. declare module BABYLON {
  122050. /**
  122051. * Block used to compute arc tangent of 2 values
  122052. */
  122053. export class ArcTan2Block extends NodeMaterialBlock {
  122054. /**
  122055. * Creates a new ArcTan2Block
  122056. * @param name defines the block name
  122057. */
  122058. constructor(name: string);
  122059. /**
  122060. * Gets the current class name
  122061. * @returns the class name
  122062. */
  122063. getClassName(): string;
  122064. /**
  122065. * Gets the x operand input component
  122066. */
  122067. readonly x: NodeMaterialConnectionPoint;
  122068. /**
  122069. * Gets the y operand input component
  122070. */
  122071. readonly y: NodeMaterialConnectionPoint;
  122072. /**
  122073. * Gets the output component
  122074. */
  122075. readonly output: NodeMaterialConnectionPoint;
  122076. protected _buildBlock(state: NodeMaterialBuildState): this;
  122077. }
  122078. }
  122079. declare module BABYLON {
  122080. /**
  122081. * Block used to smooth step a value
  122082. */
  122083. export class SmoothStepBlock extends NodeMaterialBlock {
  122084. /**
  122085. * Creates a new SmoothStepBlock
  122086. * @param name defines the block name
  122087. */
  122088. constructor(name: string);
  122089. /**
  122090. * Gets the current class name
  122091. * @returns the class name
  122092. */
  122093. getClassName(): string;
  122094. /**
  122095. * Gets the value operand input component
  122096. */
  122097. readonly value: NodeMaterialConnectionPoint;
  122098. /**
  122099. * Gets the first edge operand input component
  122100. */
  122101. readonly edge0: NodeMaterialConnectionPoint;
  122102. /**
  122103. * Gets the second edge operand input component
  122104. */
  122105. readonly edge1: NodeMaterialConnectionPoint;
  122106. /**
  122107. * Gets the output component
  122108. */
  122109. readonly output: NodeMaterialConnectionPoint;
  122110. protected _buildBlock(state: NodeMaterialBuildState): this;
  122111. }
  122112. }
  122113. declare module BABYLON {
  122114. /**
  122115. * Block used to get the reciprocal (1 / x) of a value
  122116. */
  122117. export class ReciprocalBlock extends NodeMaterialBlock {
  122118. /**
  122119. * Creates a new ReciprocalBlock
  122120. * @param name defines the block name
  122121. */
  122122. constructor(name: string);
  122123. /**
  122124. * Gets the current class name
  122125. * @returns the class name
  122126. */
  122127. getClassName(): string;
  122128. /**
  122129. * Gets the input component
  122130. */
  122131. readonly input: NodeMaterialConnectionPoint;
  122132. /**
  122133. * Gets the output component
  122134. */
  122135. readonly output: NodeMaterialConnectionPoint;
  122136. protected _buildBlock(state: NodeMaterialBuildState): this;
  122137. }
  122138. }
  122139. declare module BABYLON {
  122140. /**
  122141. * Block used to replace a color by another one
  122142. */
  122143. export class ReplaceColorBlock extends NodeMaterialBlock {
  122144. /**
  122145. * Creates a new ReplaceColorBlock
  122146. * @param name defines the block name
  122147. */
  122148. constructor(name: string);
  122149. /**
  122150. * Gets the current class name
  122151. * @returns the class name
  122152. */
  122153. getClassName(): string;
  122154. /**
  122155. * Gets the value input component
  122156. */
  122157. readonly value: NodeMaterialConnectionPoint;
  122158. /**
  122159. * Gets the reference input component
  122160. */
  122161. readonly reference: NodeMaterialConnectionPoint;
  122162. /**
  122163. * Gets the distance input component
  122164. */
  122165. readonly distance: NodeMaterialConnectionPoint;
  122166. /**
  122167. * Gets the replacement input component
  122168. */
  122169. readonly replacement: NodeMaterialConnectionPoint;
  122170. /**
  122171. * Gets the output component
  122172. */
  122173. readonly output: NodeMaterialConnectionPoint;
  122174. protected _buildBlock(state: NodeMaterialBuildState): this;
  122175. }
  122176. }
  122177. declare module BABYLON {
  122178. /**
  122179. * Block used to posterize a value
  122180. * @see https://en.wikipedia.org/wiki/Posterization
  122181. */
  122182. export class PosterizeBlock extends NodeMaterialBlock {
  122183. /**
  122184. * Creates a new PosterizeBlock
  122185. * @param name defines the block name
  122186. */
  122187. constructor(name: string);
  122188. /**
  122189. * Gets the current class name
  122190. * @returns the class name
  122191. */
  122192. getClassName(): string;
  122193. /**
  122194. * Gets the value input component
  122195. */
  122196. readonly value: NodeMaterialConnectionPoint;
  122197. /**
  122198. * Gets the steps input component
  122199. */
  122200. readonly steps: NodeMaterialConnectionPoint;
  122201. /**
  122202. * Gets the output component
  122203. */
  122204. readonly output: NodeMaterialConnectionPoint;
  122205. protected _buildBlock(state: NodeMaterialBuildState): this;
  122206. }
  122207. }
  122208. declare module BABYLON {
  122209. /**
  122210. * Operations supported by the Wave block
  122211. */
  122212. export enum WaveBlockKind {
  122213. /** SawTooth */
  122214. SawTooth = 0,
  122215. /** Square */
  122216. Square = 1,
  122217. /** Triangle */
  122218. Triangle = 2
  122219. }
  122220. /**
  122221. * Block used to apply wave operation to floats
  122222. */
  122223. export class WaveBlock extends NodeMaterialBlock {
  122224. /**
  122225. * Gets or sets the kibnd of wave to be applied by the block
  122226. */
  122227. kind: WaveBlockKind;
  122228. /**
  122229. * Creates a new WaveBlock
  122230. * @param name defines the block name
  122231. */
  122232. constructor(name: string);
  122233. /**
  122234. * Gets the current class name
  122235. * @returns the class name
  122236. */
  122237. getClassName(): string;
  122238. /**
  122239. * Gets the input component
  122240. */
  122241. readonly input: NodeMaterialConnectionPoint;
  122242. /**
  122243. * Gets the output component
  122244. */
  122245. readonly output: NodeMaterialConnectionPoint;
  122246. protected _buildBlock(state: NodeMaterialBuildState): this;
  122247. serialize(): any;
  122248. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122249. }
  122250. }
  122251. declare module BABYLON {
  122252. /**
  122253. * Class used to store a color step for the GradientBlock
  122254. */
  122255. export class GradientBlockColorStep {
  122256. /**
  122257. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122258. */
  122259. step: number;
  122260. /**
  122261. * Gets or sets the color associated with this step
  122262. */
  122263. color: Color3;
  122264. /**
  122265. * Creates a new GradientBlockColorStep
  122266. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  122267. * @param color defines the color associated with this step
  122268. */
  122269. constructor(
  122270. /**
  122271. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122272. */
  122273. step: number,
  122274. /**
  122275. * Gets or sets the color associated with this step
  122276. */
  122277. color: Color3);
  122278. }
  122279. /**
  122280. * Block used to return a color from a gradient based on an input value between 0 and 1
  122281. */
  122282. export class GradientBlock extends NodeMaterialBlock {
  122283. /**
  122284. * Gets or sets the list of color steps
  122285. */
  122286. colorSteps: GradientBlockColorStep[];
  122287. /**
  122288. * Creates a new GradientBlock
  122289. * @param name defines the block name
  122290. */
  122291. constructor(name: string);
  122292. /**
  122293. * Gets the current class name
  122294. * @returns the class name
  122295. */
  122296. getClassName(): string;
  122297. /**
  122298. * Gets the gradient input component
  122299. */
  122300. readonly gradient: NodeMaterialConnectionPoint;
  122301. /**
  122302. * Gets the output component
  122303. */
  122304. readonly output: NodeMaterialConnectionPoint;
  122305. private _writeColorConstant;
  122306. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122307. serialize(): any;
  122308. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122309. protected _dumpPropertiesCode(): string;
  122310. }
  122311. }
  122312. declare module BABYLON {
  122313. /**
  122314. * Block used to normalize lerp between 2 values
  122315. */
  122316. export class NLerpBlock extends NodeMaterialBlock {
  122317. /**
  122318. * Creates a new NLerpBlock
  122319. * @param name defines the block name
  122320. */
  122321. constructor(name: string);
  122322. /**
  122323. * Gets the current class name
  122324. * @returns the class name
  122325. */
  122326. getClassName(): string;
  122327. /**
  122328. * Gets the left operand input component
  122329. */
  122330. readonly left: NodeMaterialConnectionPoint;
  122331. /**
  122332. * Gets the right operand input component
  122333. */
  122334. readonly right: NodeMaterialConnectionPoint;
  122335. /**
  122336. * Gets the gradient operand input component
  122337. */
  122338. readonly gradient: NodeMaterialConnectionPoint;
  122339. /**
  122340. * Gets the output component
  122341. */
  122342. readonly output: NodeMaterialConnectionPoint;
  122343. protected _buildBlock(state: NodeMaterialBuildState): this;
  122344. }
  122345. }
  122346. declare module BABYLON {
  122347. /**
  122348. * Effect Render Options
  122349. */
  122350. export interface IEffectRendererOptions {
  122351. /**
  122352. * Defines the vertices positions.
  122353. */
  122354. positions?: number[];
  122355. /**
  122356. * Defines the indices.
  122357. */
  122358. indices?: number[];
  122359. }
  122360. /**
  122361. * Helper class to render one or more effects
  122362. */
  122363. export class EffectRenderer {
  122364. private engine;
  122365. private static _DefaultOptions;
  122366. private _vertexBuffers;
  122367. private _indexBuffer;
  122368. private _ringBufferIndex;
  122369. private _ringScreenBuffer;
  122370. private _fullscreenViewport;
  122371. private _getNextFrameBuffer;
  122372. /**
  122373. * Creates an effect renderer
  122374. * @param engine the engine to use for rendering
  122375. * @param options defines the options of the effect renderer
  122376. */
  122377. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  122378. /**
  122379. * Sets the current viewport in normalized coordinates 0-1
  122380. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  122381. */
  122382. setViewport(viewport?: Viewport): void;
  122383. /**
  122384. * Binds the embedded attributes buffer to the effect.
  122385. * @param effect Defines the effect to bind the attributes for
  122386. */
  122387. bindBuffers(effect: Effect): void;
  122388. /**
  122389. * Sets the current effect wrapper to use during draw.
  122390. * The effect needs to be ready before calling this api.
  122391. * This also sets the default full screen position attribute.
  122392. * @param effectWrapper Defines the effect to draw with
  122393. */
  122394. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  122395. /**
  122396. * Draws a full screen quad.
  122397. */
  122398. draw(): void;
  122399. /**
  122400. * renders one or more effects to a specified texture
  122401. * @param effectWrappers list of effects to renderer
  122402. * @param outputTexture texture to draw to, if null it will render to the screen
  122403. */
  122404. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  122405. /**
  122406. * Disposes of the effect renderer
  122407. */
  122408. dispose(): void;
  122409. }
  122410. /**
  122411. * Options to create an EffectWrapper
  122412. */
  122413. interface EffectWrapperCreationOptions {
  122414. /**
  122415. * Engine to use to create the effect
  122416. */
  122417. engine: ThinEngine;
  122418. /**
  122419. * Fragment shader for the effect
  122420. */
  122421. fragmentShader: string;
  122422. /**
  122423. * Vertex shader for the effect
  122424. */
  122425. vertexShader?: string;
  122426. /**
  122427. * Attributes to use in the shader
  122428. */
  122429. attributeNames?: Array<string>;
  122430. /**
  122431. * Uniforms to use in the shader
  122432. */
  122433. uniformNames?: Array<string>;
  122434. /**
  122435. * Texture sampler names to use in the shader
  122436. */
  122437. samplerNames?: Array<string>;
  122438. /**
  122439. * The friendly name of the effect displayed in Spector.
  122440. */
  122441. name?: string;
  122442. }
  122443. /**
  122444. * Wraps an effect to be used for rendering
  122445. */
  122446. export class EffectWrapper {
  122447. /**
  122448. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  122449. */
  122450. onApplyObservable: Observable<{}>;
  122451. /**
  122452. * The underlying effect
  122453. */
  122454. effect: Effect;
  122455. /**
  122456. * Creates an effect to be renderer
  122457. * @param creationOptions options to create the effect
  122458. */
  122459. constructor(creationOptions: EffectWrapperCreationOptions);
  122460. /**
  122461. * Disposes of the effect wrapper
  122462. */
  122463. dispose(): void;
  122464. }
  122465. }
  122466. declare module BABYLON {
  122467. /**
  122468. * Helper class to push actions to a pool of workers.
  122469. */
  122470. export class WorkerPool implements IDisposable {
  122471. private _workerInfos;
  122472. private _pendingActions;
  122473. /**
  122474. * Constructor
  122475. * @param workers Array of workers to use for actions
  122476. */
  122477. constructor(workers: Array<Worker>);
  122478. /**
  122479. * Terminates all workers and clears any pending actions.
  122480. */
  122481. dispose(): void;
  122482. /**
  122483. * Pushes an action to the worker pool. If all the workers are active, the action will be
  122484. * pended until a worker has completed its action.
  122485. * @param action The action to perform. Call onComplete when the action is complete.
  122486. */
  122487. push(action: (worker: Worker, onComplete: () => void) => void): void;
  122488. private _execute;
  122489. }
  122490. }
  122491. declare module BABYLON {
  122492. /**
  122493. * Configuration for Draco compression
  122494. */
  122495. export interface IDracoCompressionConfiguration {
  122496. /**
  122497. * Configuration for the decoder.
  122498. */
  122499. decoder: {
  122500. /**
  122501. * The url to the WebAssembly module.
  122502. */
  122503. wasmUrl?: string;
  122504. /**
  122505. * The url to the WebAssembly binary.
  122506. */
  122507. wasmBinaryUrl?: string;
  122508. /**
  122509. * The url to the fallback JavaScript module.
  122510. */
  122511. fallbackUrl?: string;
  122512. };
  122513. }
  122514. /**
  122515. * Draco compression (https://google.github.io/draco/)
  122516. *
  122517. * This class wraps the Draco module.
  122518. *
  122519. * **Encoder**
  122520. *
  122521. * The encoder is not currently implemented.
  122522. *
  122523. * **Decoder**
  122524. *
  122525. * 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.
  122526. *
  122527. * To update the configuration, use the following code:
  122528. * ```javascript
  122529. * DracoCompression.Configuration = {
  122530. * decoder: {
  122531. * wasmUrl: "<url to the WebAssembly library>",
  122532. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  122533. * fallbackUrl: "<url to the fallback JavaScript library>",
  122534. * }
  122535. * };
  122536. * ```
  122537. *
  122538. * 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.
  122539. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  122540. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  122541. *
  122542. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  122543. * ```javascript
  122544. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  122545. * ```
  122546. *
  122547. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  122548. */
  122549. export class DracoCompression implements IDisposable {
  122550. private _workerPoolPromise?;
  122551. private _decoderModulePromise?;
  122552. /**
  122553. * The configuration. Defaults to the following urls:
  122554. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  122555. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  122556. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  122557. */
  122558. static Configuration: IDracoCompressionConfiguration;
  122559. /**
  122560. * Returns true if the decoder configuration is available.
  122561. */
  122562. static readonly DecoderAvailable: boolean;
  122563. /**
  122564. * Default number of workers to create when creating the draco compression object.
  122565. */
  122566. static DefaultNumWorkers: number;
  122567. private static GetDefaultNumWorkers;
  122568. private static _Default;
  122569. /**
  122570. * Default instance for the draco compression object.
  122571. */
  122572. static readonly Default: DracoCompression;
  122573. /**
  122574. * Constructor
  122575. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  122576. */
  122577. constructor(numWorkers?: number);
  122578. /**
  122579. * Stop all async operations and release resources.
  122580. */
  122581. dispose(): void;
  122582. /**
  122583. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  122584. * @returns a promise that resolves when ready
  122585. */
  122586. whenReadyAsync(): Promise<void>;
  122587. /**
  122588. * Decode Draco compressed mesh data to vertex data.
  122589. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  122590. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  122591. * @returns A promise that resolves with the decoded vertex data
  122592. */
  122593. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  122594. [kind: string]: number;
  122595. }): Promise<VertexData>;
  122596. }
  122597. }
  122598. declare module BABYLON {
  122599. /**
  122600. * Class for building Constructive Solid Geometry
  122601. */
  122602. export class CSG {
  122603. private polygons;
  122604. /**
  122605. * The world matrix
  122606. */
  122607. matrix: Matrix;
  122608. /**
  122609. * Stores the position
  122610. */
  122611. position: Vector3;
  122612. /**
  122613. * Stores the rotation
  122614. */
  122615. rotation: Vector3;
  122616. /**
  122617. * Stores the rotation quaternion
  122618. */
  122619. rotationQuaternion: Nullable<Quaternion>;
  122620. /**
  122621. * Stores the scaling vector
  122622. */
  122623. scaling: Vector3;
  122624. /**
  122625. * Convert the Mesh to CSG
  122626. * @param mesh The Mesh to convert to CSG
  122627. * @returns A new CSG from the Mesh
  122628. */
  122629. static FromMesh(mesh: Mesh): CSG;
  122630. /**
  122631. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  122632. * @param polygons Polygons used to construct a CSG solid
  122633. */
  122634. private static FromPolygons;
  122635. /**
  122636. * Clones, or makes a deep copy, of the CSG
  122637. * @returns A new CSG
  122638. */
  122639. clone(): CSG;
  122640. /**
  122641. * Unions this CSG with another CSG
  122642. * @param csg The CSG to union against this CSG
  122643. * @returns The unioned CSG
  122644. */
  122645. union(csg: CSG): CSG;
  122646. /**
  122647. * Unions this CSG with another CSG in place
  122648. * @param csg The CSG to union against this CSG
  122649. */
  122650. unionInPlace(csg: CSG): void;
  122651. /**
  122652. * Subtracts this CSG with another CSG
  122653. * @param csg The CSG to subtract against this CSG
  122654. * @returns A new CSG
  122655. */
  122656. subtract(csg: CSG): CSG;
  122657. /**
  122658. * Subtracts this CSG with another CSG in place
  122659. * @param csg The CSG to subtact against this CSG
  122660. */
  122661. subtractInPlace(csg: CSG): void;
  122662. /**
  122663. * Intersect this CSG with another CSG
  122664. * @param csg The CSG to intersect against this CSG
  122665. * @returns A new CSG
  122666. */
  122667. intersect(csg: CSG): CSG;
  122668. /**
  122669. * Intersects this CSG with another CSG in place
  122670. * @param csg The CSG to intersect against this CSG
  122671. */
  122672. intersectInPlace(csg: CSG): void;
  122673. /**
  122674. * Return a new CSG solid with solid and empty space switched. This solid is
  122675. * not modified.
  122676. * @returns A new CSG solid with solid and empty space switched
  122677. */
  122678. inverse(): CSG;
  122679. /**
  122680. * Inverses the CSG in place
  122681. */
  122682. inverseInPlace(): void;
  122683. /**
  122684. * This is used to keep meshes transformations so they can be restored
  122685. * when we build back a Babylon Mesh
  122686. * NB : All CSG operations are performed in world coordinates
  122687. * @param csg The CSG to copy the transform attributes from
  122688. * @returns This CSG
  122689. */
  122690. copyTransformAttributes(csg: CSG): CSG;
  122691. /**
  122692. * Build Raw mesh from CSG
  122693. * Coordinates here are in world space
  122694. * @param name The name of the mesh geometry
  122695. * @param scene The Scene
  122696. * @param keepSubMeshes Specifies if the submeshes should be kept
  122697. * @returns A new Mesh
  122698. */
  122699. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122700. /**
  122701. * Build Mesh from CSG taking material and transforms into account
  122702. * @param name The name of the Mesh
  122703. * @param material The material of the Mesh
  122704. * @param scene The Scene
  122705. * @param keepSubMeshes Specifies if submeshes should be kept
  122706. * @returns The new Mesh
  122707. */
  122708. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122709. }
  122710. }
  122711. declare module BABYLON {
  122712. /**
  122713. * Class used to create a trail following a mesh
  122714. */
  122715. export class TrailMesh extends Mesh {
  122716. private _generator;
  122717. private _autoStart;
  122718. private _running;
  122719. private _diameter;
  122720. private _length;
  122721. private _sectionPolygonPointsCount;
  122722. private _sectionVectors;
  122723. private _sectionNormalVectors;
  122724. private _beforeRenderObserver;
  122725. /**
  122726. * @constructor
  122727. * @param name The value used by scene.getMeshByName() to do a lookup.
  122728. * @param generator The mesh to generate a trail.
  122729. * @param scene The scene to add this mesh to.
  122730. * @param diameter Diameter of trailing mesh. Default is 1.
  122731. * @param length Length of trailing mesh. Default is 60.
  122732. * @param autoStart Automatically start trailing mesh. Default true.
  122733. */
  122734. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  122735. /**
  122736. * "TrailMesh"
  122737. * @returns "TrailMesh"
  122738. */
  122739. getClassName(): string;
  122740. private _createMesh;
  122741. /**
  122742. * Start trailing mesh.
  122743. */
  122744. start(): void;
  122745. /**
  122746. * Stop trailing mesh.
  122747. */
  122748. stop(): void;
  122749. /**
  122750. * Update trailing mesh geometry.
  122751. */
  122752. update(): void;
  122753. /**
  122754. * Returns a new TrailMesh object.
  122755. * @param name is a string, the name given to the new mesh
  122756. * @param newGenerator use new generator object for cloned trail mesh
  122757. * @returns a new mesh
  122758. */
  122759. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  122760. /**
  122761. * Serializes this trail mesh
  122762. * @param serializationObject object to write serialization to
  122763. */
  122764. serialize(serializationObject: any): void;
  122765. /**
  122766. * Parses a serialized trail mesh
  122767. * @param parsedMesh the serialized mesh
  122768. * @param scene the scene to create the trail mesh in
  122769. * @returns the created trail mesh
  122770. */
  122771. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  122772. }
  122773. }
  122774. declare module BABYLON {
  122775. /**
  122776. * Class containing static functions to help procedurally build meshes
  122777. */
  122778. export class TiledBoxBuilder {
  122779. /**
  122780. * Creates a box mesh
  122781. * 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)
  122782. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122784. * * 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
  122785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122786. * @param name defines the name of the mesh
  122787. * @param options defines the options used to create the mesh
  122788. * @param scene defines the hosting scene
  122789. * @returns the box mesh
  122790. */
  122791. static CreateTiledBox(name: string, options: {
  122792. pattern?: number;
  122793. width?: number;
  122794. height?: number;
  122795. depth?: number;
  122796. tileSize?: number;
  122797. tileWidth?: number;
  122798. tileHeight?: number;
  122799. alignHorizontal?: number;
  122800. alignVertical?: number;
  122801. faceUV?: Vector4[];
  122802. faceColors?: Color4[];
  122803. sideOrientation?: number;
  122804. updatable?: boolean;
  122805. }, scene?: Nullable<Scene>): Mesh;
  122806. }
  122807. }
  122808. declare module BABYLON {
  122809. /**
  122810. * Class containing static functions to help procedurally build meshes
  122811. */
  122812. export class TorusKnotBuilder {
  122813. /**
  122814. * Creates a torus knot mesh
  122815. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  122816. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  122817. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  122818. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  122819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122820. * * 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
  122821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122822. * @param name defines the name of the mesh
  122823. * @param options defines the options used to create the mesh
  122824. * @param scene defines the hosting scene
  122825. * @returns the torus knot mesh
  122826. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  122827. */
  122828. static CreateTorusKnot(name: string, options: {
  122829. radius?: number;
  122830. tube?: number;
  122831. radialSegments?: number;
  122832. tubularSegments?: number;
  122833. p?: number;
  122834. q?: number;
  122835. updatable?: boolean;
  122836. sideOrientation?: number;
  122837. frontUVs?: Vector4;
  122838. backUVs?: Vector4;
  122839. }, scene: any): Mesh;
  122840. }
  122841. }
  122842. declare module BABYLON {
  122843. /**
  122844. * Polygon
  122845. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  122846. */
  122847. export class Polygon {
  122848. /**
  122849. * Creates a rectangle
  122850. * @param xmin bottom X coord
  122851. * @param ymin bottom Y coord
  122852. * @param xmax top X coord
  122853. * @param ymax top Y coord
  122854. * @returns points that make the resulting rectation
  122855. */
  122856. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  122857. /**
  122858. * Creates a circle
  122859. * @param radius radius of circle
  122860. * @param cx scale in x
  122861. * @param cy scale in y
  122862. * @param numberOfSides number of sides that make up the circle
  122863. * @returns points that make the resulting circle
  122864. */
  122865. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  122866. /**
  122867. * Creates a polygon from input string
  122868. * @param input Input polygon data
  122869. * @returns the parsed points
  122870. */
  122871. static Parse(input: string): Vector2[];
  122872. /**
  122873. * Starts building a polygon from x and y coordinates
  122874. * @param x x coordinate
  122875. * @param y y coordinate
  122876. * @returns the started path2
  122877. */
  122878. static StartingAt(x: number, y: number): Path2;
  122879. }
  122880. /**
  122881. * Builds a polygon
  122882. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  122883. */
  122884. export class PolygonMeshBuilder {
  122885. private _points;
  122886. private _outlinepoints;
  122887. private _holes;
  122888. private _name;
  122889. private _scene;
  122890. private _epoints;
  122891. private _eholes;
  122892. private _addToepoint;
  122893. /**
  122894. * Babylon reference to the earcut plugin.
  122895. */
  122896. bjsEarcut: any;
  122897. /**
  122898. * Creates a PolygonMeshBuilder
  122899. * @param name name of the builder
  122900. * @param contours Path of the polygon
  122901. * @param scene scene to add to when creating the mesh
  122902. * @param earcutInjection can be used to inject your own earcut reference
  122903. */
  122904. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  122905. /**
  122906. * Adds a whole within the polygon
  122907. * @param hole Array of points defining the hole
  122908. * @returns this
  122909. */
  122910. addHole(hole: Vector2[]): PolygonMeshBuilder;
  122911. /**
  122912. * Creates the polygon
  122913. * @param updatable If the mesh should be updatable
  122914. * @param depth The depth of the mesh created
  122915. * @returns the created mesh
  122916. */
  122917. build(updatable?: boolean, depth?: number): Mesh;
  122918. /**
  122919. * Creates the polygon
  122920. * @param depth The depth of the mesh created
  122921. * @returns the created VertexData
  122922. */
  122923. buildVertexData(depth?: number): VertexData;
  122924. /**
  122925. * Adds a side to the polygon
  122926. * @param positions points that make the polygon
  122927. * @param normals normals of the polygon
  122928. * @param uvs uvs of the polygon
  122929. * @param indices indices of the polygon
  122930. * @param bounds bounds of the polygon
  122931. * @param points points of the polygon
  122932. * @param depth depth of the polygon
  122933. * @param flip flip of the polygon
  122934. */
  122935. private addSide;
  122936. }
  122937. }
  122938. declare module BABYLON {
  122939. /**
  122940. * Class containing static functions to help procedurally build meshes
  122941. */
  122942. export class PolygonBuilder {
  122943. /**
  122944. * Creates a polygon mesh
  122945. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122946. * * 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
  122947. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122949. * * 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)
  122950. * * Remember you can only change the shape positions, not their number when updating a polygon
  122951. * @param name defines the name of the mesh
  122952. * @param options defines the options used to create the mesh
  122953. * @param scene defines the hosting scene
  122954. * @param earcutInjection can be used to inject your own earcut reference
  122955. * @returns the polygon mesh
  122956. */
  122957. static CreatePolygon(name: string, options: {
  122958. shape: Vector3[];
  122959. holes?: Vector3[][];
  122960. depth?: number;
  122961. faceUV?: Vector4[];
  122962. faceColors?: Color4[];
  122963. updatable?: boolean;
  122964. sideOrientation?: number;
  122965. frontUVs?: Vector4;
  122966. backUVs?: Vector4;
  122967. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122968. /**
  122969. * Creates an extruded polygon mesh, with depth in the Y direction.
  122970. * * 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)
  122971. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122972. * @param name defines the name of the mesh
  122973. * @param options defines the options used to create the mesh
  122974. * @param scene defines the hosting scene
  122975. * @param earcutInjection can be used to inject your own earcut reference
  122976. * @returns the polygon mesh
  122977. */
  122978. static ExtrudePolygon(name: string, options: {
  122979. shape: Vector3[];
  122980. holes?: Vector3[][];
  122981. depth?: number;
  122982. faceUV?: Vector4[];
  122983. faceColors?: Color4[];
  122984. updatable?: boolean;
  122985. sideOrientation?: number;
  122986. frontUVs?: Vector4;
  122987. backUVs?: Vector4;
  122988. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122989. }
  122990. }
  122991. declare module BABYLON {
  122992. /**
  122993. * Class containing static functions to help procedurally build meshes
  122994. */
  122995. export class LatheBuilder {
  122996. /**
  122997. * Creates lathe mesh.
  122998. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  122999. * * 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
  123000. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123001. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123002. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123003. * * 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
  123004. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123005. * * 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
  123006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123007. * * 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
  123008. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123010. * @param name defines the name of the mesh
  123011. * @param options defines the options used to create the mesh
  123012. * @param scene defines the hosting scene
  123013. * @returns the lathe mesh
  123014. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123015. */
  123016. static CreateLathe(name: string, options: {
  123017. shape: Vector3[];
  123018. radius?: number;
  123019. tessellation?: number;
  123020. clip?: number;
  123021. arc?: number;
  123022. closed?: boolean;
  123023. updatable?: boolean;
  123024. sideOrientation?: number;
  123025. frontUVs?: Vector4;
  123026. backUVs?: Vector4;
  123027. cap?: number;
  123028. invertUV?: boolean;
  123029. }, scene?: Nullable<Scene>): Mesh;
  123030. }
  123031. }
  123032. declare module BABYLON {
  123033. /**
  123034. * Class containing static functions to help procedurally build meshes
  123035. */
  123036. export class TiledPlaneBuilder {
  123037. /**
  123038. * Creates a tiled plane mesh
  123039. * * The parameter `pattern` will, depending on value, do nothing or
  123040. * * * flip (reflect about central vertical) alternate tiles across and up
  123041. * * * flip every tile on alternate rows
  123042. * * * rotate (180 degs) alternate tiles across and up
  123043. * * * rotate every tile on alternate rows
  123044. * * * flip and rotate alternate tiles across and up
  123045. * * * flip and rotate every tile on alternate rows
  123046. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  123047. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  123048. * * 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
  123049. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123050. * * 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)
  123051. * * 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)
  123052. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123053. * @param name defines the name of the mesh
  123054. * @param options defines the options used to create the mesh
  123055. * @param scene defines the hosting scene
  123056. * @returns the box mesh
  123057. */
  123058. static CreateTiledPlane(name: string, options: {
  123059. pattern?: number;
  123060. tileSize?: number;
  123061. tileWidth?: number;
  123062. tileHeight?: number;
  123063. size?: number;
  123064. width?: number;
  123065. height?: number;
  123066. alignHorizontal?: number;
  123067. alignVertical?: number;
  123068. sideOrientation?: number;
  123069. frontUVs?: Vector4;
  123070. backUVs?: Vector4;
  123071. updatable?: boolean;
  123072. }, scene?: Nullable<Scene>): Mesh;
  123073. }
  123074. }
  123075. declare module BABYLON {
  123076. /**
  123077. * Class containing static functions to help procedurally build meshes
  123078. */
  123079. export class TubeBuilder {
  123080. /**
  123081. * Creates a tube mesh.
  123082. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123083. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123084. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123085. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123086. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123087. * * 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)
  123088. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123089. * * 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
  123090. * * 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
  123091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123092. * * 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
  123093. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123095. * @param name defines the name of the mesh
  123096. * @param options defines the options used to create the mesh
  123097. * @param scene defines the hosting scene
  123098. * @returns the tube mesh
  123099. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123100. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123101. */
  123102. static CreateTube(name: string, options: {
  123103. path: Vector3[];
  123104. radius?: number;
  123105. tessellation?: number;
  123106. radiusFunction?: {
  123107. (i: number, distance: number): number;
  123108. };
  123109. cap?: number;
  123110. arc?: number;
  123111. updatable?: boolean;
  123112. sideOrientation?: number;
  123113. frontUVs?: Vector4;
  123114. backUVs?: Vector4;
  123115. instance?: Mesh;
  123116. invertUV?: boolean;
  123117. }, scene?: Nullable<Scene>): Mesh;
  123118. }
  123119. }
  123120. declare module BABYLON {
  123121. /**
  123122. * Class containing static functions to help procedurally build meshes
  123123. */
  123124. export class IcoSphereBuilder {
  123125. /**
  123126. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123127. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123128. * * 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`)
  123129. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123130. * * 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
  123131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123132. * * 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
  123133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123134. * @param name defines the name of the mesh
  123135. * @param options defines the options used to create the mesh
  123136. * @param scene defines the hosting scene
  123137. * @returns the icosahedron mesh
  123138. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123139. */
  123140. static CreateIcoSphere(name: string, options: {
  123141. radius?: number;
  123142. radiusX?: number;
  123143. radiusY?: number;
  123144. radiusZ?: number;
  123145. flat?: boolean;
  123146. subdivisions?: number;
  123147. sideOrientation?: number;
  123148. frontUVs?: Vector4;
  123149. backUVs?: Vector4;
  123150. updatable?: boolean;
  123151. }, scene?: Nullable<Scene>): Mesh;
  123152. }
  123153. }
  123154. declare module BABYLON {
  123155. /**
  123156. * Class containing static functions to help procedurally build meshes
  123157. */
  123158. export class DecalBuilder {
  123159. /**
  123160. * Creates a decal mesh.
  123161. * 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
  123162. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123163. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123164. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123165. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123166. * @param name defines the name of the mesh
  123167. * @param sourceMesh defines the mesh where the decal must be applied
  123168. * @param options defines the options used to create the mesh
  123169. * @param scene defines the hosting scene
  123170. * @returns the decal mesh
  123171. * @see https://doc.babylonjs.com/how_to/decals
  123172. */
  123173. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123174. position?: Vector3;
  123175. normal?: Vector3;
  123176. size?: Vector3;
  123177. angle?: number;
  123178. }): Mesh;
  123179. }
  123180. }
  123181. declare module BABYLON {
  123182. /**
  123183. * Class containing static functions to help procedurally build meshes
  123184. */
  123185. export class MeshBuilder {
  123186. /**
  123187. * Creates a box mesh
  123188. * * The parameter `size` sets the size (float) of each box side (default 1)
  123189. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  123190. * * 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)
  123191. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123193. * * 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
  123194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123195. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123196. * @param name defines the name of the mesh
  123197. * @param options defines the options used to create the mesh
  123198. * @param scene defines the hosting scene
  123199. * @returns the box mesh
  123200. */
  123201. static CreateBox(name: string, options: {
  123202. size?: number;
  123203. width?: number;
  123204. height?: number;
  123205. depth?: number;
  123206. faceUV?: Vector4[];
  123207. faceColors?: Color4[];
  123208. sideOrientation?: number;
  123209. frontUVs?: Vector4;
  123210. backUVs?: Vector4;
  123211. updatable?: boolean;
  123212. }, scene?: Nullable<Scene>): Mesh;
  123213. /**
  123214. * Creates a tiled box mesh
  123215. * * faceTiles sets the pattern, tile size and number of tiles for a face
  123216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123217. * @param name defines the name of the mesh
  123218. * @param options defines the options used to create the mesh
  123219. * @param scene defines the hosting scene
  123220. * @returns the tiled box mesh
  123221. */
  123222. static CreateTiledBox(name: string, options: {
  123223. pattern?: number;
  123224. size?: number;
  123225. width?: number;
  123226. height?: number;
  123227. depth: number;
  123228. tileSize?: number;
  123229. tileWidth?: number;
  123230. tileHeight?: number;
  123231. faceUV?: Vector4[];
  123232. faceColors?: Color4[];
  123233. alignHorizontal?: number;
  123234. alignVertical?: number;
  123235. sideOrientation?: number;
  123236. updatable?: boolean;
  123237. }, scene?: Nullable<Scene>): Mesh;
  123238. /**
  123239. * Creates a sphere mesh
  123240. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  123241. * * 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`)
  123242. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  123243. * * 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
  123244. * * 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)
  123245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123246. * * 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
  123247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123248. * @param name defines the name of the mesh
  123249. * @param options defines the options used to create the mesh
  123250. * @param scene defines the hosting scene
  123251. * @returns the sphere mesh
  123252. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  123253. */
  123254. static CreateSphere(name: string, options: {
  123255. segments?: number;
  123256. diameter?: number;
  123257. diameterX?: number;
  123258. diameterY?: number;
  123259. diameterZ?: number;
  123260. arc?: number;
  123261. slice?: number;
  123262. sideOrientation?: number;
  123263. frontUVs?: Vector4;
  123264. backUVs?: Vector4;
  123265. updatable?: boolean;
  123266. }, scene?: Nullable<Scene>): Mesh;
  123267. /**
  123268. * Creates a plane polygonal mesh. By default, this is a disc
  123269. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  123270. * * 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
  123271. * * 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
  123272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123273. * * 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
  123274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123275. * @param name defines the name of the mesh
  123276. * @param options defines the options used to create the mesh
  123277. * @param scene defines the hosting scene
  123278. * @returns the plane polygonal mesh
  123279. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  123280. */
  123281. static CreateDisc(name: string, options: {
  123282. radius?: number;
  123283. tessellation?: number;
  123284. arc?: number;
  123285. updatable?: boolean;
  123286. sideOrientation?: number;
  123287. frontUVs?: Vector4;
  123288. backUVs?: Vector4;
  123289. }, scene?: Nullable<Scene>): Mesh;
  123290. /**
  123291. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123292. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123293. * * 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`)
  123294. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123295. * * 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
  123296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123297. * * 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
  123298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123299. * @param name defines the name of the mesh
  123300. * @param options defines the options used to create the mesh
  123301. * @param scene defines the hosting scene
  123302. * @returns the icosahedron mesh
  123303. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123304. */
  123305. static CreateIcoSphere(name: string, options: {
  123306. radius?: number;
  123307. radiusX?: number;
  123308. radiusY?: number;
  123309. radiusZ?: number;
  123310. flat?: boolean;
  123311. subdivisions?: number;
  123312. sideOrientation?: number;
  123313. frontUVs?: Vector4;
  123314. backUVs?: Vector4;
  123315. updatable?: boolean;
  123316. }, scene?: Nullable<Scene>): Mesh;
  123317. /**
  123318. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123319. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  123320. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  123321. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  123322. * * 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
  123323. * * 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
  123324. * * 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
  123325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123326. * * 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
  123327. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123328. * * 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
  123329. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  123330. * * 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
  123331. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  123332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123333. * @param name defines the name of the mesh
  123334. * @param options defines the options used to create the mesh
  123335. * @param scene defines the hosting scene
  123336. * @returns the ribbon mesh
  123337. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  123338. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123339. */
  123340. static CreateRibbon(name: string, options: {
  123341. pathArray: Vector3[][];
  123342. closeArray?: boolean;
  123343. closePath?: boolean;
  123344. offset?: number;
  123345. updatable?: boolean;
  123346. sideOrientation?: number;
  123347. frontUVs?: Vector4;
  123348. backUVs?: Vector4;
  123349. instance?: Mesh;
  123350. invertUV?: boolean;
  123351. uvs?: Vector2[];
  123352. colors?: Color4[];
  123353. }, scene?: Nullable<Scene>): Mesh;
  123354. /**
  123355. * Creates a cylinder or a cone mesh
  123356. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123357. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123358. * * 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.
  123359. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123360. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123361. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123362. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123363. * * 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).
  123364. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123365. * * 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).
  123366. * * 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
  123367. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123368. * * 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
  123369. * * 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.
  123370. * * If `enclose` is false, a ring surface is one element.
  123371. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123372. * * 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
  123373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123374. * * 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
  123375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123376. * @param name defines the name of the mesh
  123377. * @param options defines the options used to create the mesh
  123378. * @param scene defines the hosting scene
  123379. * @returns the cylinder mesh
  123380. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123381. */
  123382. static CreateCylinder(name: string, options: {
  123383. height?: number;
  123384. diameterTop?: number;
  123385. diameterBottom?: number;
  123386. diameter?: number;
  123387. tessellation?: number;
  123388. subdivisions?: number;
  123389. arc?: number;
  123390. faceColors?: Color4[];
  123391. faceUV?: Vector4[];
  123392. updatable?: boolean;
  123393. hasRings?: boolean;
  123394. enclose?: boolean;
  123395. cap?: number;
  123396. sideOrientation?: number;
  123397. frontUVs?: Vector4;
  123398. backUVs?: Vector4;
  123399. }, scene?: Nullable<Scene>): Mesh;
  123400. /**
  123401. * Creates a torus mesh
  123402. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123403. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123404. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123406. * * 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
  123407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123408. * @param name defines the name of the mesh
  123409. * @param options defines the options used to create the mesh
  123410. * @param scene defines the hosting scene
  123411. * @returns the torus mesh
  123412. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123413. */
  123414. static CreateTorus(name: string, options: {
  123415. diameter?: number;
  123416. thickness?: number;
  123417. tessellation?: number;
  123418. updatable?: boolean;
  123419. sideOrientation?: number;
  123420. frontUVs?: Vector4;
  123421. backUVs?: Vector4;
  123422. }, scene?: Nullable<Scene>): Mesh;
  123423. /**
  123424. * Creates a torus knot mesh
  123425. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123426. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123427. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123428. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123430. * * 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
  123431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123432. * @param name defines the name of the mesh
  123433. * @param options defines the options used to create the mesh
  123434. * @param scene defines the hosting scene
  123435. * @returns the torus knot mesh
  123436. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123437. */
  123438. static CreateTorusKnot(name: string, options: {
  123439. radius?: number;
  123440. tube?: number;
  123441. radialSegments?: number;
  123442. tubularSegments?: number;
  123443. p?: number;
  123444. q?: number;
  123445. updatable?: boolean;
  123446. sideOrientation?: number;
  123447. frontUVs?: Vector4;
  123448. backUVs?: Vector4;
  123449. }, scene?: Nullable<Scene>): Mesh;
  123450. /**
  123451. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  123452. * * 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
  123453. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  123454. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  123455. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  123456. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  123457. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  123458. * * 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
  123459. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  123460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123461. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  123462. * @param name defines the name of the new line system
  123463. * @param options defines the options used to create the line system
  123464. * @param scene defines the hosting scene
  123465. * @returns a new line system mesh
  123466. */
  123467. static CreateLineSystem(name: string, options: {
  123468. lines: Vector3[][];
  123469. updatable?: boolean;
  123470. instance?: Nullable<LinesMesh>;
  123471. colors?: Nullable<Color4[][]>;
  123472. useVertexAlpha?: boolean;
  123473. }, scene: Nullable<Scene>): LinesMesh;
  123474. /**
  123475. * Creates a line mesh
  123476. * 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
  123477. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123478. * * The parameter `points` is an array successive Vector3
  123479. * * 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
  123480. * * The optional parameter `colors` is an array of successive Color4, one per line point
  123481. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  123482. * * When updating an instance, remember that only point positions can change, not the number of points
  123483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123484. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  123485. * @param name defines the name of the new line system
  123486. * @param options defines the options used to create the line system
  123487. * @param scene defines the hosting scene
  123488. * @returns a new line mesh
  123489. */
  123490. static CreateLines(name: string, options: {
  123491. points: Vector3[];
  123492. updatable?: boolean;
  123493. instance?: Nullable<LinesMesh>;
  123494. colors?: Color4[];
  123495. useVertexAlpha?: boolean;
  123496. }, scene?: Nullable<Scene>): LinesMesh;
  123497. /**
  123498. * Creates a dashed line mesh
  123499. * * 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
  123500. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123501. * * The parameter `points` is an array successive Vector3
  123502. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  123503. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  123504. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  123505. * * 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
  123506. * * When updating an instance, remember that only point positions can change, not the number of points
  123507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123508. * @param name defines the name of the mesh
  123509. * @param options defines the options used to create the mesh
  123510. * @param scene defines the hosting scene
  123511. * @returns the dashed line mesh
  123512. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  123513. */
  123514. static CreateDashedLines(name: string, options: {
  123515. points: Vector3[];
  123516. dashSize?: number;
  123517. gapSize?: number;
  123518. dashNb?: number;
  123519. updatable?: boolean;
  123520. instance?: LinesMesh;
  123521. }, scene?: Nullable<Scene>): LinesMesh;
  123522. /**
  123523. * 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.
  123524. * * 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.
  123525. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123526. * * 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.
  123527. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  123528. * * 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
  123529. * * 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
  123530. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  123531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123532. * * 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
  123533. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  123534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123535. * @param name defines the name of the mesh
  123536. * @param options defines the options used to create the mesh
  123537. * @param scene defines the hosting scene
  123538. * @returns the extruded shape mesh
  123539. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123540. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123541. */
  123542. static ExtrudeShape(name: string, options: {
  123543. shape: Vector3[];
  123544. path: Vector3[];
  123545. scale?: number;
  123546. rotation?: number;
  123547. cap?: number;
  123548. updatable?: boolean;
  123549. sideOrientation?: number;
  123550. frontUVs?: Vector4;
  123551. backUVs?: Vector4;
  123552. instance?: Mesh;
  123553. invertUV?: boolean;
  123554. }, scene?: Nullable<Scene>): Mesh;
  123555. /**
  123556. * Creates an custom extruded shape mesh.
  123557. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  123558. * * 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.
  123559. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123560. * * 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
  123561. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  123562. * * 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
  123563. * * It must returns a float value that will be the scale value applied to the shape on each path point
  123564. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  123565. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  123566. * * 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
  123567. * * 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
  123568. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  123569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123570. * * 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
  123571. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123573. * @param name defines the name of the mesh
  123574. * @param options defines the options used to create the mesh
  123575. * @param scene defines the hosting scene
  123576. * @returns the custom extruded shape mesh
  123577. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  123578. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123580. */
  123581. static ExtrudeShapeCustom(name: string, options: {
  123582. shape: Vector3[];
  123583. path: Vector3[];
  123584. scaleFunction?: any;
  123585. rotationFunction?: any;
  123586. ribbonCloseArray?: boolean;
  123587. ribbonClosePath?: boolean;
  123588. cap?: number;
  123589. updatable?: boolean;
  123590. sideOrientation?: number;
  123591. frontUVs?: Vector4;
  123592. backUVs?: Vector4;
  123593. instance?: Mesh;
  123594. invertUV?: boolean;
  123595. }, scene?: Nullable<Scene>): Mesh;
  123596. /**
  123597. * Creates lathe mesh.
  123598. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123599. * * 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
  123600. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123601. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123602. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123603. * * 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
  123604. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123605. * * 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
  123606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123607. * * 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
  123608. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123610. * @param name defines the name of the mesh
  123611. * @param options defines the options used to create the mesh
  123612. * @param scene defines the hosting scene
  123613. * @returns the lathe mesh
  123614. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123615. */
  123616. static CreateLathe(name: string, options: {
  123617. shape: Vector3[];
  123618. radius?: number;
  123619. tessellation?: number;
  123620. clip?: number;
  123621. arc?: number;
  123622. closed?: boolean;
  123623. updatable?: boolean;
  123624. sideOrientation?: number;
  123625. frontUVs?: Vector4;
  123626. backUVs?: Vector4;
  123627. cap?: number;
  123628. invertUV?: boolean;
  123629. }, scene?: Nullable<Scene>): Mesh;
  123630. /**
  123631. * Creates a tiled plane mesh
  123632. * * You can set a limited pattern arrangement with the tiles
  123633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123634. * * 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
  123635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123636. * @param name defines the name of the mesh
  123637. * @param options defines the options used to create the mesh
  123638. * @param scene defines the hosting scene
  123639. * @returns the plane mesh
  123640. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123641. */
  123642. static CreateTiledPlane(name: string, options: {
  123643. pattern?: number;
  123644. tileSize?: number;
  123645. tileWidth?: number;
  123646. tileHeight?: number;
  123647. size?: number;
  123648. width?: number;
  123649. height?: number;
  123650. alignHorizontal?: number;
  123651. alignVertical?: number;
  123652. sideOrientation?: number;
  123653. frontUVs?: Vector4;
  123654. backUVs?: Vector4;
  123655. updatable?: boolean;
  123656. }, scene?: Nullable<Scene>): Mesh;
  123657. /**
  123658. * Creates a plane mesh
  123659. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123660. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123661. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123663. * * 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
  123664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123665. * @param name defines the name of the mesh
  123666. * @param options defines the options used to create the mesh
  123667. * @param scene defines the hosting scene
  123668. * @returns the plane mesh
  123669. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123670. */
  123671. static CreatePlane(name: string, options: {
  123672. size?: number;
  123673. width?: number;
  123674. height?: number;
  123675. sideOrientation?: number;
  123676. frontUVs?: Vector4;
  123677. backUVs?: Vector4;
  123678. updatable?: boolean;
  123679. sourcePlane?: Plane;
  123680. }, scene?: Nullable<Scene>): Mesh;
  123681. /**
  123682. * Creates a ground mesh
  123683. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123684. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123686. * @param name defines the name of the mesh
  123687. * @param options defines the options used to create the mesh
  123688. * @param scene defines the hosting scene
  123689. * @returns the ground mesh
  123690. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123691. */
  123692. static CreateGround(name: string, options: {
  123693. width?: number;
  123694. height?: number;
  123695. subdivisions?: number;
  123696. subdivisionsX?: number;
  123697. subdivisionsY?: number;
  123698. updatable?: boolean;
  123699. }, scene?: Nullable<Scene>): Mesh;
  123700. /**
  123701. * Creates a tiled ground mesh
  123702. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123703. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123704. * * 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
  123705. * * 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
  123706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123707. * @param name defines the name of the mesh
  123708. * @param options defines the options used to create the mesh
  123709. * @param scene defines the hosting scene
  123710. * @returns the tiled ground mesh
  123711. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123712. */
  123713. static CreateTiledGround(name: string, options: {
  123714. xmin: number;
  123715. zmin: number;
  123716. xmax: number;
  123717. zmax: number;
  123718. subdivisions?: {
  123719. w: number;
  123720. h: number;
  123721. };
  123722. precision?: {
  123723. w: number;
  123724. h: number;
  123725. };
  123726. updatable?: boolean;
  123727. }, scene?: Nullable<Scene>): Mesh;
  123728. /**
  123729. * Creates a ground mesh from a height map
  123730. * * The parameter `url` sets the URL of the height map image resource.
  123731. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123732. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123733. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123734. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123735. * * 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.
  123736. * * 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).
  123737. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123739. * @param name defines the name of the mesh
  123740. * @param url defines the url to the height map
  123741. * @param options defines the options used to create the mesh
  123742. * @param scene defines the hosting scene
  123743. * @returns the ground mesh
  123744. * @see https://doc.babylonjs.com/babylon101/height_map
  123745. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123746. */
  123747. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123748. width?: number;
  123749. height?: number;
  123750. subdivisions?: number;
  123751. minHeight?: number;
  123752. maxHeight?: number;
  123753. colorFilter?: Color3;
  123754. alphaFilter?: number;
  123755. updatable?: boolean;
  123756. onReady?: (mesh: GroundMesh) => void;
  123757. }, scene?: Nullable<Scene>): GroundMesh;
  123758. /**
  123759. * Creates a polygon mesh
  123760. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123761. * * 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
  123762. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123764. * * 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)
  123765. * * Remember you can only change the shape positions, not their number when updating a polygon
  123766. * @param name defines the name of the mesh
  123767. * @param options defines the options used to create the mesh
  123768. * @param scene defines the hosting scene
  123769. * @param earcutInjection can be used to inject your own earcut reference
  123770. * @returns the polygon mesh
  123771. */
  123772. static CreatePolygon(name: string, options: {
  123773. shape: Vector3[];
  123774. holes?: Vector3[][];
  123775. depth?: number;
  123776. faceUV?: Vector4[];
  123777. faceColors?: Color4[];
  123778. updatable?: boolean;
  123779. sideOrientation?: number;
  123780. frontUVs?: Vector4;
  123781. backUVs?: Vector4;
  123782. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123783. /**
  123784. * Creates an extruded polygon mesh, with depth in the Y direction.
  123785. * * 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)
  123786. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123787. * @param name defines the name of the mesh
  123788. * @param options defines the options used to create the mesh
  123789. * @param scene defines the hosting scene
  123790. * @param earcutInjection can be used to inject your own earcut reference
  123791. * @returns the polygon mesh
  123792. */
  123793. static ExtrudePolygon(name: string, options: {
  123794. shape: Vector3[];
  123795. holes?: Vector3[][];
  123796. depth?: number;
  123797. faceUV?: Vector4[];
  123798. faceColors?: Color4[];
  123799. updatable?: boolean;
  123800. sideOrientation?: number;
  123801. frontUVs?: Vector4;
  123802. backUVs?: Vector4;
  123803. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123804. /**
  123805. * Creates a tube mesh.
  123806. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123807. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123808. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123809. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123810. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123811. * * 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)
  123812. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123813. * * 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
  123814. * * 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
  123815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123816. * * 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
  123817. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123819. * @param name defines the name of the mesh
  123820. * @param options defines the options used to create the mesh
  123821. * @param scene defines the hosting scene
  123822. * @returns the tube mesh
  123823. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123824. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123825. */
  123826. static CreateTube(name: string, options: {
  123827. path: Vector3[];
  123828. radius?: number;
  123829. tessellation?: number;
  123830. radiusFunction?: {
  123831. (i: number, distance: number): number;
  123832. };
  123833. cap?: number;
  123834. arc?: number;
  123835. updatable?: boolean;
  123836. sideOrientation?: number;
  123837. frontUVs?: Vector4;
  123838. backUVs?: Vector4;
  123839. instance?: Mesh;
  123840. invertUV?: boolean;
  123841. }, scene?: Nullable<Scene>): Mesh;
  123842. /**
  123843. * Creates a polyhedron mesh
  123844. * * 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
  123845. * * The parameter `size` (positive float, default 1) sets the polygon size
  123846. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123847. * * 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`
  123848. * * 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
  123849. * * 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)`)
  123850. * * 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
  123851. * * 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
  123852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123853. * * 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
  123854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123855. * @param name defines the name of the mesh
  123856. * @param options defines the options used to create the mesh
  123857. * @param scene defines the hosting scene
  123858. * @returns the polyhedron mesh
  123859. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123860. */
  123861. static CreatePolyhedron(name: string, options: {
  123862. type?: number;
  123863. size?: number;
  123864. sizeX?: number;
  123865. sizeY?: number;
  123866. sizeZ?: number;
  123867. custom?: any;
  123868. faceUV?: Vector4[];
  123869. faceColors?: Color4[];
  123870. flat?: boolean;
  123871. updatable?: boolean;
  123872. sideOrientation?: number;
  123873. frontUVs?: Vector4;
  123874. backUVs?: Vector4;
  123875. }, scene?: Nullable<Scene>): Mesh;
  123876. /**
  123877. * Creates a decal mesh.
  123878. * 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
  123879. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123880. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123881. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123882. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123883. * @param name defines the name of the mesh
  123884. * @param sourceMesh defines the mesh where the decal must be applied
  123885. * @param options defines the options used to create the mesh
  123886. * @param scene defines the hosting scene
  123887. * @returns the decal mesh
  123888. * @see https://doc.babylonjs.com/how_to/decals
  123889. */
  123890. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123891. position?: Vector3;
  123892. normal?: Vector3;
  123893. size?: Vector3;
  123894. angle?: number;
  123895. }): Mesh;
  123896. }
  123897. }
  123898. declare module BABYLON {
  123899. /**
  123900. * A simplifier interface for future simplification implementations
  123901. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123902. */
  123903. export interface ISimplifier {
  123904. /**
  123905. * Simplification of a given mesh according to the given settings.
  123906. * Since this requires computation, it is assumed that the function runs async.
  123907. * @param settings The settings of the simplification, including quality and distance
  123908. * @param successCallback A callback that will be called after the mesh was simplified.
  123909. * @param errorCallback in case of an error, this callback will be called. optional.
  123910. */
  123911. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  123912. }
  123913. /**
  123914. * Expected simplification settings.
  123915. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  123916. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123917. */
  123918. export interface ISimplificationSettings {
  123919. /**
  123920. * Gets or sets the expected quality
  123921. */
  123922. quality: number;
  123923. /**
  123924. * Gets or sets the distance when this optimized version should be used
  123925. */
  123926. distance: number;
  123927. /**
  123928. * Gets an already optimized mesh
  123929. */
  123930. optimizeMesh?: boolean;
  123931. }
  123932. /**
  123933. * Class used to specify simplification options
  123934. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123935. */
  123936. export class SimplificationSettings implements ISimplificationSettings {
  123937. /** expected quality */
  123938. quality: number;
  123939. /** distance when this optimized version should be used */
  123940. distance: number;
  123941. /** already optimized mesh */
  123942. optimizeMesh?: boolean | undefined;
  123943. /**
  123944. * Creates a SimplificationSettings
  123945. * @param quality expected quality
  123946. * @param distance distance when this optimized version should be used
  123947. * @param optimizeMesh already optimized mesh
  123948. */
  123949. constructor(
  123950. /** expected quality */
  123951. quality: number,
  123952. /** distance when this optimized version should be used */
  123953. distance: number,
  123954. /** already optimized mesh */
  123955. optimizeMesh?: boolean | undefined);
  123956. }
  123957. /**
  123958. * Interface used to define a simplification task
  123959. */
  123960. export interface ISimplificationTask {
  123961. /**
  123962. * Array of settings
  123963. */
  123964. settings: Array<ISimplificationSettings>;
  123965. /**
  123966. * Simplification type
  123967. */
  123968. simplificationType: SimplificationType;
  123969. /**
  123970. * Mesh to simplify
  123971. */
  123972. mesh: Mesh;
  123973. /**
  123974. * Callback called on success
  123975. */
  123976. successCallback?: () => void;
  123977. /**
  123978. * Defines if parallel processing can be used
  123979. */
  123980. parallelProcessing: boolean;
  123981. }
  123982. /**
  123983. * Queue used to order the simplification tasks
  123984. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123985. */
  123986. export class SimplificationQueue {
  123987. private _simplificationArray;
  123988. /**
  123989. * Gets a boolean indicating that the process is still running
  123990. */
  123991. running: boolean;
  123992. /**
  123993. * Creates a new queue
  123994. */
  123995. constructor();
  123996. /**
  123997. * Adds a new simplification task
  123998. * @param task defines a task to add
  123999. */
  124000. addTask(task: ISimplificationTask): void;
  124001. /**
  124002. * Execute next task
  124003. */
  124004. executeNext(): void;
  124005. /**
  124006. * Execute a simplification task
  124007. * @param task defines the task to run
  124008. */
  124009. runSimplification(task: ISimplificationTask): void;
  124010. private getSimplifier;
  124011. }
  124012. /**
  124013. * The implemented types of simplification
  124014. * At the moment only Quadratic Error Decimation is implemented
  124015. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124016. */
  124017. export enum SimplificationType {
  124018. /** Quadratic error decimation */
  124019. QUADRATIC = 0
  124020. }
  124021. }
  124022. declare module BABYLON {
  124023. interface Scene {
  124024. /** @hidden (Backing field) */
  124025. _simplificationQueue: SimplificationQueue;
  124026. /**
  124027. * Gets or sets the simplification queue attached to the scene
  124028. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124029. */
  124030. simplificationQueue: SimplificationQueue;
  124031. }
  124032. interface Mesh {
  124033. /**
  124034. * Simplify the mesh according to the given array of settings.
  124035. * Function will return immediately and will simplify async
  124036. * @param settings a collection of simplification settings
  124037. * @param parallelProcessing should all levels calculate parallel or one after the other
  124038. * @param simplificationType the type of simplification to run
  124039. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  124040. * @returns the current mesh
  124041. */
  124042. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  124043. }
  124044. /**
  124045. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  124046. * created in a scene
  124047. */
  124048. export class SimplicationQueueSceneComponent implements ISceneComponent {
  124049. /**
  124050. * The component name helpfull to identify the component in the list of scene components.
  124051. */
  124052. readonly name: string;
  124053. /**
  124054. * The scene the component belongs to.
  124055. */
  124056. scene: Scene;
  124057. /**
  124058. * Creates a new instance of the component for the given scene
  124059. * @param scene Defines the scene to register the component in
  124060. */
  124061. constructor(scene: Scene);
  124062. /**
  124063. * Registers the component in a given scene
  124064. */
  124065. register(): void;
  124066. /**
  124067. * Rebuilds the elements related to this component in case of
  124068. * context lost for instance.
  124069. */
  124070. rebuild(): void;
  124071. /**
  124072. * Disposes the component and the associated ressources
  124073. */
  124074. dispose(): void;
  124075. private _beforeCameraUpdate;
  124076. }
  124077. }
  124078. declare module BABYLON {
  124079. /**
  124080. * Navigation plugin interface to add navigation constrained by a navigation mesh
  124081. */
  124082. export interface INavigationEnginePlugin {
  124083. /**
  124084. * plugin name
  124085. */
  124086. name: string;
  124087. /**
  124088. * Creates a navigation mesh
  124089. * @param meshes array of all the geometry used to compute the navigatio mesh
  124090. * @param parameters bunch of parameters used to filter geometry
  124091. */
  124092. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124093. /**
  124094. * Create a navigation mesh debug mesh
  124095. * @param scene is where the mesh will be added
  124096. * @returns debug display mesh
  124097. */
  124098. createDebugNavMesh(scene: Scene): Mesh;
  124099. /**
  124100. * Get a navigation mesh constrained position, closest to the parameter position
  124101. * @param position world position
  124102. * @returns the closest point to position constrained by the navigation mesh
  124103. */
  124104. getClosestPoint(position: Vector3): Vector3;
  124105. /**
  124106. * Get a navigation mesh constrained position, within a particular radius
  124107. * @param position world position
  124108. * @param maxRadius the maximum distance to the constrained world position
  124109. * @returns the closest point to position constrained by the navigation mesh
  124110. */
  124111. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124112. /**
  124113. * Compute the final position from a segment made of destination-position
  124114. * @param position world position
  124115. * @param destination world position
  124116. * @returns the resulting point along the navmesh
  124117. */
  124118. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124119. /**
  124120. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124121. * @param start world position
  124122. * @param end world position
  124123. * @returns array containing world position composing the path
  124124. */
  124125. computePath(start: Vector3, end: Vector3): Vector3[];
  124126. /**
  124127. * If this plugin is supported
  124128. * @returns true if plugin is supported
  124129. */
  124130. isSupported(): boolean;
  124131. /**
  124132. * Create a new Crowd so you can add agents
  124133. * @param maxAgents the maximum agent count in the crowd
  124134. * @param maxAgentRadius the maximum radius an agent can have
  124135. * @param scene to attach the crowd to
  124136. * @returns the crowd you can add agents to
  124137. */
  124138. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124139. /**
  124140. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124141. * The queries will try to find a solution within those bounds
  124142. * default is (1,1,1)
  124143. * @param extent x,y,z value that define the extent around the queries point of reference
  124144. */
  124145. setDefaultQueryExtent(extent: Vector3): void;
  124146. /**
  124147. * Get the Bounding box extent specified by setDefaultQueryExtent
  124148. * @returns the box extent values
  124149. */
  124150. getDefaultQueryExtent(): Vector3;
  124151. /**
  124152. * Release all resources
  124153. */
  124154. dispose(): void;
  124155. }
  124156. /**
  124157. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  124158. */
  124159. export interface ICrowd {
  124160. /**
  124161. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124162. * You can attach anything to that node. The node position is updated in the scene update tick.
  124163. * @param pos world position that will be constrained by the navigation mesh
  124164. * @param parameters agent parameters
  124165. * @param transform hooked to the agent that will be update by the scene
  124166. * @returns agent index
  124167. */
  124168. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124169. /**
  124170. * Returns the agent position in world space
  124171. * @param index agent index returned by addAgent
  124172. * @returns world space position
  124173. */
  124174. getAgentPosition(index: number): Vector3;
  124175. /**
  124176. * Gets the agent velocity in world space
  124177. * @param index agent index returned by addAgent
  124178. * @returns world space velocity
  124179. */
  124180. getAgentVelocity(index: number): Vector3;
  124181. /**
  124182. * remove a particular agent previously created
  124183. * @param index agent index returned by addAgent
  124184. */
  124185. removeAgent(index: number): void;
  124186. /**
  124187. * get the list of all agents attached to this crowd
  124188. * @returns list of agent indices
  124189. */
  124190. getAgents(): number[];
  124191. /**
  124192. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124193. * @param deltaTime in seconds
  124194. */
  124195. update(deltaTime: number): void;
  124196. /**
  124197. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124198. * @param index agent index returned by addAgent
  124199. * @param destination targeted world position
  124200. */
  124201. agentGoto(index: number, destination: Vector3): void;
  124202. /**
  124203. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124204. * The queries will try to find a solution within those bounds
  124205. * default is (1,1,1)
  124206. * @param extent x,y,z value that define the extent around the queries point of reference
  124207. */
  124208. setDefaultQueryExtent(extent: Vector3): void;
  124209. /**
  124210. * Get the Bounding box extent specified by setDefaultQueryExtent
  124211. * @returns the box extent values
  124212. */
  124213. getDefaultQueryExtent(): Vector3;
  124214. /**
  124215. * Release all resources
  124216. */
  124217. dispose(): void;
  124218. }
  124219. /**
  124220. * Configures an agent
  124221. */
  124222. export interface IAgentParameters {
  124223. /**
  124224. * Agent radius. [Limit: >= 0]
  124225. */
  124226. radius: number;
  124227. /**
  124228. * Agent height. [Limit: > 0]
  124229. */
  124230. height: number;
  124231. /**
  124232. * Maximum allowed acceleration. [Limit: >= 0]
  124233. */
  124234. maxAcceleration: number;
  124235. /**
  124236. * Maximum allowed speed. [Limit: >= 0]
  124237. */
  124238. maxSpeed: number;
  124239. /**
  124240. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  124241. */
  124242. collisionQueryRange: number;
  124243. /**
  124244. * The path visibility optimization range. [Limit: > 0]
  124245. */
  124246. pathOptimizationRange: number;
  124247. /**
  124248. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  124249. */
  124250. separationWeight: number;
  124251. }
  124252. /**
  124253. * Configures the navigation mesh creation
  124254. */
  124255. export interface INavMeshParameters {
  124256. /**
  124257. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  124258. */
  124259. cs: number;
  124260. /**
  124261. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  124262. */
  124263. ch: number;
  124264. /**
  124265. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  124266. */
  124267. walkableSlopeAngle: number;
  124268. /**
  124269. * Minimum floor to 'ceiling' height that will still allow the floor area to
  124270. * be considered walkable. [Limit: >= 3] [Units: vx]
  124271. */
  124272. walkableHeight: number;
  124273. /**
  124274. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  124275. */
  124276. walkableClimb: number;
  124277. /**
  124278. * The distance to erode/shrink the walkable area of the heightfield away from
  124279. * obstructions. [Limit: >=0] [Units: vx]
  124280. */
  124281. walkableRadius: number;
  124282. /**
  124283. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  124284. */
  124285. maxEdgeLen: number;
  124286. /**
  124287. * The maximum distance a simplfied contour's border edges should deviate
  124288. * the original raw contour. [Limit: >=0] [Units: vx]
  124289. */
  124290. maxSimplificationError: number;
  124291. /**
  124292. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  124293. */
  124294. minRegionArea: number;
  124295. /**
  124296. * Any regions with a span count smaller than this value will, if possible,
  124297. * be merged with larger regions. [Limit: >=0] [Units: vx]
  124298. */
  124299. mergeRegionArea: number;
  124300. /**
  124301. * The maximum number of vertices allowed for polygons generated during the
  124302. * contour to polygon conversion process. [Limit: >= 3]
  124303. */
  124304. maxVertsPerPoly: number;
  124305. /**
  124306. * Sets the sampling distance to use when generating the detail mesh.
  124307. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  124308. */
  124309. detailSampleDist: number;
  124310. /**
  124311. * The maximum distance the detail mesh surface should deviate from heightfield
  124312. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  124313. */
  124314. detailSampleMaxError: number;
  124315. }
  124316. }
  124317. declare module BABYLON {
  124318. /**
  124319. * RecastJS navigation plugin
  124320. */
  124321. export class RecastJSPlugin implements INavigationEnginePlugin {
  124322. /**
  124323. * Reference to the Recast library
  124324. */
  124325. bjsRECAST: any;
  124326. /**
  124327. * plugin name
  124328. */
  124329. name: string;
  124330. /**
  124331. * the first navmesh created. We might extend this to support multiple navmeshes
  124332. */
  124333. navMesh: any;
  124334. /**
  124335. * Initializes the recastJS plugin
  124336. * @param recastInjection can be used to inject your own recast reference
  124337. */
  124338. constructor(recastInjection?: any);
  124339. /**
  124340. * Creates a navigation mesh
  124341. * @param meshes array of all the geometry used to compute the navigatio mesh
  124342. * @param parameters bunch of parameters used to filter geometry
  124343. */
  124344. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124345. /**
  124346. * Create a navigation mesh debug mesh
  124347. * @param scene is where the mesh will be added
  124348. * @returns debug display mesh
  124349. */
  124350. createDebugNavMesh(scene: Scene): Mesh;
  124351. /**
  124352. * Get a navigation mesh constrained position, closest to the parameter position
  124353. * @param position world position
  124354. * @returns the closest point to position constrained by the navigation mesh
  124355. */
  124356. getClosestPoint(position: Vector3): Vector3;
  124357. /**
  124358. * Get a navigation mesh constrained position, within a particular radius
  124359. * @param position world position
  124360. * @param maxRadius the maximum distance to the constrained world position
  124361. * @returns the closest point to position constrained by the navigation mesh
  124362. */
  124363. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124364. /**
  124365. * Compute the final position from a segment made of destination-position
  124366. * @param position world position
  124367. * @param destination world position
  124368. * @returns the resulting point along the navmesh
  124369. */
  124370. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124371. /**
  124372. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124373. * @param start world position
  124374. * @param end world position
  124375. * @returns array containing world position composing the path
  124376. */
  124377. computePath(start: Vector3, end: Vector3): Vector3[];
  124378. /**
  124379. * Create a new Crowd so you can add agents
  124380. * @param maxAgents the maximum agent count in the crowd
  124381. * @param maxAgentRadius the maximum radius an agent can have
  124382. * @param scene to attach the crowd to
  124383. * @returns the crowd you can add agents to
  124384. */
  124385. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124386. /**
  124387. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124388. * The queries will try to find a solution within those bounds
  124389. * default is (1,1,1)
  124390. * @param extent x,y,z value that define the extent around the queries point of reference
  124391. */
  124392. setDefaultQueryExtent(extent: Vector3): void;
  124393. /**
  124394. * Get the Bounding box extent specified by setDefaultQueryExtent
  124395. * @returns the box extent values
  124396. */
  124397. getDefaultQueryExtent(): Vector3;
  124398. /**
  124399. * Disposes
  124400. */
  124401. dispose(): void;
  124402. /**
  124403. * If this plugin is supported
  124404. * @returns true if plugin is supported
  124405. */
  124406. isSupported(): boolean;
  124407. }
  124408. /**
  124409. * Recast detour crowd implementation
  124410. */
  124411. export class RecastJSCrowd implements ICrowd {
  124412. /**
  124413. * Recast/detour plugin
  124414. */
  124415. bjsRECASTPlugin: RecastJSPlugin;
  124416. /**
  124417. * Link to the detour crowd
  124418. */
  124419. recastCrowd: any;
  124420. /**
  124421. * One transform per agent
  124422. */
  124423. transforms: TransformNode[];
  124424. /**
  124425. * All agents created
  124426. */
  124427. agents: number[];
  124428. /**
  124429. * Link to the scene is kept to unregister the crowd from the scene
  124430. */
  124431. private _scene;
  124432. /**
  124433. * Observer for crowd updates
  124434. */
  124435. private _onBeforeAnimationsObserver;
  124436. /**
  124437. * Constructor
  124438. * @param plugin recastJS plugin
  124439. * @param maxAgents the maximum agent count in the crowd
  124440. * @param maxAgentRadius the maximum radius an agent can have
  124441. * @param scene to attach the crowd to
  124442. * @returns the crowd you can add agents to
  124443. */
  124444. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  124445. /**
  124446. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124447. * You can attach anything to that node. The node position is updated in the scene update tick.
  124448. * @param pos world position that will be constrained by the navigation mesh
  124449. * @param parameters agent parameters
  124450. * @param transform hooked to the agent that will be update by the scene
  124451. * @returns agent index
  124452. */
  124453. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124454. /**
  124455. * Returns the agent position in world space
  124456. * @param index agent index returned by addAgent
  124457. * @returns world space position
  124458. */
  124459. getAgentPosition(index: number): Vector3;
  124460. /**
  124461. * Returns the agent velocity in world space
  124462. * @param index agent index returned by addAgent
  124463. * @returns world space velocity
  124464. */
  124465. getAgentVelocity(index: number): Vector3;
  124466. /**
  124467. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124468. * @param index agent index returned by addAgent
  124469. * @param destination targeted world position
  124470. */
  124471. agentGoto(index: number, destination: Vector3): void;
  124472. /**
  124473. * remove a particular agent previously created
  124474. * @param index agent index returned by addAgent
  124475. */
  124476. removeAgent(index: number): void;
  124477. /**
  124478. * get the list of all agents attached to this crowd
  124479. * @returns list of agent indices
  124480. */
  124481. getAgents(): number[];
  124482. /**
  124483. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124484. * @param deltaTime in seconds
  124485. */
  124486. update(deltaTime: number): void;
  124487. /**
  124488. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124489. * The queries will try to find a solution within those bounds
  124490. * default is (1,1,1)
  124491. * @param extent x,y,z value that define the extent around the queries point of reference
  124492. */
  124493. setDefaultQueryExtent(extent: Vector3): void;
  124494. /**
  124495. * Get the Bounding box extent specified by setDefaultQueryExtent
  124496. * @returns the box extent values
  124497. */
  124498. getDefaultQueryExtent(): Vector3;
  124499. /**
  124500. * Release all resources
  124501. */
  124502. dispose(): void;
  124503. }
  124504. }
  124505. declare module BABYLON {
  124506. /**
  124507. * Class used to enable access to IndexedDB
  124508. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124509. */
  124510. export class Database implements IOfflineProvider {
  124511. private _callbackManifestChecked;
  124512. private _currentSceneUrl;
  124513. private _db;
  124514. private _enableSceneOffline;
  124515. private _enableTexturesOffline;
  124516. private _manifestVersionFound;
  124517. private _mustUpdateRessources;
  124518. private _hasReachedQuota;
  124519. private _isSupported;
  124520. private _idbFactory;
  124521. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  124522. private static IsUASupportingBlobStorage;
  124523. /**
  124524. * Gets a boolean indicating if Database storate is enabled (off by default)
  124525. */
  124526. static IDBStorageEnabled: boolean;
  124527. /**
  124528. * Gets a boolean indicating if scene must be saved in the database
  124529. */
  124530. readonly enableSceneOffline: boolean;
  124531. /**
  124532. * Gets a boolean indicating if textures must be saved in the database
  124533. */
  124534. readonly enableTexturesOffline: boolean;
  124535. /**
  124536. * Creates a new Database
  124537. * @param urlToScene defines the url to load the scene
  124538. * @param callbackManifestChecked defines the callback to use when manifest is checked
  124539. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  124540. */
  124541. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  124542. private static _ParseURL;
  124543. private static _ReturnFullUrlLocation;
  124544. private _checkManifestFile;
  124545. /**
  124546. * Open the database and make it available
  124547. * @param successCallback defines the callback to call on success
  124548. * @param errorCallback defines the callback to call on error
  124549. */
  124550. open(successCallback: () => void, errorCallback: () => void): void;
  124551. /**
  124552. * Loads an image from the database
  124553. * @param url defines the url to load from
  124554. * @param image defines the target DOM image
  124555. */
  124556. loadImage(url: string, image: HTMLImageElement): void;
  124557. private _loadImageFromDBAsync;
  124558. private _saveImageIntoDBAsync;
  124559. private _checkVersionFromDB;
  124560. private _loadVersionFromDBAsync;
  124561. private _saveVersionIntoDBAsync;
  124562. /**
  124563. * Loads a file from database
  124564. * @param url defines the URL to load from
  124565. * @param sceneLoaded defines a callback to call on success
  124566. * @param progressCallBack defines a callback to call when progress changed
  124567. * @param errorCallback defines a callback to call on error
  124568. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  124569. */
  124570. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  124571. private _loadFileAsync;
  124572. private _saveFileAsync;
  124573. /**
  124574. * Validates if xhr data is correct
  124575. * @param xhr defines the request to validate
  124576. * @param dataType defines the expected data type
  124577. * @returns true if data is correct
  124578. */
  124579. private static _ValidateXHRData;
  124580. }
  124581. }
  124582. declare module BABYLON {
  124583. /** @hidden */
  124584. export var gpuUpdateParticlesPixelShader: {
  124585. name: string;
  124586. shader: string;
  124587. };
  124588. }
  124589. declare module BABYLON {
  124590. /** @hidden */
  124591. export var gpuUpdateParticlesVertexShader: {
  124592. name: string;
  124593. shader: string;
  124594. };
  124595. }
  124596. declare module BABYLON {
  124597. /** @hidden */
  124598. export var clipPlaneFragmentDeclaration2: {
  124599. name: string;
  124600. shader: string;
  124601. };
  124602. }
  124603. declare module BABYLON {
  124604. /** @hidden */
  124605. export var gpuRenderParticlesPixelShader: {
  124606. name: string;
  124607. shader: string;
  124608. };
  124609. }
  124610. declare module BABYLON {
  124611. /** @hidden */
  124612. export var clipPlaneVertexDeclaration2: {
  124613. name: string;
  124614. shader: string;
  124615. };
  124616. }
  124617. declare module BABYLON {
  124618. /** @hidden */
  124619. export var gpuRenderParticlesVertexShader: {
  124620. name: string;
  124621. shader: string;
  124622. };
  124623. }
  124624. declare module BABYLON {
  124625. /**
  124626. * This represents a GPU particle system in Babylon
  124627. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  124628. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  124629. */
  124630. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  124631. /**
  124632. * The layer mask we are rendering the particles through.
  124633. */
  124634. layerMask: number;
  124635. private _capacity;
  124636. private _activeCount;
  124637. private _currentActiveCount;
  124638. private _accumulatedCount;
  124639. private _renderEffect;
  124640. private _updateEffect;
  124641. private _buffer0;
  124642. private _buffer1;
  124643. private _spriteBuffer;
  124644. private _updateVAO;
  124645. private _renderVAO;
  124646. private _targetIndex;
  124647. private _sourceBuffer;
  124648. private _targetBuffer;
  124649. private _engine;
  124650. private _currentRenderId;
  124651. private _started;
  124652. private _stopped;
  124653. private _timeDelta;
  124654. private _randomTexture;
  124655. private _randomTexture2;
  124656. private _attributesStrideSize;
  124657. private _updateEffectOptions;
  124658. private _randomTextureSize;
  124659. private _actualFrame;
  124660. private readonly _rawTextureWidth;
  124661. /**
  124662. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  124663. */
  124664. static readonly IsSupported: boolean;
  124665. /**
  124666. * An event triggered when the system is disposed.
  124667. */
  124668. onDisposeObservable: Observable<GPUParticleSystem>;
  124669. /**
  124670. * Gets the maximum number of particles active at the same time.
  124671. * @returns The max number of active particles.
  124672. */
  124673. getCapacity(): number;
  124674. /**
  124675. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  124676. * to override the particles.
  124677. */
  124678. forceDepthWrite: boolean;
  124679. /**
  124680. * Gets or set the number of active particles
  124681. */
  124682. activeParticleCount: number;
  124683. private _preWarmDone;
  124684. /**
  124685. * Is this system ready to be used/rendered
  124686. * @return true if the system is ready
  124687. */
  124688. isReady(): boolean;
  124689. /**
  124690. * Gets if the system has been started. (Note: this will still be true after stop is called)
  124691. * @returns True if it has been started, otherwise false.
  124692. */
  124693. isStarted(): boolean;
  124694. /**
  124695. * Starts the particle system and begins to emit
  124696. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  124697. */
  124698. start(delay?: number): void;
  124699. /**
  124700. * Stops the particle system.
  124701. */
  124702. stop(): void;
  124703. /**
  124704. * Remove all active particles
  124705. */
  124706. reset(): void;
  124707. /**
  124708. * Returns the string "GPUParticleSystem"
  124709. * @returns a string containing the class name
  124710. */
  124711. getClassName(): string;
  124712. private _colorGradientsTexture;
  124713. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  124714. /**
  124715. * Adds a new color gradient
  124716. * @param gradient defines the gradient to use (between 0 and 1)
  124717. * @param color1 defines the color to affect to the specified gradient
  124718. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  124719. * @returns the current particle system
  124720. */
  124721. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  124722. /**
  124723. * Remove a specific color gradient
  124724. * @param gradient defines the gradient to remove
  124725. * @returns the current particle system
  124726. */
  124727. removeColorGradient(gradient: number): GPUParticleSystem;
  124728. private _angularSpeedGradientsTexture;
  124729. private _sizeGradientsTexture;
  124730. private _velocityGradientsTexture;
  124731. private _limitVelocityGradientsTexture;
  124732. private _dragGradientsTexture;
  124733. private _addFactorGradient;
  124734. /**
  124735. * Adds a new size gradient
  124736. * @param gradient defines the gradient to use (between 0 and 1)
  124737. * @param factor defines the size factor to affect to the specified gradient
  124738. * @returns the current particle system
  124739. */
  124740. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  124741. /**
  124742. * Remove a specific size gradient
  124743. * @param gradient defines the gradient to remove
  124744. * @returns the current particle system
  124745. */
  124746. removeSizeGradient(gradient: number): GPUParticleSystem;
  124747. /**
  124748. * Adds a new angular speed gradient
  124749. * @param gradient defines the gradient to use (between 0 and 1)
  124750. * @param factor defines the angular speed to affect to the specified gradient
  124751. * @returns the current particle system
  124752. */
  124753. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  124754. /**
  124755. * Remove a specific angular speed gradient
  124756. * @param gradient defines the gradient to remove
  124757. * @returns the current particle system
  124758. */
  124759. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  124760. /**
  124761. * Adds a new velocity gradient
  124762. * @param gradient defines the gradient to use (between 0 and 1)
  124763. * @param factor defines the velocity to affect to the specified gradient
  124764. * @returns the current particle system
  124765. */
  124766. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124767. /**
  124768. * Remove a specific velocity gradient
  124769. * @param gradient defines the gradient to remove
  124770. * @returns the current particle system
  124771. */
  124772. removeVelocityGradient(gradient: number): GPUParticleSystem;
  124773. /**
  124774. * Adds a new limit velocity gradient
  124775. * @param gradient defines the gradient to use (between 0 and 1)
  124776. * @param factor defines the limit velocity value to affect to the specified gradient
  124777. * @returns the current particle system
  124778. */
  124779. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124780. /**
  124781. * Remove a specific limit velocity gradient
  124782. * @param gradient defines the gradient to remove
  124783. * @returns the current particle system
  124784. */
  124785. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  124786. /**
  124787. * Adds a new drag gradient
  124788. * @param gradient defines the gradient to use (between 0 and 1)
  124789. * @param factor defines the drag value to affect to the specified gradient
  124790. * @returns the current particle system
  124791. */
  124792. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  124793. /**
  124794. * Remove a specific drag gradient
  124795. * @param gradient defines the gradient to remove
  124796. * @returns the current particle system
  124797. */
  124798. removeDragGradient(gradient: number): GPUParticleSystem;
  124799. /**
  124800. * Not supported by GPUParticleSystem
  124801. * @param gradient defines the gradient to use (between 0 and 1)
  124802. * @param factor defines the emit rate value to affect to the specified gradient
  124803. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124804. * @returns the current particle system
  124805. */
  124806. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124807. /**
  124808. * Not supported by GPUParticleSystem
  124809. * @param gradient defines the gradient to remove
  124810. * @returns the current particle system
  124811. */
  124812. removeEmitRateGradient(gradient: number): IParticleSystem;
  124813. /**
  124814. * Not supported by GPUParticleSystem
  124815. * @param gradient defines the gradient to use (between 0 and 1)
  124816. * @param factor defines the start size value to affect to the specified gradient
  124817. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124818. * @returns the current particle system
  124819. */
  124820. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124821. /**
  124822. * Not supported by GPUParticleSystem
  124823. * @param gradient defines the gradient to remove
  124824. * @returns the current particle system
  124825. */
  124826. removeStartSizeGradient(gradient: number): IParticleSystem;
  124827. /**
  124828. * Not supported by GPUParticleSystem
  124829. * @param gradient defines the gradient to use (between 0 and 1)
  124830. * @param min defines the color remap minimal range
  124831. * @param max defines the color remap maximal range
  124832. * @returns the current particle system
  124833. */
  124834. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124835. /**
  124836. * Not supported by GPUParticleSystem
  124837. * @param gradient defines the gradient to remove
  124838. * @returns the current particle system
  124839. */
  124840. removeColorRemapGradient(): IParticleSystem;
  124841. /**
  124842. * Not supported by GPUParticleSystem
  124843. * @param gradient defines the gradient to use (between 0 and 1)
  124844. * @param min defines the alpha remap minimal range
  124845. * @param max defines the alpha remap maximal range
  124846. * @returns the current particle system
  124847. */
  124848. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124849. /**
  124850. * Not supported by GPUParticleSystem
  124851. * @param gradient defines the gradient to remove
  124852. * @returns the current particle system
  124853. */
  124854. removeAlphaRemapGradient(): IParticleSystem;
  124855. /**
  124856. * Not supported by GPUParticleSystem
  124857. * @param gradient defines the gradient to use (between 0 and 1)
  124858. * @param color defines the color to affect to the specified gradient
  124859. * @returns the current particle system
  124860. */
  124861. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  124862. /**
  124863. * Not supported by GPUParticleSystem
  124864. * @param gradient defines the gradient to remove
  124865. * @returns the current particle system
  124866. */
  124867. removeRampGradient(): IParticleSystem;
  124868. /**
  124869. * Not supported by GPUParticleSystem
  124870. * @returns the list of ramp gradients
  124871. */
  124872. getRampGradients(): Nullable<Array<Color3Gradient>>;
  124873. /**
  124874. * Not supported by GPUParticleSystem
  124875. * Gets or sets a boolean indicating that ramp gradients must be used
  124876. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  124877. */
  124878. useRampGradients: boolean;
  124879. /**
  124880. * Not supported by GPUParticleSystem
  124881. * @param gradient defines the gradient to use (between 0 and 1)
  124882. * @param factor defines the life time factor to affect to the specified gradient
  124883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124884. * @returns the current particle system
  124885. */
  124886. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124887. /**
  124888. * Not supported by GPUParticleSystem
  124889. * @param gradient defines the gradient to remove
  124890. * @returns the current particle system
  124891. */
  124892. removeLifeTimeGradient(gradient: number): IParticleSystem;
  124893. /**
  124894. * Instantiates a GPU particle system.
  124895. * 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.
  124896. * @param name The name of the particle system
  124897. * @param options The options used to create the system
  124898. * @param scene The scene the particle system belongs to
  124899. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  124900. */
  124901. constructor(name: string, options: Partial<{
  124902. capacity: number;
  124903. randomTextureSize: number;
  124904. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  124905. protected _reset(): void;
  124906. private _createUpdateVAO;
  124907. private _createRenderVAO;
  124908. private _initialize;
  124909. /** @hidden */
  124910. _recreateUpdateEffect(): void;
  124911. /** @hidden */
  124912. _recreateRenderEffect(): void;
  124913. /**
  124914. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  124915. * @param preWarm defines if we are in the pre-warmimg phase
  124916. */
  124917. animate(preWarm?: boolean): void;
  124918. private _createFactorGradientTexture;
  124919. private _createSizeGradientTexture;
  124920. private _createAngularSpeedGradientTexture;
  124921. private _createVelocityGradientTexture;
  124922. private _createLimitVelocityGradientTexture;
  124923. private _createDragGradientTexture;
  124924. private _createColorGradientTexture;
  124925. /**
  124926. * Renders the particle system in its current state
  124927. * @param preWarm defines if the system should only update the particles but not render them
  124928. * @returns the current number of particles
  124929. */
  124930. render(preWarm?: boolean): number;
  124931. /**
  124932. * Rebuilds the particle system
  124933. */
  124934. rebuild(): void;
  124935. private _releaseBuffers;
  124936. private _releaseVAOs;
  124937. /**
  124938. * Disposes the particle system and free the associated resources
  124939. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  124940. */
  124941. dispose(disposeTexture?: boolean): void;
  124942. /**
  124943. * Clones the particle system.
  124944. * @param name The name of the cloned object
  124945. * @param newEmitter The new emitter to use
  124946. * @returns the cloned particle system
  124947. */
  124948. clone(name: string, newEmitter: any): GPUParticleSystem;
  124949. /**
  124950. * Serializes the particle system to a JSON object.
  124951. * @returns the JSON object
  124952. */
  124953. serialize(): any;
  124954. /**
  124955. * Parses a JSON object to create a GPU particle system.
  124956. * @param parsedParticleSystem The JSON object to parse
  124957. * @param scene The scene to create the particle system in
  124958. * @param rootUrl The root url to use to load external dependencies like texture
  124959. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  124960. * @returns the parsed GPU particle system
  124961. */
  124962. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  124963. }
  124964. }
  124965. declare module BABYLON {
  124966. /**
  124967. * Represents a set of particle systems working together to create a specific effect
  124968. */
  124969. export class ParticleSystemSet implements IDisposable {
  124970. private _emitterCreationOptions;
  124971. private _emitterNode;
  124972. /**
  124973. * Gets the particle system list
  124974. */
  124975. systems: IParticleSystem[];
  124976. /**
  124977. * Gets the emitter node used with this set
  124978. */
  124979. readonly emitterNode: Nullable<TransformNode>;
  124980. /**
  124981. * Creates a new emitter mesh as a sphere
  124982. * @param options defines the options used to create the sphere
  124983. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  124984. * @param scene defines the hosting scene
  124985. */
  124986. setEmitterAsSphere(options: {
  124987. diameter: number;
  124988. segments: number;
  124989. color: Color3;
  124990. }, renderingGroupId: number, scene: Scene): void;
  124991. /**
  124992. * Starts all particle systems of the set
  124993. * @param emitter defines an optional mesh to use as emitter for the particle systems
  124994. */
  124995. start(emitter?: AbstractMesh): void;
  124996. /**
  124997. * Release all associated resources
  124998. */
  124999. dispose(): void;
  125000. /**
  125001. * Serialize the set into a JSON compatible object
  125002. * @returns a JSON compatible representation of the set
  125003. */
  125004. serialize(): any;
  125005. /**
  125006. * Parse a new ParticleSystemSet from a serialized source
  125007. * @param data defines a JSON compatible representation of the set
  125008. * @param scene defines the hosting scene
  125009. * @param gpu defines if we want GPU particles or CPU particles
  125010. * @returns a new ParticleSystemSet
  125011. */
  125012. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  125013. }
  125014. }
  125015. declare module BABYLON {
  125016. /**
  125017. * This class is made for on one-liner static method to help creating particle system set.
  125018. */
  125019. export class ParticleHelper {
  125020. /**
  125021. * Gets or sets base Assets URL
  125022. */
  125023. static BaseAssetsUrl: string;
  125024. /**
  125025. * Create a default particle system that you can tweak
  125026. * @param emitter defines the emitter to use
  125027. * @param capacity defines the system capacity (default is 500 particles)
  125028. * @param scene defines the hosting scene
  125029. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  125030. * @returns the new Particle system
  125031. */
  125032. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  125033. /**
  125034. * This is the main static method (one-liner) of this helper to create different particle systems
  125035. * @param type This string represents the type to the particle system to create
  125036. * @param scene The scene where the particle system should live
  125037. * @param gpu If the system will use gpu
  125038. * @returns the ParticleSystemSet created
  125039. */
  125040. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  125041. /**
  125042. * Static function used to export a particle system to a ParticleSystemSet variable.
  125043. * Please note that the emitter shape is not exported
  125044. * @param systems defines the particle systems to export
  125045. * @returns the created particle system set
  125046. */
  125047. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  125048. }
  125049. }
  125050. declare module BABYLON {
  125051. interface Engine {
  125052. /**
  125053. * Create an effect to use with particle systems.
  125054. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  125055. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  125056. * @param uniformsNames defines a list of attribute names
  125057. * @param samplers defines an array of string used to represent textures
  125058. * @param defines defines the string containing the defines to use to compile the shaders
  125059. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  125060. * @param onCompiled defines a function to call when the effect creation is successful
  125061. * @param onError defines a function to call when the effect creation has failed
  125062. * @returns the new Effect
  125063. */
  125064. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  125065. }
  125066. interface Mesh {
  125067. /**
  125068. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  125069. * @returns an array of IParticleSystem
  125070. */
  125071. getEmittedParticleSystems(): IParticleSystem[];
  125072. /**
  125073. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  125074. * @returns an array of IParticleSystem
  125075. */
  125076. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  125077. }
  125078. /**
  125079. * @hidden
  125080. */
  125081. export var _IDoNeedToBeInTheBuild: number;
  125082. }
  125083. declare module BABYLON {
  125084. interface Scene {
  125085. /** @hidden (Backing field) */
  125086. _physicsEngine: Nullable<IPhysicsEngine>;
  125087. /**
  125088. * Gets the current physics engine
  125089. * @returns a IPhysicsEngine or null if none attached
  125090. */
  125091. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  125092. /**
  125093. * Enables physics to the current scene
  125094. * @param gravity defines the scene's gravity for the physics engine
  125095. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  125096. * @return a boolean indicating if the physics engine was initialized
  125097. */
  125098. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  125099. /**
  125100. * Disables and disposes the physics engine associated with the scene
  125101. */
  125102. disablePhysicsEngine(): void;
  125103. /**
  125104. * Gets a boolean indicating if there is an active physics engine
  125105. * @returns a boolean indicating if there is an active physics engine
  125106. */
  125107. isPhysicsEnabled(): boolean;
  125108. /**
  125109. * Deletes a physics compound impostor
  125110. * @param compound defines the compound to delete
  125111. */
  125112. deleteCompoundImpostor(compound: any): void;
  125113. /**
  125114. * An event triggered when physic simulation is about to be run
  125115. */
  125116. onBeforePhysicsObservable: Observable<Scene>;
  125117. /**
  125118. * An event triggered when physic simulation has been done
  125119. */
  125120. onAfterPhysicsObservable: Observable<Scene>;
  125121. }
  125122. interface AbstractMesh {
  125123. /** @hidden */
  125124. _physicsImpostor: Nullable<PhysicsImpostor>;
  125125. /**
  125126. * Gets or sets impostor used for physic simulation
  125127. * @see http://doc.babylonjs.com/features/physics_engine
  125128. */
  125129. physicsImpostor: Nullable<PhysicsImpostor>;
  125130. /**
  125131. * Gets the current physics impostor
  125132. * @see http://doc.babylonjs.com/features/physics_engine
  125133. * @returns a physics impostor or null
  125134. */
  125135. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  125136. /** Apply a physic impulse to the mesh
  125137. * @param force defines the force to apply
  125138. * @param contactPoint defines where to apply the force
  125139. * @returns the current mesh
  125140. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  125141. */
  125142. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  125143. /**
  125144. * Creates a physic joint between two meshes
  125145. * @param otherMesh defines the other mesh to use
  125146. * @param pivot1 defines the pivot to use on this mesh
  125147. * @param pivot2 defines the pivot to use on the other mesh
  125148. * @param options defines additional options (can be plugin dependent)
  125149. * @returns the current mesh
  125150. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  125151. */
  125152. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  125153. /** @hidden */
  125154. _disposePhysicsObserver: Nullable<Observer<Node>>;
  125155. }
  125156. /**
  125157. * Defines the physics engine scene component responsible to manage a physics engine
  125158. */
  125159. export class PhysicsEngineSceneComponent implements ISceneComponent {
  125160. /**
  125161. * The component name helpful to identify the component in the list of scene components.
  125162. */
  125163. readonly name: string;
  125164. /**
  125165. * The scene the component belongs to.
  125166. */
  125167. scene: Scene;
  125168. /**
  125169. * Creates a new instance of the component for the given scene
  125170. * @param scene Defines the scene to register the component in
  125171. */
  125172. constructor(scene: Scene);
  125173. /**
  125174. * Registers the component in a given scene
  125175. */
  125176. register(): void;
  125177. /**
  125178. * Rebuilds the elements related to this component in case of
  125179. * context lost for instance.
  125180. */
  125181. rebuild(): void;
  125182. /**
  125183. * Disposes the component and the associated ressources
  125184. */
  125185. dispose(): void;
  125186. }
  125187. }
  125188. declare module BABYLON {
  125189. /**
  125190. * A helper for physics simulations
  125191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125192. */
  125193. export class PhysicsHelper {
  125194. private _scene;
  125195. private _physicsEngine;
  125196. /**
  125197. * Initializes the Physics helper
  125198. * @param scene Babylon.js scene
  125199. */
  125200. constructor(scene: Scene);
  125201. /**
  125202. * Applies a radial explosion impulse
  125203. * @param origin the origin of the explosion
  125204. * @param radiusOrEventOptions the radius or the options of radial explosion
  125205. * @param strength the explosion strength
  125206. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125207. * @returns A physics radial explosion event, or null
  125208. */
  125209. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125210. /**
  125211. * Applies a radial explosion force
  125212. * @param origin the origin of the explosion
  125213. * @param radiusOrEventOptions the radius or the options of radial explosion
  125214. * @param strength the explosion strength
  125215. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125216. * @returns A physics radial explosion event, or null
  125217. */
  125218. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125219. /**
  125220. * Creates a gravitational field
  125221. * @param origin the origin of the explosion
  125222. * @param radiusOrEventOptions the radius or the options of radial explosion
  125223. * @param strength the explosion strength
  125224. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125225. * @returns A physics gravitational field event, or null
  125226. */
  125227. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  125228. /**
  125229. * Creates a physics updraft event
  125230. * @param origin the origin of the updraft
  125231. * @param radiusOrEventOptions the radius or the options of the updraft
  125232. * @param strength the strength of the updraft
  125233. * @param height the height of the updraft
  125234. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  125235. * @returns A physics updraft event, or null
  125236. */
  125237. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  125238. /**
  125239. * Creates a physics vortex event
  125240. * @param origin the of the vortex
  125241. * @param radiusOrEventOptions the radius or the options of the vortex
  125242. * @param strength the strength of the vortex
  125243. * @param height the height of the vortex
  125244. * @returns a Physics vortex event, or null
  125245. * A physics vortex event or null
  125246. */
  125247. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  125248. }
  125249. /**
  125250. * Represents a physics radial explosion event
  125251. */
  125252. class PhysicsRadialExplosionEvent {
  125253. private _scene;
  125254. private _options;
  125255. private _sphere;
  125256. private _dataFetched;
  125257. /**
  125258. * Initializes a radial explosioin event
  125259. * @param _scene BabylonJS scene
  125260. * @param _options The options for the vortex event
  125261. */
  125262. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  125263. /**
  125264. * Returns the data related to the radial explosion event (sphere).
  125265. * @returns The radial explosion event data
  125266. */
  125267. getData(): PhysicsRadialExplosionEventData;
  125268. /**
  125269. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  125270. * @param impostor A physics imposter
  125271. * @param origin the origin of the explosion
  125272. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  125273. */
  125274. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  125275. /**
  125276. * Triggers affecterd impostors callbacks
  125277. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  125278. */
  125279. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  125280. /**
  125281. * Disposes the sphere.
  125282. * @param force Specifies if the sphere should be disposed by force
  125283. */
  125284. dispose(force?: boolean): void;
  125285. /*** Helpers ***/
  125286. private _prepareSphere;
  125287. private _intersectsWithSphere;
  125288. }
  125289. /**
  125290. * Represents a gravitational field event
  125291. */
  125292. class PhysicsGravitationalFieldEvent {
  125293. private _physicsHelper;
  125294. private _scene;
  125295. private _origin;
  125296. private _options;
  125297. private _tickCallback;
  125298. private _sphere;
  125299. private _dataFetched;
  125300. /**
  125301. * Initializes the physics gravitational field event
  125302. * @param _physicsHelper A physics helper
  125303. * @param _scene BabylonJS scene
  125304. * @param _origin The origin position of the gravitational field event
  125305. * @param _options The options for the vortex event
  125306. */
  125307. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  125308. /**
  125309. * Returns the data related to the gravitational field event (sphere).
  125310. * @returns A gravitational field event
  125311. */
  125312. getData(): PhysicsGravitationalFieldEventData;
  125313. /**
  125314. * Enables the gravitational field.
  125315. */
  125316. enable(): void;
  125317. /**
  125318. * Disables the gravitational field.
  125319. */
  125320. disable(): void;
  125321. /**
  125322. * Disposes the sphere.
  125323. * @param force The force to dispose from the gravitational field event
  125324. */
  125325. dispose(force?: boolean): void;
  125326. private _tick;
  125327. }
  125328. /**
  125329. * Represents a physics updraft event
  125330. */
  125331. class PhysicsUpdraftEvent {
  125332. private _scene;
  125333. private _origin;
  125334. private _options;
  125335. private _physicsEngine;
  125336. private _originTop;
  125337. private _originDirection;
  125338. private _tickCallback;
  125339. private _cylinder;
  125340. private _cylinderPosition;
  125341. private _dataFetched;
  125342. /**
  125343. * Initializes the physics updraft event
  125344. * @param _scene BabylonJS scene
  125345. * @param _origin The origin position of the updraft
  125346. * @param _options The options for the updraft event
  125347. */
  125348. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  125349. /**
  125350. * Returns the data related to the updraft event (cylinder).
  125351. * @returns A physics updraft event
  125352. */
  125353. getData(): PhysicsUpdraftEventData;
  125354. /**
  125355. * Enables the updraft.
  125356. */
  125357. enable(): void;
  125358. /**
  125359. * Disables the updraft.
  125360. */
  125361. disable(): void;
  125362. /**
  125363. * Disposes the cylinder.
  125364. * @param force Specifies if the updraft should be disposed by force
  125365. */
  125366. dispose(force?: boolean): void;
  125367. private getImpostorHitData;
  125368. private _tick;
  125369. /*** Helpers ***/
  125370. private _prepareCylinder;
  125371. private _intersectsWithCylinder;
  125372. }
  125373. /**
  125374. * Represents a physics vortex event
  125375. */
  125376. class PhysicsVortexEvent {
  125377. private _scene;
  125378. private _origin;
  125379. private _options;
  125380. private _physicsEngine;
  125381. private _originTop;
  125382. private _tickCallback;
  125383. private _cylinder;
  125384. private _cylinderPosition;
  125385. private _dataFetched;
  125386. /**
  125387. * Initializes the physics vortex event
  125388. * @param _scene The BabylonJS scene
  125389. * @param _origin The origin position of the vortex
  125390. * @param _options The options for the vortex event
  125391. */
  125392. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  125393. /**
  125394. * Returns the data related to the vortex event (cylinder).
  125395. * @returns The physics vortex event data
  125396. */
  125397. getData(): PhysicsVortexEventData;
  125398. /**
  125399. * Enables the vortex.
  125400. */
  125401. enable(): void;
  125402. /**
  125403. * Disables the cortex.
  125404. */
  125405. disable(): void;
  125406. /**
  125407. * Disposes the sphere.
  125408. * @param force
  125409. */
  125410. dispose(force?: boolean): void;
  125411. private getImpostorHitData;
  125412. private _tick;
  125413. /*** Helpers ***/
  125414. private _prepareCylinder;
  125415. private _intersectsWithCylinder;
  125416. }
  125417. /**
  125418. * Options fot the radial explosion event
  125419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125420. */
  125421. export class PhysicsRadialExplosionEventOptions {
  125422. /**
  125423. * The radius of the sphere for the radial explosion.
  125424. */
  125425. radius: number;
  125426. /**
  125427. * The strenth of the explosion.
  125428. */
  125429. strength: number;
  125430. /**
  125431. * The strenght of the force in correspondence to the distance of the affected object
  125432. */
  125433. falloff: PhysicsRadialImpulseFalloff;
  125434. /**
  125435. * Sphere options for the radial explosion.
  125436. */
  125437. sphere: {
  125438. segments: number;
  125439. diameter: number;
  125440. };
  125441. /**
  125442. * Sphere options for the radial explosion.
  125443. */
  125444. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  125445. }
  125446. /**
  125447. * Options fot the updraft event
  125448. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125449. */
  125450. export class PhysicsUpdraftEventOptions {
  125451. /**
  125452. * The radius of the cylinder for the vortex
  125453. */
  125454. radius: number;
  125455. /**
  125456. * The strenth of the updraft.
  125457. */
  125458. strength: number;
  125459. /**
  125460. * The height of the cylinder for the updraft.
  125461. */
  125462. height: number;
  125463. /**
  125464. * The mode for the the updraft.
  125465. */
  125466. updraftMode: PhysicsUpdraftMode;
  125467. }
  125468. /**
  125469. * Options fot the vortex event
  125470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125471. */
  125472. export class PhysicsVortexEventOptions {
  125473. /**
  125474. * The radius of the cylinder for the vortex
  125475. */
  125476. radius: number;
  125477. /**
  125478. * The strenth of the vortex.
  125479. */
  125480. strength: number;
  125481. /**
  125482. * The height of the cylinder for the vortex.
  125483. */
  125484. height: number;
  125485. /**
  125486. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  125487. */
  125488. centripetalForceThreshold: number;
  125489. /**
  125490. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  125491. */
  125492. centripetalForceMultiplier: number;
  125493. /**
  125494. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  125495. */
  125496. centrifugalForceMultiplier: number;
  125497. /**
  125498. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  125499. */
  125500. updraftForceMultiplier: number;
  125501. }
  125502. /**
  125503. * The strenght of the force in correspondence to the distance of the affected object
  125504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125505. */
  125506. export enum PhysicsRadialImpulseFalloff {
  125507. /** Defines that impulse is constant in strength across it's whole radius */
  125508. Constant = 0,
  125509. /** Defines that impulse gets weaker if it's further from the origin */
  125510. Linear = 1
  125511. }
  125512. /**
  125513. * The strength of the force in correspondence to the distance of the affected object
  125514. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125515. */
  125516. export enum PhysicsUpdraftMode {
  125517. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  125518. Center = 0,
  125519. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  125520. Perpendicular = 1
  125521. }
  125522. /**
  125523. * Interface for a physics hit data
  125524. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125525. */
  125526. export interface PhysicsHitData {
  125527. /**
  125528. * The force applied at the contact point
  125529. */
  125530. force: Vector3;
  125531. /**
  125532. * The contact point
  125533. */
  125534. contactPoint: Vector3;
  125535. /**
  125536. * The distance from the origin to the contact point
  125537. */
  125538. distanceFromOrigin: number;
  125539. }
  125540. /**
  125541. * Interface for radial explosion event data
  125542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125543. */
  125544. export interface PhysicsRadialExplosionEventData {
  125545. /**
  125546. * A sphere used for the radial explosion event
  125547. */
  125548. sphere: Mesh;
  125549. }
  125550. /**
  125551. * Interface for gravitational field event data
  125552. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125553. */
  125554. export interface PhysicsGravitationalFieldEventData {
  125555. /**
  125556. * A sphere mesh used for the gravitational field event
  125557. */
  125558. sphere: Mesh;
  125559. }
  125560. /**
  125561. * Interface for updraft event data
  125562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125563. */
  125564. export interface PhysicsUpdraftEventData {
  125565. /**
  125566. * A cylinder used for the updraft event
  125567. */
  125568. cylinder: Mesh;
  125569. }
  125570. /**
  125571. * Interface for vortex event data
  125572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125573. */
  125574. export interface PhysicsVortexEventData {
  125575. /**
  125576. * A cylinder used for the vortex event
  125577. */
  125578. cylinder: Mesh;
  125579. }
  125580. /**
  125581. * Interface for an affected physics impostor
  125582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125583. */
  125584. export interface PhysicsAffectedImpostorWithData {
  125585. /**
  125586. * The impostor affected by the effect
  125587. */
  125588. impostor: PhysicsImpostor;
  125589. /**
  125590. * The data about the hit/horce from the explosion
  125591. */
  125592. hitData: PhysicsHitData;
  125593. }
  125594. }
  125595. declare module BABYLON {
  125596. /** @hidden */
  125597. export var blackAndWhitePixelShader: {
  125598. name: string;
  125599. shader: string;
  125600. };
  125601. }
  125602. declare module BABYLON {
  125603. /**
  125604. * Post process used to render in black and white
  125605. */
  125606. export class BlackAndWhitePostProcess extends PostProcess {
  125607. /**
  125608. * Linear about to convert he result to black and white (default: 1)
  125609. */
  125610. degree: number;
  125611. /**
  125612. * Creates a black and white post process
  125613. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  125614. * @param name The name of the effect.
  125615. * @param options The required width/height ratio to downsize to before computing the render pass.
  125616. * @param camera The camera to apply the render pass to.
  125617. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125618. * @param engine The engine which the post process will be applied. (default: current engine)
  125619. * @param reusable If the post process can be reused on the same frame. (default: false)
  125620. */
  125621. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125622. }
  125623. }
  125624. declare module BABYLON {
  125625. /**
  125626. * This represents a set of one or more post processes in Babylon.
  125627. * A post process can be used to apply a shader to a texture after it is rendered.
  125628. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125629. */
  125630. export class PostProcessRenderEffect {
  125631. private _postProcesses;
  125632. private _getPostProcesses;
  125633. private _singleInstance;
  125634. private _cameras;
  125635. private _indicesForCamera;
  125636. /**
  125637. * Name of the effect
  125638. * @hidden
  125639. */
  125640. _name: string;
  125641. /**
  125642. * Instantiates a post process render effect.
  125643. * A post process can be used to apply a shader to a texture after it is rendered.
  125644. * @param engine The engine the effect is tied to
  125645. * @param name The name of the effect
  125646. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  125647. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  125648. */
  125649. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  125650. /**
  125651. * Checks if all the post processes in the effect are supported.
  125652. */
  125653. readonly isSupported: boolean;
  125654. /**
  125655. * Updates the current state of the effect
  125656. * @hidden
  125657. */
  125658. _update(): void;
  125659. /**
  125660. * Attaches the effect on cameras
  125661. * @param cameras The camera to attach to.
  125662. * @hidden
  125663. */
  125664. _attachCameras(cameras: Camera): void;
  125665. /**
  125666. * Attaches the effect on cameras
  125667. * @param cameras The camera to attach to.
  125668. * @hidden
  125669. */
  125670. _attachCameras(cameras: Camera[]): void;
  125671. /**
  125672. * Detaches the effect on cameras
  125673. * @param cameras The camera to detatch from.
  125674. * @hidden
  125675. */
  125676. _detachCameras(cameras: Camera): void;
  125677. /**
  125678. * Detatches the effect on cameras
  125679. * @param cameras The camera to detatch from.
  125680. * @hidden
  125681. */
  125682. _detachCameras(cameras: Camera[]): void;
  125683. /**
  125684. * Enables the effect on given cameras
  125685. * @param cameras The camera to enable.
  125686. * @hidden
  125687. */
  125688. _enable(cameras: Camera): void;
  125689. /**
  125690. * Enables the effect on given cameras
  125691. * @param cameras The camera to enable.
  125692. * @hidden
  125693. */
  125694. _enable(cameras: Nullable<Camera[]>): void;
  125695. /**
  125696. * Disables the effect on the given cameras
  125697. * @param cameras The camera to disable.
  125698. * @hidden
  125699. */
  125700. _disable(cameras: Camera): void;
  125701. /**
  125702. * Disables the effect on the given cameras
  125703. * @param cameras The camera to disable.
  125704. * @hidden
  125705. */
  125706. _disable(cameras: Nullable<Camera[]>): void;
  125707. /**
  125708. * Gets a list of the post processes contained in the effect.
  125709. * @param camera The camera to get the post processes on.
  125710. * @returns The list of the post processes in the effect.
  125711. */
  125712. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  125713. }
  125714. }
  125715. declare module BABYLON {
  125716. /** @hidden */
  125717. export var extractHighlightsPixelShader: {
  125718. name: string;
  125719. shader: string;
  125720. };
  125721. }
  125722. declare module BABYLON {
  125723. /**
  125724. * 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.
  125725. */
  125726. export class ExtractHighlightsPostProcess extends PostProcess {
  125727. /**
  125728. * The luminance threshold, pixels below this value will be set to black.
  125729. */
  125730. threshold: number;
  125731. /** @hidden */
  125732. _exposure: number;
  125733. /**
  125734. * Post process which has the input texture to be used when performing highlight extraction
  125735. * @hidden
  125736. */
  125737. _inputPostProcess: Nullable<PostProcess>;
  125738. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125739. }
  125740. }
  125741. declare module BABYLON {
  125742. /** @hidden */
  125743. export var bloomMergePixelShader: {
  125744. name: string;
  125745. shader: string;
  125746. };
  125747. }
  125748. declare module BABYLON {
  125749. /**
  125750. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125751. */
  125752. export class BloomMergePostProcess extends PostProcess {
  125753. /** Weight of the bloom to be added to the original input. */
  125754. weight: number;
  125755. /**
  125756. * Creates a new instance of @see BloomMergePostProcess
  125757. * @param name The name of the effect.
  125758. * @param originalFromInput Post process which's input will be used for the merge.
  125759. * @param blurred Blurred highlights post process which's output will be used.
  125760. * @param weight Weight of the bloom to be added to the original input.
  125761. * @param options The required width/height ratio to downsize to before computing the render pass.
  125762. * @param camera The camera to apply the render pass to.
  125763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125764. * @param engine The engine which the post process will be applied. (default: current engine)
  125765. * @param reusable If the post process can be reused on the same frame. (default: false)
  125766. * @param textureType Type of textures used when performing the post process. (default: 0)
  125767. * @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)
  125768. */
  125769. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  125770. /** Weight of the bloom to be added to the original input. */
  125771. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125772. }
  125773. }
  125774. declare module BABYLON {
  125775. /**
  125776. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  125777. */
  125778. export class BloomEffect extends PostProcessRenderEffect {
  125779. private bloomScale;
  125780. /**
  125781. * @hidden Internal
  125782. */
  125783. _effects: Array<PostProcess>;
  125784. /**
  125785. * @hidden Internal
  125786. */
  125787. _downscale: ExtractHighlightsPostProcess;
  125788. private _blurX;
  125789. private _blurY;
  125790. private _merge;
  125791. /**
  125792. * The luminance threshold to find bright areas of the image to bloom.
  125793. */
  125794. threshold: number;
  125795. /**
  125796. * The strength of the bloom.
  125797. */
  125798. weight: number;
  125799. /**
  125800. * Specifies the size of the bloom blur kernel, relative to the final output size
  125801. */
  125802. kernel: number;
  125803. /**
  125804. * Creates a new instance of @see BloomEffect
  125805. * @param scene The scene the effect belongs to.
  125806. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  125807. * @param bloomKernel The size of the kernel to be used when applying the blur.
  125808. * @param bloomWeight The the strength of bloom.
  125809. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125810. * @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)
  125811. */
  125812. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  125813. /**
  125814. * Disposes each of the internal effects for a given camera.
  125815. * @param camera The camera to dispose the effect on.
  125816. */
  125817. disposeEffects(camera: Camera): void;
  125818. /**
  125819. * @hidden Internal
  125820. */
  125821. _updateEffects(): void;
  125822. /**
  125823. * Internal
  125824. * @returns if all the contained post processes are ready.
  125825. * @hidden
  125826. */
  125827. _isReady(): boolean;
  125828. }
  125829. }
  125830. declare module BABYLON {
  125831. /** @hidden */
  125832. export var chromaticAberrationPixelShader: {
  125833. name: string;
  125834. shader: string;
  125835. };
  125836. }
  125837. declare module BABYLON {
  125838. /**
  125839. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  125840. */
  125841. export class ChromaticAberrationPostProcess extends PostProcess {
  125842. /**
  125843. * The amount of seperation of rgb channels (default: 30)
  125844. */
  125845. aberrationAmount: number;
  125846. /**
  125847. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  125848. */
  125849. radialIntensity: number;
  125850. /**
  125851. * 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))
  125852. */
  125853. direction: Vector2;
  125854. /**
  125855. * 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))
  125856. */
  125857. centerPosition: Vector2;
  125858. /**
  125859. * Creates a new instance ChromaticAberrationPostProcess
  125860. * @param name The name of the effect.
  125861. * @param screenWidth The width of the screen to apply the effect on.
  125862. * @param screenHeight The height of the screen to apply the effect on.
  125863. * @param options The required width/height ratio to downsize to before computing the render pass.
  125864. * @param camera The camera to apply the render pass to.
  125865. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125866. * @param engine The engine which the post process will be applied. (default: current engine)
  125867. * @param reusable If the post process can be reused on the same frame. (default: false)
  125868. * @param textureType Type of textures used when performing the post process. (default: 0)
  125869. * @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)
  125870. */
  125871. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125872. }
  125873. }
  125874. declare module BABYLON {
  125875. /** @hidden */
  125876. export var circleOfConfusionPixelShader: {
  125877. name: string;
  125878. shader: string;
  125879. };
  125880. }
  125881. declare module BABYLON {
  125882. /**
  125883. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  125884. */
  125885. export class CircleOfConfusionPostProcess extends PostProcess {
  125886. /**
  125887. * 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.
  125888. */
  125889. lensSize: number;
  125890. /**
  125891. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125892. */
  125893. fStop: number;
  125894. /**
  125895. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125896. */
  125897. focusDistance: number;
  125898. /**
  125899. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  125900. */
  125901. focalLength: number;
  125902. private _depthTexture;
  125903. /**
  125904. * Creates a new instance CircleOfConfusionPostProcess
  125905. * @param name The name of the effect.
  125906. * @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.
  125907. * @param options The required width/height ratio to downsize to before computing the render pass.
  125908. * @param camera The camera to apply the render pass to.
  125909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125910. * @param engine The engine which the post process will be applied. (default: current engine)
  125911. * @param reusable If the post process can be reused on the same frame. (default: false)
  125912. * @param textureType Type of textures used when performing the post process. (default: 0)
  125913. * @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)
  125914. */
  125915. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125916. /**
  125917. * 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.
  125918. */
  125919. depthTexture: RenderTargetTexture;
  125920. }
  125921. }
  125922. declare module BABYLON {
  125923. /** @hidden */
  125924. export var colorCorrectionPixelShader: {
  125925. name: string;
  125926. shader: string;
  125927. };
  125928. }
  125929. declare module BABYLON {
  125930. /**
  125931. *
  125932. * This post-process allows the modification of rendered colors by using
  125933. * a 'look-up table' (LUT). This effect is also called Color Grading.
  125934. *
  125935. * The object needs to be provided an url to a texture containing the color
  125936. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  125937. * Use an image editing software to tweak the LUT to match your needs.
  125938. *
  125939. * For an example of a color LUT, see here:
  125940. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  125941. * For explanations on color grading, see here:
  125942. * @see http://udn.epicgames.com/Three/ColorGrading.html
  125943. *
  125944. */
  125945. export class ColorCorrectionPostProcess extends PostProcess {
  125946. private _colorTableTexture;
  125947. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125948. }
  125949. }
  125950. declare module BABYLON {
  125951. /** @hidden */
  125952. export var convolutionPixelShader: {
  125953. name: string;
  125954. shader: string;
  125955. };
  125956. }
  125957. declare module BABYLON {
  125958. /**
  125959. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  125960. * input texture to perform effects such as edge detection or sharpening
  125961. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125962. */
  125963. export class ConvolutionPostProcess extends PostProcess {
  125964. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125965. kernel: number[];
  125966. /**
  125967. * Creates a new instance ConvolutionPostProcess
  125968. * @param name The name of the effect.
  125969. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  125970. * @param options The required width/height ratio to downsize to before computing the render pass.
  125971. * @param camera The camera to apply the render pass to.
  125972. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125973. * @param engine The engine which the post process will be applied. (default: current engine)
  125974. * @param reusable If the post process can be reused on the same frame. (default: false)
  125975. * @param textureType Type of textures used when performing the post process. (default: 0)
  125976. */
  125977. constructor(name: string,
  125978. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125979. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125980. /**
  125981. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125982. */
  125983. static EdgeDetect0Kernel: number[];
  125984. /**
  125985. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125986. */
  125987. static EdgeDetect1Kernel: number[];
  125988. /**
  125989. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125990. */
  125991. static EdgeDetect2Kernel: number[];
  125992. /**
  125993. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125994. */
  125995. static SharpenKernel: number[];
  125996. /**
  125997. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125998. */
  125999. static EmbossKernel: number[];
  126000. /**
  126001. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126002. */
  126003. static GaussianKernel: number[];
  126004. }
  126005. }
  126006. declare module BABYLON {
  126007. /**
  126008. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  126009. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  126010. * based on samples that have a large difference in distance than the center pixel.
  126011. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  126012. */
  126013. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  126014. direction: Vector2;
  126015. /**
  126016. * Creates a new instance CircleOfConfusionPostProcess
  126017. * @param name The name of the effect.
  126018. * @param scene The scene the effect belongs to.
  126019. * @param direction The direction the blur should be applied.
  126020. * @param kernel The size of the kernel used to blur.
  126021. * @param options The required width/height ratio to downsize to before computing the render pass.
  126022. * @param camera The camera to apply the render pass to.
  126023. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  126024. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  126025. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126026. * @param engine The engine which the post process will be applied. (default: current engine)
  126027. * @param reusable If the post process can be reused on the same frame. (default: false)
  126028. * @param textureType Type of textures used when performing the post process. (default: 0)
  126029. * @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)
  126030. */
  126031. 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);
  126032. }
  126033. }
  126034. declare module BABYLON {
  126035. /** @hidden */
  126036. export var depthOfFieldMergePixelShader: {
  126037. name: string;
  126038. shader: string;
  126039. };
  126040. }
  126041. declare module BABYLON {
  126042. /**
  126043. * Options to be set when merging outputs from the default pipeline.
  126044. */
  126045. export class DepthOfFieldMergePostProcessOptions {
  126046. /**
  126047. * The original image to merge on top of
  126048. */
  126049. originalFromInput: PostProcess;
  126050. /**
  126051. * Parameters to perform the merge of the depth of field effect
  126052. */
  126053. depthOfField?: {
  126054. circleOfConfusion: PostProcess;
  126055. blurSteps: Array<PostProcess>;
  126056. };
  126057. /**
  126058. * Parameters to perform the merge of bloom effect
  126059. */
  126060. bloom?: {
  126061. blurred: PostProcess;
  126062. weight: number;
  126063. };
  126064. }
  126065. /**
  126066. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  126067. */
  126068. export class DepthOfFieldMergePostProcess extends PostProcess {
  126069. private blurSteps;
  126070. /**
  126071. * Creates a new instance of DepthOfFieldMergePostProcess
  126072. * @param name The name of the effect.
  126073. * @param originalFromInput Post process which's input will be used for the merge.
  126074. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  126075. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  126076. * @param options The required width/height ratio to downsize to before computing the render pass.
  126077. * @param camera The camera to apply the render pass to.
  126078. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126079. * @param engine The engine which the post process will be applied. (default: current engine)
  126080. * @param reusable If the post process can be reused on the same frame. (default: false)
  126081. * @param textureType Type of textures used when performing the post process. (default: 0)
  126082. * @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)
  126083. */
  126084. 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);
  126085. /**
  126086. * Updates the effect with the current post process compile time values and recompiles the shader.
  126087. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  126088. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  126089. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  126090. * @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
  126091. * @param onCompiled Called when the shader has been compiled.
  126092. * @param onError Called if there is an error when compiling a shader.
  126093. */
  126094. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  126095. }
  126096. }
  126097. declare module BABYLON {
  126098. /**
  126099. * Specifies the level of max blur that should be applied when using the depth of field effect
  126100. */
  126101. export enum DepthOfFieldEffectBlurLevel {
  126102. /**
  126103. * Subtle blur
  126104. */
  126105. Low = 0,
  126106. /**
  126107. * Medium blur
  126108. */
  126109. Medium = 1,
  126110. /**
  126111. * Large blur
  126112. */
  126113. High = 2
  126114. }
  126115. /**
  126116. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  126117. */
  126118. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  126119. private _circleOfConfusion;
  126120. /**
  126121. * @hidden Internal, blurs from high to low
  126122. */
  126123. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  126124. private _depthOfFieldBlurY;
  126125. private _dofMerge;
  126126. /**
  126127. * @hidden Internal post processes in depth of field effect
  126128. */
  126129. _effects: Array<PostProcess>;
  126130. /**
  126131. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  126132. */
  126133. focalLength: number;
  126134. /**
  126135. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  126136. */
  126137. fStop: number;
  126138. /**
  126139. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  126140. */
  126141. focusDistance: number;
  126142. /**
  126143. * 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.
  126144. */
  126145. lensSize: number;
  126146. /**
  126147. * Creates a new instance DepthOfFieldEffect
  126148. * @param scene The scene the effect belongs to.
  126149. * @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.
  126150. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  126151. * @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)
  126152. */
  126153. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  126154. /**
  126155. * Get the current class name of the current effet
  126156. * @returns "DepthOfFieldEffect"
  126157. */
  126158. getClassName(): string;
  126159. /**
  126160. * 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.
  126161. */
  126162. depthTexture: RenderTargetTexture;
  126163. /**
  126164. * Disposes each of the internal effects for a given camera.
  126165. * @param camera The camera to dispose the effect on.
  126166. */
  126167. disposeEffects(camera: Camera): void;
  126168. /**
  126169. * @hidden Internal
  126170. */
  126171. _updateEffects(): void;
  126172. /**
  126173. * Internal
  126174. * @returns if all the contained post processes are ready.
  126175. * @hidden
  126176. */
  126177. _isReady(): boolean;
  126178. }
  126179. }
  126180. declare module BABYLON {
  126181. /** @hidden */
  126182. export var displayPassPixelShader: {
  126183. name: string;
  126184. shader: string;
  126185. };
  126186. }
  126187. declare module BABYLON {
  126188. /**
  126189. * DisplayPassPostProcess which produces an output the same as it's input
  126190. */
  126191. export class DisplayPassPostProcess extends PostProcess {
  126192. /**
  126193. * Creates the DisplayPassPostProcess
  126194. * @param name The name of the effect.
  126195. * @param options The required width/height ratio to downsize to before computing the render pass.
  126196. * @param camera The camera to apply the render pass to.
  126197. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126198. * @param engine The engine which the post process will be applied. (default: current engine)
  126199. * @param reusable If the post process can be reused on the same frame. (default: false)
  126200. */
  126201. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126202. }
  126203. }
  126204. declare module BABYLON {
  126205. /** @hidden */
  126206. export var filterPixelShader: {
  126207. name: string;
  126208. shader: string;
  126209. };
  126210. }
  126211. declare module BABYLON {
  126212. /**
  126213. * Applies a kernel filter to the image
  126214. */
  126215. export class FilterPostProcess extends PostProcess {
  126216. /** The matrix to be applied to the image */
  126217. kernelMatrix: Matrix;
  126218. /**
  126219. *
  126220. * @param name The name of the effect.
  126221. * @param kernelMatrix The matrix to be applied to the image
  126222. * @param options The required width/height ratio to downsize to before computing the render pass.
  126223. * @param camera The camera to apply the render pass to.
  126224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126225. * @param engine The engine which the post process will be applied. (default: current engine)
  126226. * @param reusable If the post process can be reused on the same frame. (default: false)
  126227. */
  126228. constructor(name: string,
  126229. /** The matrix to be applied to the image */
  126230. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126231. }
  126232. }
  126233. declare module BABYLON {
  126234. /** @hidden */
  126235. export var fxaaPixelShader: {
  126236. name: string;
  126237. shader: string;
  126238. };
  126239. }
  126240. declare module BABYLON {
  126241. /** @hidden */
  126242. export var fxaaVertexShader: {
  126243. name: string;
  126244. shader: string;
  126245. };
  126246. }
  126247. declare module BABYLON {
  126248. /**
  126249. * Fxaa post process
  126250. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  126251. */
  126252. export class FxaaPostProcess extends PostProcess {
  126253. /** @hidden */
  126254. texelWidth: number;
  126255. /** @hidden */
  126256. texelHeight: number;
  126257. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126258. private _getDefines;
  126259. }
  126260. }
  126261. declare module BABYLON {
  126262. /** @hidden */
  126263. export var grainPixelShader: {
  126264. name: string;
  126265. shader: string;
  126266. };
  126267. }
  126268. declare module BABYLON {
  126269. /**
  126270. * The GrainPostProcess adds noise to the image at mid luminance levels
  126271. */
  126272. export class GrainPostProcess extends PostProcess {
  126273. /**
  126274. * The intensity of the grain added (default: 30)
  126275. */
  126276. intensity: number;
  126277. /**
  126278. * If the grain should be randomized on every frame
  126279. */
  126280. animated: boolean;
  126281. /**
  126282. * Creates a new instance of @see GrainPostProcess
  126283. * @param name The name of the effect.
  126284. * @param options The required width/height ratio to downsize to before computing the render pass.
  126285. * @param camera The camera to apply the render pass to.
  126286. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126287. * @param engine The engine which the post process will be applied. (default: current engine)
  126288. * @param reusable If the post process can be reused on the same frame. (default: false)
  126289. * @param textureType Type of textures used when performing the post process. (default: 0)
  126290. * @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)
  126291. */
  126292. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126293. }
  126294. }
  126295. declare module BABYLON {
  126296. /** @hidden */
  126297. export var highlightsPixelShader: {
  126298. name: string;
  126299. shader: string;
  126300. };
  126301. }
  126302. declare module BABYLON {
  126303. /**
  126304. * Extracts highlights from the image
  126305. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126306. */
  126307. export class HighlightsPostProcess extends PostProcess {
  126308. /**
  126309. * Extracts highlights from the image
  126310. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126311. * @param name The name of the effect.
  126312. * @param options The required width/height ratio to downsize to before computing the render pass.
  126313. * @param camera The camera to apply the render pass to.
  126314. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126315. * @param engine The engine which the post process will be applied. (default: current engine)
  126316. * @param reusable If the post process can be reused on the same frame. (default: false)
  126317. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  126318. */
  126319. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126320. }
  126321. }
  126322. declare module BABYLON {
  126323. /** @hidden */
  126324. export var mrtFragmentDeclaration: {
  126325. name: string;
  126326. shader: string;
  126327. };
  126328. }
  126329. declare module BABYLON {
  126330. /** @hidden */
  126331. export var geometryPixelShader: {
  126332. name: string;
  126333. shader: string;
  126334. };
  126335. }
  126336. declare module BABYLON {
  126337. /** @hidden */
  126338. export var geometryVertexShader: {
  126339. name: string;
  126340. shader: string;
  126341. };
  126342. }
  126343. declare module BABYLON {
  126344. /** @hidden */
  126345. interface ISavedTransformationMatrix {
  126346. world: Matrix;
  126347. viewProjection: Matrix;
  126348. }
  126349. /**
  126350. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  126351. */
  126352. export class GeometryBufferRenderer {
  126353. /**
  126354. * Constant used to retrieve the position texture index in the G-Buffer textures array
  126355. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  126356. */
  126357. static readonly POSITION_TEXTURE_TYPE: number;
  126358. /**
  126359. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  126360. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  126361. */
  126362. static readonly VELOCITY_TEXTURE_TYPE: number;
  126363. /**
  126364. * Dictionary used to store the previous transformation matrices of each rendered mesh
  126365. * in order to compute objects velocities when enableVelocity is set to "true"
  126366. * @hidden
  126367. */
  126368. _previousTransformationMatrices: {
  126369. [index: number]: ISavedTransformationMatrix;
  126370. };
  126371. /**
  126372. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  126373. * in order to compute objects velocities when enableVelocity is set to "true"
  126374. * @hidden
  126375. */
  126376. _previousBonesTransformationMatrices: {
  126377. [index: number]: Float32Array;
  126378. };
  126379. /**
  126380. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  126381. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  126382. */
  126383. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  126384. private _scene;
  126385. private _multiRenderTarget;
  126386. private _ratio;
  126387. private _enablePosition;
  126388. private _enableVelocity;
  126389. private _positionIndex;
  126390. private _velocityIndex;
  126391. protected _effect: Effect;
  126392. protected _cachedDefines: string;
  126393. /**
  126394. * Set the render list (meshes to be rendered) used in the G buffer.
  126395. */
  126396. renderList: Mesh[];
  126397. /**
  126398. * Gets wether or not G buffer are supported by the running hardware.
  126399. * This requires draw buffer supports
  126400. */
  126401. readonly isSupported: boolean;
  126402. /**
  126403. * Returns the index of the given texture type in the G-Buffer textures array
  126404. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  126405. * @returns the index of the given texture type in the G-Buffer textures array
  126406. */
  126407. getTextureIndex(textureType: number): number;
  126408. /**
  126409. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  126410. */
  126411. /**
  126412. * Sets whether or not objects positions are enabled for the G buffer.
  126413. */
  126414. enablePosition: boolean;
  126415. /**
  126416. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  126417. */
  126418. /**
  126419. * Sets wether or not objects velocities are enabled for the G buffer.
  126420. */
  126421. enableVelocity: boolean;
  126422. /**
  126423. * Gets the scene associated with the buffer.
  126424. */
  126425. readonly scene: Scene;
  126426. /**
  126427. * Gets the ratio used by the buffer during its creation.
  126428. * How big is the buffer related to the main canvas.
  126429. */
  126430. readonly ratio: number;
  126431. /** @hidden */
  126432. static _SceneComponentInitialization: (scene: Scene) => void;
  126433. /**
  126434. * Creates a new G Buffer for the scene
  126435. * @param scene The scene the buffer belongs to
  126436. * @param ratio How big is the buffer related to the main canvas.
  126437. */
  126438. constructor(scene: Scene, ratio?: number);
  126439. /**
  126440. * Checks wether everything is ready to render a submesh to the G buffer.
  126441. * @param subMesh the submesh to check readiness for
  126442. * @param useInstances is the mesh drawn using instance or not
  126443. * @returns true if ready otherwise false
  126444. */
  126445. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126446. /**
  126447. * Gets the current underlying G Buffer.
  126448. * @returns the buffer
  126449. */
  126450. getGBuffer(): MultiRenderTarget;
  126451. /**
  126452. * Gets the number of samples used to render the buffer (anti aliasing).
  126453. */
  126454. /**
  126455. * Sets the number of samples used to render the buffer (anti aliasing).
  126456. */
  126457. samples: number;
  126458. /**
  126459. * Disposes the renderer and frees up associated resources.
  126460. */
  126461. dispose(): void;
  126462. protected _createRenderTargets(): void;
  126463. private _copyBonesTransformationMatrices;
  126464. }
  126465. }
  126466. declare module BABYLON {
  126467. interface Scene {
  126468. /** @hidden (Backing field) */
  126469. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126470. /**
  126471. * Gets or Sets the current geometry buffer associated to the scene.
  126472. */
  126473. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126474. /**
  126475. * Enables a GeometryBufferRender and associates it with the scene
  126476. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  126477. * @returns the GeometryBufferRenderer
  126478. */
  126479. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  126480. /**
  126481. * Disables the GeometryBufferRender associated with the scene
  126482. */
  126483. disableGeometryBufferRenderer(): void;
  126484. }
  126485. /**
  126486. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  126487. * in several rendering techniques.
  126488. */
  126489. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  126490. /**
  126491. * The component name helpful to identify the component in the list of scene components.
  126492. */
  126493. readonly name: string;
  126494. /**
  126495. * The scene the component belongs to.
  126496. */
  126497. scene: Scene;
  126498. /**
  126499. * Creates a new instance of the component for the given scene
  126500. * @param scene Defines the scene to register the component in
  126501. */
  126502. constructor(scene: Scene);
  126503. /**
  126504. * Registers the component in a given scene
  126505. */
  126506. register(): void;
  126507. /**
  126508. * Rebuilds the elements related to this component in case of
  126509. * context lost for instance.
  126510. */
  126511. rebuild(): void;
  126512. /**
  126513. * Disposes the component and the associated ressources
  126514. */
  126515. dispose(): void;
  126516. private _gatherRenderTargets;
  126517. }
  126518. }
  126519. declare module BABYLON {
  126520. /** @hidden */
  126521. export var motionBlurPixelShader: {
  126522. name: string;
  126523. shader: string;
  126524. };
  126525. }
  126526. declare module BABYLON {
  126527. /**
  126528. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  126529. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  126530. * As an example, all you have to do is to create the post-process:
  126531. * var mb = new BABYLON.MotionBlurPostProcess(
  126532. * 'mb', // The name of the effect.
  126533. * scene, // The scene containing the objects to blur according to their velocity.
  126534. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  126535. * camera // The camera to apply the render pass to.
  126536. * );
  126537. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  126538. */
  126539. export class MotionBlurPostProcess extends PostProcess {
  126540. /**
  126541. * Defines how much the image is blurred by the movement. Default value is equal to 1
  126542. */
  126543. motionStrength: number;
  126544. /**
  126545. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  126546. */
  126547. /**
  126548. * Sets the number of iterations to be used for motion blur quality
  126549. */
  126550. motionBlurSamples: number;
  126551. private _motionBlurSamples;
  126552. private _geometryBufferRenderer;
  126553. /**
  126554. * Creates a new instance MotionBlurPostProcess
  126555. * @param name The name of the effect.
  126556. * @param scene The scene containing the objects to blur according to their velocity.
  126557. * @param options The required width/height ratio to downsize to before computing the render pass.
  126558. * @param camera The camera to apply the render pass to.
  126559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126560. * @param engine The engine which the post process will be applied. (default: current engine)
  126561. * @param reusable If the post process can be reused on the same frame. (default: false)
  126562. * @param textureType Type of textures used when performing the post process. (default: 0)
  126563. * @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)
  126564. */
  126565. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126566. /**
  126567. * Excludes the given skinned mesh from computing bones velocities.
  126568. * 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.
  126569. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  126570. */
  126571. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126572. /**
  126573. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  126574. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  126575. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  126576. */
  126577. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126578. /**
  126579. * Disposes the post process.
  126580. * @param camera The camera to dispose the post process on.
  126581. */
  126582. dispose(camera?: Camera): void;
  126583. }
  126584. }
  126585. declare module BABYLON {
  126586. /** @hidden */
  126587. export var refractionPixelShader: {
  126588. name: string;
  126589. shader: string;
  126590. };
  126591. }
  126592. declare module BABYLON {
  126593. /**
  126594. * Post process which applies a refractin texture
  126595. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126596. */
  126597. export class RefractionPostProcess extends PostProcess {
  126598. /** the base color of the refraction (used to taint the rendering) */
  126599. color: Color3;
  126600. /** simulated refraction depth */
  126601. depth: number;
  126602. /** the coefficient of the base color (0 to remove base color tainting) */
  126603. colorLevel: number;
  126604. private _refTexture;
  126605. private _ownRefractionTexture;
  126606. /**
  126607. * Gets or sets the refraction texture
  126608. * Please note that you are responsible for disposing the texture if you set it manually
  126609. */
  126610. refractionTexture: Texture;
  126611. /**
  126612. * Initializes the RefractionPostProcess
  126613. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126614. * @param name The name of the effect.
  126615. * @param refractionTextureUrl Url of the refraction texture to use
  126616. * @param color the base color of the refraction (used to taint the rendering)
  126617. * @param depth simulated refraction depth
  126618. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  126619. * @param camera The camera to apply the render pass to.
  126620. * @param options The required width/height ratio to downsize to before computing the render pass.
  126621. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126622. * @param engine The engine which the post process will be applied. (default: current engine)
  126623. * @param reusable If the post process can be reused on the same frame. (default: false)
  126624. */
  126625. constructor(name: string, refractionTextureUrl: string,
  126626. /** the base color of the refraction (used to taint the rendering) */
  126627. color: Color3,
  126628. /** simulated refraction depth */
  126629. depth: number,
  126630. /** the coefficient of the base color (0 to remove base color tainting) */
  126631. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126632. /**
  126633. * Disposes of the post process
  126634. * @param camera Camera to dispose post process on
  126635. */
  126636. dispose(camera: Camera): void;
  126637. }
  126638. }
  126639. declare module BABYLON {
  126640. /** @hidden */
  126641. export var sharpenPixelShader: {
  126642. name: string;
  126643. shader: string;
  126644. };
  126645. }
  126646. declare module BABYLON {
  126647. /**
  126648. * The SharpenPostProcess applies a sharpen kernel to every pixel
  126649. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  126650. */
  126651. export class SharpenPostProcess extends PostProcess {
  126652. /**
  126653. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  126654. */
  126655. colorAmount: number;
  126656. /**
  126657. * How much sharpness should be applied (default: 0.3)
  126658. */
  126659. edgeAmount: number;
  126660. /**
  126661. * Creates a new instance ConvolutionPostProcess
  126662. * @param name The name of the effect.
  126663. * @param options The required width/height ratio to downsize to before computing the render pass.
  126664. * @param camera The camera to apply the render pass to.
  126665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126666. * @param engine The engine which the post process will be applied. (default: current engine)
  126667. * @param reusable If the post process can be reused on the same frame. (default: false)
  126668. * @param textureType Type of textures used when performing the post process. (default: 0)
  126669. * @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)
  126670. */
  126671. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126672. }
  126673. }
  126674. declare module BABYLON {
  126675. /**
  126676. * PostProcessRenderPipeline
  126677. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126678. */
  126679. export class PostProcessRenderPipeline {
  126680. private engine;
  126681. private _renderEffects;
  126682. private _renderEffectsForIsolatedPass;
  126683. /**
  126684. * List of inspectable custom properties (used by the Inspector)
  126685. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  126686. */
  126687. inspectableCustomProperties: IInspectable[];
  126688. /**
  126689. * @hidden
  126690. */
  126691. protected _cameras: Camera[];
  126692. /** @hidden */
  126693. _name: string;
  126694. /**
  126695. * Gets pipeline name
  126696. */
  126697. readonly name: string;
  126698. /**
  126699. * Initializes a PostProcessRenderPipeline
  126700. * @param engine engine to add the pipeline to
  126701. * @param name name of the pipeline
  126702. */
  126703. constructor(engine: Engine, name: string);
  126704. /**
  126705. * Gets the class name
  126706. * @returns "PostProcessRenderPipeline"
  126707. */
  126708. getClassName(): string;
  126709. /**
  126710. * If all the render effects in the pipeline are supported
  126711. */
  126712. readonly isSupported: boolean;
  126713. /**
  126714. * Adds an effect to the pipeline
  126715. * @param renderEffect the effect to add
  126716. */
  126717. addEffect(renderEffect: PostProcessRenderEffect): void;
  126718. /** @hidden */
  126719. _rebuild(): void;
  126720. /** @hidden */
  126721. _enableEffect(renderEffectName: string, cameras: Camera): void;
  126722. /** @hidden */
  126723. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  126724. /** @hidden */
  126725. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126726. /** @hidden */
  126727. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126728. /** @hidden */
  126729. _attachCameras(cameras: Camera, unique: boolean): void;
  126730. /** @hidden */
  126731. _attachCameras(cameras: Camera[], unique: boolean): void;
  126732. /** @hidden */
  126733. _detachCameras(cameras: Camera): void;
  126734. /** @hidden */
  126735. _detachCameras(cameras: Nullable<Camera[]>): void;
  126736. /** @hidden */
  126737. _update(): void;
  126738. /** @hidden */
  126739. _reset(): void;
  126740. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  126741. /**
  126742. * Disposes of the pipeline
  126743. */
  126744. dispose(): void;
  126745. }
  126746. }
  126747. declare module BABYLON {
  126748. /**
  126749. * PostProcessRenderPipelineManager class
  126750. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126751. */
  126752. export class PostProcessRenderPipelineManager {
  126753. private _renderPipelines;
  126754. /**
  126755. * Initializes a PostProcessRenderPipelineManager
  126756. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126757. */
  126758. constructor();
  126759. /**
  126760. * Gets the list of supported render pipelines
  126761. */
  126762. readonly supportedPipelines: PostProcessRenderPipeline[];
  126763. /**
  126764. * Adds a pipeline to the manager
  126765. * @param renderPipeline The pipeline to add
  126766. */
  126767. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  126768. /**
  126769. * Attaches a camera to the pipeline
  126770. * @param renderPipelineName The name of the pipeline to attach to
  126771. * @param cameras the camera to attach
  126772. * @param unique if the camera can be attached multiple times to the pipeline
  126773. */
  126774. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  126775. /**
  126776. * Detaches a camera from the pipeline
  126777. * @param renderPipelineName The name of the pipeline to detach from
  126778. * @param cameras the camera to detach
  126779. */
  126780. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  126781. /**
  126782. * Enables an effect by name on a pipeline
  126783. * @param renderPipelineName the name of the pipeline to enable the effect in
  126784. * @param renderEffectName the name of the effect to enable
  126785. * @param cameras the cameras that the effect should be enabled on
  126786. */
  126787. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126788. /**
  126789. * Disables an effect by name on a pipeline
  126790. * @param renderPipelineName the name of the pipeline to disable the effect in
  126791. * @param renderEffectName the name of the effect to disable
  126792. * @param cameras the cameras that the effect should be disabled on
  126793. */
  126794. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126795. /**
  126796. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  126797. */
  126798. update(): void;
  126799. /** @hidden */
  126800. _rebuild(): void;
  126801. /**
  126802. * Disposes of the manager and pipelines
  126803. */
  126804. dispose(): void;
  126805. }
  126806. }
  126807. declare module BABYLON {
  126808. interface Scene {
  126809. /** @hidden (Backing field) */
  126810. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126811. /**
  126812. * Gets the postprocess render pipeline manager
  126813. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126814. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126815. */
  126816. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126817. }
  126818. /**
  126819. * Defines the Render Pipeline scene component responsible to rendering pipelines
  126820. */
  126821. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  126822. /**
  126823. * The component name helpfull to identify the component in the list of scene components.
  126824. */
  126825. readonly name: string;
  126826. /**
  126827. * The scene the component belongs to.
  126828. */
  126829. scene: Scene;
  126830. /**
  126831. * Creates a new instance of the component for the given scene
  126832. * @param scene Defines the scene to register the component in
  126833. */
  126834. constructor(scene: Scene);
  126835. /**
  126836. * Registers the component in a given scene
  126837. */
  126838. register(): void;
  126839. /**
  126840. * Rebuilds the elements related to this component in case of
  126841. * context lost for instance.
  126842. */
  126843. rebuild(): void;
  126844. /**
  126845. * Disposes the component and the associated ressources
  126846. */
  126847. dispose(): void;
  126848. private _gatherRenderTargets;
  126849. }
  126850. }
  126851. declare module BABYLON {
  126852. /**
  126853. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  126854. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126855. */
  126856. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  126857. private _scene;
  126858. private _camerasToBeAttached;
  126859. /**
  126860. * ID of the sharpen post process,
  126861. */
  126862. private readonly SharpenPostProcessId;
  126863. /**
  126864. * @ignore
  126865. * ID of the image processing post process;
  126866. */
  126867. readonly ImageProcessingPostProcessId: string;
  126868. /**
  126869. * @ignore
  126870. * ID of the Fast Approximate Anti-Aliasing post process;
  126871. */
  126872. readonly FxaaPostProcessId: string;
  126873. /**
  126874. * ID of the chromatic aberration post process,
  126875. */
  126876. private readonly ChromaticAberrationPostProcessId;
  126877. /**
  126878. * ID of the grain post process
  126879. */
  126880. private readonly GrainPostProcessId;
  126881. /**
  126882. * Sharpen post process which will apply a sharpen convolution to enhance edges
  126883. */
  126884. sharpen: SharpenPostProcess;
  126885. private _sharpenEffect;
  126886. private bloom;
  126887. /**
  126888. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  126889. */
  126890. depthOfField: DepthOfFieldEffect;
  126891. /**
  126892. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  126893. */
  126894. fxaa: FxaaPostProcess;
  126895. /**
  126896. * Image post processing pass used to perform operations such as tone mapping or color grading.
  126897. */
  126898. imageProcessing: ImageProcessingPostProcess;
  126899. /**
  126900. * Chromatic aberration post process which will shift rgb colors in the image
  126901. */
  126902. chromaticAberration: ChromaticAberrationPostProcess;
  126903. private _chromaticAberrationEffect;
  126904. /**
  126905. * Grain post process which add noise to the image
  126906. */
  126907. grain: GrainPostProcess;
  126908. private _grainEffect;
  126909. /**
  126910. * Glow post process which adds a glow to emissive areas of the image
  126911. */
  126912. private _glowLayer;
  126913. /**
  126914. * Animations which can be used to tweak settings over a period of time
  126915. */
  126916. animations: Animation[];
  126917. private _imageProcessingConfigurationObserver;
  126918. private _sharpenEnabled;
  126919. private _bloomEnabled;
  126920. private _depthOfFieldEnabled;
  126921. private _depthOfFieldBlurLevel;
  126922. private _fxaaEnabled;
  126923. private _imageProcessingEnabled;
  126924. private _defaultPipelineTextureType;
  126925. private _bloomScale;
  126926. private _chromaticAberrationEnabled;
  126927. private _grainEnabled;
  126928. private _buildAllowed;
  126929. /**
  126930. * Gets active scene
  126931. */
  126932. readonly scene: Scene;
  126933. /**
  126934. * Enable or disable the sharpen process from the pipeline
  126935. */
  126936. sharpenEnabled: boolean;
  126937. private _resizeObserver;
  126938. private _hardwareScaleLevel;
  126939. private _bloomKernel;
  126940. /**
  126941. * Specifies the size of the bloom blur kernel, relative to the final output size
  126942. */
  126943. bloomKernel: number;
  126944. /**
  126945. * Specifies the weight of the bloom in the final rendering
  126946. */
  126947. private _bloomWeight;
  126948. /**
  126949. * Specifies the luma threshold for the area that will be blurred by the bloom
  126950. */
  126951. private _bloomThreshold;
  126952. private _hdr;
  126953. /**
  126954. * The strength of the bloom.
  126955. */
  126956. bloomWeight: number;
  126957. /**
  126958. * The strength of the bloom.
  126959. */
  126960. bloomThreshold: number;
  126961. /**
  126962. * The scale of the bloom, lower value will provide better performance.
  126963. */
  126964. bloomScale: number;
  126965. /**
  126966. * Enable or disable the bloom from the pipeline
  126967. */
  126968. bloomEnabled: boolean;
  126969. private _rebuildBloom;
  126970. /**
  126971. * If the depth of field is enabled.
  126972. */
  126973. depthOfFieldEnabled: boolean;
  126974. /**
  126975. * Blur level of the depth of field effect. (Higher blur will effect performance)
  126976. */
  126977. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  126978. /**
  126979. * If the anti aliasing is enabled.
  126980. */
  126981. fxaaEnabled: boolean;
  126982. private _samples;
  126983. /**
  126984. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126985. */
  126986. samples: number;
  126987. /**
  126988. * If image processing is enabled.
  126989. */
  126990. imageProcessingEnabled: boolean;
  126991. /**
  126992. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  126993. */
  126994. glowLayerEnabled: boolean;
  126995. /**
  126996. * Gets the glow layer (or null if not defined)
  126997. */
  126998. readonly glowLayer: Nullable<GlowLayer>;
  126999. /**
  127000. * Enable or disable the chromaticAberration process from the pipeline
  127001. */
  127002. chromaticAberrationEnabled: boolean;
  127003. /**
  127004. * Enable or disable the grain process from the pipeline
  127005. */
  127006. grainEnabled: boolean;
  127007. /**
  127008. * @constructor
  127009. * @param name - The rendering pipeline name (default: "")
  127010. * @param hdr - If high dynamic range textures should be used (default: true)
  127011. * @param scene - The scene linked to this pipeline (default: the last created scene)
  127012. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  127013. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  127014. */
  127015. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  127016. /**
  127017. * Get the class name
  127018. * @returns "DefaultRenderingPipeline"
  127019. */
  127020. getClassName(): string;
  127021. /**
  127022. * Force the compilation of the entire pipeline.
  127023. */
  127024. prepare(): void;
  127025. private _hasCleared;
  127026. private _prevPostProcess;
  127027. private _prevPrevPostProcess;
  127028. private _setAutoClearAndTextureSharing;
  127029. private _depthOfFieldSceneObserver;
  127030. private _buildPipeline;
  127031. private _disposePostProcesses;
  127032. /**
  127033. * Adds a camera to the pipeline
  127034. * @param camera the camera to be added
  127035. */
  127036. addCamera(camera: Camera): void;
  127037. /**
  127038. * Removes a camera from the pipeline
  127039. * @param camera the camera to remove
  127040. */
  127041. removeCamera(camera: Camera): void;
  127042. /**
  127043. * Dispose of the pipeline and stop all post processes
  127044. */
  127045. dispose(): void;
  127046. /**
  127047. * Serialize the rendering pipeline (Used when exporting)
  127048. * @returns the serialized object
  127049. */
  127050. serialize(): any;
  127051. /**
  127052. * Parse the serialized pipeline
  127053. * @param source Source pipeline.
  127054. * @param scene The scene to load the pipeline to.
  127055. * @param rootUrl The URL of the serialized pipeline.
  127056. * @returns An instantiated pipeline from the serialized object.
  127057. */
  127058. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  127059. }
  127060. }
  127061. declare module BABYLON {
  127062. /** @hidden */
  127063. export var lensHighlightsPixelShader: {
  127064. name: string;
  127065. shader: string;
  127066. };
  127067. }
  127068. declare module BABYLON {
  127069. /** @hidden */
  127070. export var depthOfFieldPixelShader: {
  127071. name: string;
  127072. shader: string;
  127073. };
  127074. }
  127075. declare module BABYLON {
  127076. /**
  127077. * BABYLON.JS Chromatic Aberration GLSL Shader
  127078. * Author: Olivier Guyot
  127079. * Separates very slightly R, G and B colors on the edges of the screen
  127080. * Inspired by Francois Tarlier & Martins Upitis
  127081. */
  127082. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  127083. /**
  127084. * @ignore
  127085. * The chromatic aberration PostProcess id in the pipeline
  127086. */
  127087. LensChromaticAberrationEffect: string;
  127088. /**
  127089. * @ignore
  127090. * The highlights enhancing PostProcess id in the pipeline
  127091. */
  127092. HighlightsEnhancingEffect: string;
  127093. /**
  127094. * @ignore
  127095. * The depth-of-field PostProcess id in the pipeline
  127096. */
  127097. LensDepthOfFieldEffect: string;
  127098. private _scene;
  127099. private _depthTexture;
  127100. private _grainTexture;
  127101. private _chromaticAberrationPostProcess;
  127102. private _highlightsPostProcess;
  127103. private _depthOfFieldPostProcess;
  127104. private _edgeBlur;
  127105. private _grainAmount;
  127106. private _chromaticAberration;
  127107. private _distortion;
  127108. private _highlightsGain;
  127109. private _highlightsThreshold;
  127110. private _dofDistance;
  127111. private _dofAperture;
  127112. private _dofDarken;
  127113. private _dofPentagon;
  127114. private _blurNoise;
  127115. /**
  127116. * @constructor
  127117. *
  127118. * Effect parameters are as follow:
  127119. * {
  127120. * chromatic_aberration: number; // from 0 to x (1 for realism)
  127121. * edge_blur: number; // from 0 to x (1 for realism)
  127122. * distortion: number; // from 0 to x (1 for realism)
  127123. * grain_amount: number; // from 0 to 1
  127124. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  127125. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  127126. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  127127. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  127128. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  127129. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  127130. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  127131. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  127132. * }
  127133. * Note: if an effect parameter is unset, effect is disabled
  127134. *
  127135. * @param name The rendering pipeline name
  127136. * @param parameters - An object containing all parameters (see above)
  127137. * @param scene The scene linked to this pipeline
  127138. * @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)
  127139. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127140. */
  127141. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  127142. /**
  127143. * Get the class name
  127144. * @returns "LensRenderingPipeline"
  127145. */
  127146. getClassName(): string;
  127147. /**
  127148. * Gets associated scene
  127149. */
  127150. readonly scene: Scene;
  127151. /**
  127152. * Gets or sets the edge blur
  127153. */
  127154. edgeBlur: number;
  127155. /**
  127156. * Gets or sets the grain amount
  127157. */
  127158. grainAmount: number;
  127159. /**
  127160. * Gets or sets the chromatic aberration amount
  127161. */
  127162. chromaticAberration: number;
  127163. /**
  127164. * Gets or sets the depth of field aperture
  127165. */
  127166. dofAperture: number;
  127167. /**
  127168. * Gets or sets the edge distortion
  127169. */
  127170. edgeDistortion: number;
  127171. /**
  127172. * Gets or sets the depth of field distortion
  127173. */
  127174. dofDistortion: number;
  127175. /**
  127176. * Gets or sets the darken out of focus amount
  127177. */
  127178. darkenOutOfFocus: number;
  127179. /**
  127180. * Gets or sets a boolean indicating if blur noise is enabled
  127181. */
  127182. blurNoise: boolean;
  127183. /**
  127184. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  127185. */
  127186. pentagonBokeh: boolean;
  127187. /**
  127188. * Gets or sets the highlight grain amount
  127189. */
  127190. highlightsGain: number;
  127191. /**
  127192. * Gets or sets the highlight threshold
  127193. */
  127194. highlightsThreshold: number;
  127195. /**
  127196. * Sets the amount of blur at the edges
  127197. * @param amount blur amount
  127198. */
  127199. setEdgeBlur(amount: number): void;
  127200. /**
  127201. * Sets edge blur to 0
  127202. */
  127203. disableEdgeBlur(): void;
  127204. /**
  127205. * Sets the amout of grain
  127206. * @param amount Amount of grain
  127207. */
  127208. setGrainAmount(amount: number): void;
  127209. /**
  127210. * Set grain amount to 0
  127211. */
  127212. disableGrain(): void;
  127213. /**
  127214. * Sets the chromatic aberration amount
  127215. * @param amount amount of chromatic aberration
  127216. */
  127217. setChromaticAberration(amount: number): void;
  127218. /**
  127219. * Sets chromatic aberration amount to 0
  127220. */
  127221. disableChromaticAberration(): void;
  127222. /**
  127223. * Sets the EdgeDistortion amount
  127224. * @param amount amount of EdgeDistortion
  127225. */
  127226. setEdgeDistortion(amount: number): void;
  127227. /**
  127228. * Sets edge distortion to 0
  127229. */
  127230. disableEdgeDistortion(): void;
  127231. /**
  127232. * Sets the FocusDistance amount
  127233. * @param amount amount of FocusDistance
  127234. */
  127235. setFocusDistance(amount: number): void;
  127236. /**
  127237. * Disables depth of field
  127238. */
  127239. disableDepthOfField(): void;
  127240. /**
  127241. * Sets the Aperture amount
  127242. * @param amount amount of Aperture
  127243. */
  127244. setAperture(amount: number): void;
  127245. /**
  127246. * Sets the DarkenOutOfFocus amount
  127247. * @param amount amount of DarkenOutOfFocus
  127248. */
  127249. setDarkenOutOfFocus(amount: number): void;
  127250. private _pentagonBokehIsEnabled;
  127251. /**
  127252. * Creates a pentagon bokeh effect
  127253. */
  127254. enablePentagonBokeh(): void;
  127255. /**
  127256. * Disables the pentagon bokeh effect
  127257. */
  127258. disablePentagonBokeh(): void;
  127259. /**
  127260. * Enables noise blur
  127261. */
  127262. enableNoiseBlur(): void;
  127263. /**
  127264. * Disables noise blur
  127265. */
  127266. disableNoiseBlur(): void;
  127267. /**
  127268. * Sets the HighlightsGain amount
  127269. * @param amount amount of HighlightsGain
  127270. */
  127271. setHighlightsGain(amount: number): void;
  127272. /**
  127273. * Sets the HighlightsThreshold amount
  127274. * @param amount amount of HighlightsThreshold
  127275. */
  127276. setHighlightsThreshold(amount: number): void;
  127277. /**
  127278. * Disables highlights
  127279. */
  127280. disableHighlights(): void;
  127281. /**
  127282. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  127283. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  127284. */
  127285. dispose(disableDepthRender?: boolean): void;
  127286. private _createChromaticAberrationPostProcess;
  127287. private _createHighlightsPostProcess;
  127288. private _createDepthOfFieldPostProcess;
  127289. private _createGrainTexture;
  127290. }
  127291. }
  127292. declare module BABYLON {
  127293. /** @hidden */
  127294. export var ssao2PixelShader: {
  127295. name: string;
  127296. shader: string;
  127297. };
  127298. }
  127299. declare module BABYLON {
  127300. /** @hidden */
  127301. export var ssaoCombinePixelShader: {
  127302. name: string;
  127303. shader: string;
  127304. };
  127305. }
  127306. declare module BABYLON {
  127307. /**
  127308. * Render pipeline to produce ssao effect
  127309. */
  127310. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  127311. /**
  127312. * @ignore
  127313. * The PassPostProcess id in the pipeline that contains the original scene color
  127314. */
  127315. SSAOOriginalSceneColorEffect: string;
  127316. /**
  127317. * @ignore
  127318. * The SSAO PostProcess id in the pipeline
  127319. */
  127320. SSAORenderEffect: string;
  127321. /**
  127322. * @ignore
  127323. * The horizontal blur PostProcess id in the pipeline
  127324. */
  127325. SSAOBlurHRenderEffect: string;
  127326. /**
  127327. * @ignore
  127328. * The vertical blur PostProcess id in the pipeline
  127329. */
  127330. SSAOBlurVRenderEffect: string;
  127331. /**
  127332. * @ignore
  127333. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127334. */
  127335. SSAOCombineRenderEffect: string;
  127336. /**
  127337. * The output strength of the SSAO post-process. Default value is 1.0.
  127338. */
  127339. totalStrength: number;
  127340. /**
  127341. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  127342. */
  127343. maxZ: number;
  127344. /**
  127345. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  127346. */
  127347. minZAspect: number;
  127348. private _samples;
  127349. /**
  127350. * Number of samples used for the SSAO calculations. Default value is 8
  127351. */
  127352. samples: number;
  127353. private _textureSamples;
  127354. /**
  127355. * Number of samples to use for antialiasing
  127356. */
  127357. textureSamples: number;
  127358. /**
  127359. * Ratio object used for SSAO ratio and blur ratio
  127360. */
  127361. private _ratio;
  127362. /**
  127363. * Dynamically generated sphere sampler.
  127364. */
  127365. private _sampleSphere;
  127366. /**
  127367. * Blur filter offsets
  127368. */
  127369. private _samplerOffsets;
  127370. private _expensiveBlur;
  127371. /**
  127372. * If bilateral blur should be used
  127373. */
  127374. expensiveBlur: boolean;
  127375. /**
  127376. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  127377. */
  127378. radius: number;
  127379. /**
  127380. * The base color of the SSAO post-process
  127381. * The final result is "base + ssao" between [0, 1]
  127382. */
  127383. base: number;
  127384. /**
  127385. * Support test.
  127386. */
  127387. static readonly IsSupported: boolean;
  127388. private _scene;
  127389. private _depthTexture;
  127390. private _normalTexture;
  127391. private _randomTexture;
  127392. private _originalColorPostProcess;
  127393. private _ssaoPostProcess;
  127394. private _blurHPostProcess;
  127395. private _blurVPostProcess;
  127396. private _ssaoCombinePostProcess;
  127397. private _firstUpdate;
  127398. /**
  127399. * Gets active scene
  127400. */
  127401. readonly scene: Scene;
  127402. /**
  127403. * @constructor
  127404. * @param name The rendering pipeline name
  127405. * @param scene The scene linked to this pipeline
  127406. * @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 }
  127407. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127408. */
  127409. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127410. /**
  127411. * Get the class name
  127412. * @returns "SSAO2RenderingPipeline"
  127413. */
  127414. getClassName(): string;
  127415. /**
  127416. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127417. */
  127418. dispose(disableGeometryBufferRenderer?: boolean): void;
  127419. private _createBlurPostProcess;
  127420. /** @hidden */
  127421. _rebuild(): void;
  127422. private _bits;
  127423. private _radicalInverse_VdC;
  127424. private _hammersley;
  127425. private _hemisphereSample_uniform;
  127426. private _generateHemisphere;
  127427. private _createSSAOPostProcess;
  127428. private _createSSAOCombinePostProcess;
  127429. private _createRandomTexture;
  127430. /**
  127431. * Serialize the rendering pipeline (Used when exporting)
  127432. * @returns the serialized object
  127433. */
  127434. serialize(): any;
  127435. /**
  127436. * Parse the serialized pipeline
  127437. * @param source Source pipeline.
  127438. * @param scene The scene to load the pipeline to.
  127439. * @param rootUrl The URL of the serialized pipeline.
  127440. * @returns An instantiated pipeline from the serialized object.
  127441. */
  127442. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  127443. }
  127444. }
  127445. declare module BABYLON {
  127446. /** @hidden */
  127447. export var ssaoPixelShader: {
  127448. name: string;
  127449. shader: string;
  127450. };
  127451. }
  127452. declare module BABYLON {
  127453. /**
  127454. * Render pipeline to produce ssao effect
  127455. */
  127456. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  127457. /**
  127458. * @ignore
  127459. * The PassPostProcess id in the pipeline that contains the original scene color
  127460. */
  127461. SSAOOriginalSceneColorEffect: string;
  127462. /**
  127463. * @ignore
  127464. * The SSAO PostProcess id in the pipeline
  127465. */
  127466. SSAORenderEffect: string;
  127467. /**
  127468. * @ignore
  127469. * The horizontal blur PostProcess id in the pipeline
  127470. */
  127471. SSAOBlurHRenderEffect: string;
  127472. /**
  127473. * @ignore
  127474. * The vertical blur PostProcess id in the pipeline
  127475. */
  127476. SSAOBlurVRenderEffect: string;
  127477. /**
  127478. * @ignore
  127479. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127480. */
  127481. SSAOCombineRenderEffect: string;
  127482. /**
  127483. * The output strength of the SSAO post-process. Default value is 1.0.
  127484. */
  127485. totalStrength: number;
  127486. /**
  127487. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  127488. */
  127489. radius: number;
  127490. /**
  127491. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  127492. * Must not be equal to fallOff and superior to fallOff.
  127493. * Default value is 0.0075
  127494. */
  127495. area: number;
  127496. /**
  127497. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  127498. * Must not be equal to area and inferior to area.
  127499. * Default value is 0.000001
  127500. */
  127501. fallOff: number;
  127502. /**
  127503. * The base color of the SSAO post-process
  127504. * The final result is "base + ssao" between [0, 1]
  127505. */
  127506. base: number;
  127507. private _scene;
  127508. private _depthTexture;
  127509. private _randomTexture;
  127510. private _originalColorPostProcess;
  127511. private _ssaoPostProcess;
  127512. private _blurHPostProcess;
  127513. private _blurVPostProcess;
  127514. private _ssaoCombinePostProcess;
  127515. private _firstUpdate;
  127516. /**
  127517. * Gets active scene
  127518. */
  127519. readonly scene: Scene;
  127520. /**
  127521. * @constructor
  127522. * @param name - The rendering pipeline name
  127523. * @param scene - The scene linked to this pipeline
  127524. * @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 }
  127525. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  127526. */
  127527. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127528. /**
  127529. * Get the class name
  127530. * @returns "SSAORenderingPipeline"
  127531. */
  127532. getClassName(): string;
  127533. /**
  127534. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127535. */
  127536. dispose(disableDepthRender?: boolean): void;
  127537. private _createBlurPostProcess;
  127538. /** @hidden */
  127539. _rebuild(): void;
  127540. private _createSSAOPostProcess;
  127541. private _createSSAOCombinePostProcess;
  127542. private _createRandomTexture;
  127543. }
  127544. }
  127545. declare module BABYLON {
  127546. /** @hidden */
  127547. export var standardPixelShader: {
  127548. name: string;
  127549. shader: string;
  127550. };
  127551. }
  127552. declare module BABYLON {
  127553. /**
  127554. * Standard rendering pipeline
  127555. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127556. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  127557. */
  127558. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  127559. /**
  127560. * Public members
  127561. */
  127562. /**
  127563. * Post-process which contains the original scene color before the pipeline applies all the effects
  127564. */
  127565. originalPostProcess: Nullable<PostProcess>;
  127566. /**
  127567. * Post-process used to down scale an image x4
  127568. */
  127569. downSampleX4PostProcess: Nullable<PostProcess>;
  127570. /**
  127571. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  127572. */
  127573. brightPassPostProcess: Nullable<PostProcess>;
  127574. /**
  127575. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  127576. */
  127577. blurHPostProcesses: PostProcess[];
  127578. /**
  127579. * Post-process array storing all the vertical blur post-processes used by the pipeline
  127580. */
  127581. blurVPostProcesses: PostProcess[];
  127582. /**
  127583. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  127584. */
  127585. textureAdderPostProcess: Nullable<PostProcess>;
  127586. /**
  127587. * Post-process used to create volumetric lighting effect
  127588. */
  127589. volumetricLightPostProcess: Nullable<PostProcess>;
  127590. /**
  127591. * Post-process used to smooth the previous volumetric light post-process on the X axis
  127592. */
  127593. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  127594. /**
  127595. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  127596. */
  127597. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  127598. /**
  127599. * Post-process used to merge the volumetric light effect and the real scene color
  127600. */
  127601. volumetricLightMergePostProces: Nullable<PostProcess>;
  127602. /**
  127603. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  127604. */
  127605. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  127606. /**
  127607. * Base post-process used to calculate the average luminance of the final image for HDR
  127608. */
  127609. luminancePostProcess: Nullable<PostProcess>;
  127610. /**
  127611. * Post-processes used to create down sample post-processes in order to get
  127612. * the average luminance of the final image for HDR
  127613. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  127614. */
  127615. luminanceDownSamplePostProcesses: PostProcess[];
  127616. /**
  127617. * Post-process used to create a HDR effect (light adaptation)
  127618. */
  127619. hdrPostProcess: Nullable<PostProcess>;
  127620. /**
  127621. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  127622. */
  127623. textureAdderFinalPostProcess: Nullable<PostProcess>;
  127624. /**
  127625. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  127626. */
  127627. lensFlareFinalPostProcess: Nullable<PostProcess>;
  127628. /**
  127629. * Post-process used to merge the final HDR post-process and the real scene color
  127630. */
  127631. hdrFinalPostProcess: Nullable<PostProcess>;
  127632. /**
  127633. * Post-process used to create a lens flare effect
  127634. */
  127635. lensFlarePostProcess: Nullable<PostProcess>;
  127636. /**
  127637. * Post-process that merges the result of the lens flare post-process and the real scene color
  127638. */
  127639. lensFlareComposePostProcess: Nullable<PostProcess>;
  127640. /**
  127641. * Post-process used to create a motion blur effect
  127642. */
  127643. motionBlurPostProcess: Nullable<PostProcess>;
  127644. /**
  127645. * Post-process used to create a depth of field effect
  127646. */
  127647. depthOfFieldPostProcess: Nullable<PostProcess>;
  127648. /**
  127649. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  127650. */
  127651. fxaaPostProcess: Nullable<FxaaPostProcess>;
  127652. /**
  127653. * Represents the brightness threshold in order to configure the illuminated surfaces
  127654. */
  127655. brightThreshold: number;
  127656. /**
  127657. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  127658. */
  127659. blurWidth: number;
  127660. /**
  127661. * Sets if the blur for highlighted surfaces must be only horizontal
  127662. */
  127663. horizontalBlur: boolean;
  127664. /**
  127665. * Gets the overall exposure used by the pipeline
  127666. */
  127667. /**
  127668. * Sets the overall exposure used by the pipeline
  127669. */
  127670. exposure: number;
  127671. /**
  127672. * Texture used typically to simulate "dirty" on camera lens
  127673. */
  127674. lensTexture: Nullable<Texture>;
  127675. /**
  127676. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  127677. */
  127678. volumetricLightCoefficient: number;
  127679. /**
  127680. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  127681. */
  127682. volumetricLightPower: number;
  127683. /**
  127684. * Used the set the blur intensity to smooth the volumetric lights
  127685. */
  127686. volumetricLightBlurScale: number;
  127687. /**
  127688. * Light (spot or directional) used to generate the volumetric lights rays
  127689. * The source light must have a shadow generate so the pipeline can get its
  127690. * depth map
  127691. */
  127692. sourceLight: Nullable<SpotLight | DirectionalLight>;
  127693. /**
  127694. * For eye adaptation, represents the minimum luminance the eye can see
  127695. */
  127696. hdrMinimumLuminance: number;
  127697. /**
  127698. * For eye adaptation, represents the decrease luminance speed
  127699. */
  127700. hdrDecreaseRate: number;
  127701. /**
  127702. * For eye adaptation, represents the increase luminance speed
  127703. */
  127704. hdrIncreaseRate: number;
  127705. /**
  127706. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127707. */
  127708. /**
  127709. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127710. */
  127711. hdrAutoExposure: boolean;
  127712. /**
  127713. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  127714. */
  127715. lensColorTexture: Nullable<Texture>;
  127716. /**
  127717. * The overall strengh for the lens flare effect
  127718. */
  127719. lensFlareStrength: number;
  127720. /**
  127721. * Dispersion coefficient for lens flare ghosts
  127722. */
  127723. lensFlareGhostDispersal: number;
  127724. /**
  127725. * Main lens flare halo width
  127726. */
  127727. lensFlareHaloWidth: number;
  127728. /**
  127729. * Based on the lens distortion effect, defines how much the lens flare result
  127730. * is distorted
  127731. */
  127732. lensFlareDistortionStrength: number;
  127733. /**
  127734. * Configures the blur intensity used for for lens flare (halo)
  127735. */
  127736. lensFlareBlurWidth: number;
  127737. /**
  127738. * Lens star texture must be used to simulate rays on the flares and is available
  127739. * in the documentation
  127740. */
  127741. lensStarTexture: Nullable<Texture>;
  127742. /**
  127743. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  127744. * flare effect by taking account of the dirt texture
  127745. */
  127746. lensFlareDirtTexture: Nullable<Texture>;
  127747. /**
  127748. * Represents the focal length for the depth of field effect
  127749. */
  127750. depthOfFieldDistance: number;
  127751. /**
  127752. * Represents the blur intensity for the blurred part of the depth of field effect
  127753. */
  127754. depthOfFieldBlurWidth: number;
  127755. /**
  127756. * Gets how much the image is blurred by the movement while using the motion blur post-process
  127757. */
  127758. /**
  127759. * Sets how much the image is blurred by the movement while using the motion blur post-process
  127760. */
  127761. motionStrength: number;
  127762. /**
  127763. * Gets wether or not the motion blur post-process is object based or screen based.
  127764. */
  127765. /**
  127766. * Sets wether or not the motion blur post-process should be object based or screen based
  127767. */
  127768. objectBasedMotionBlur: boolean;
  127769. /**
  127770. * List of animations for the pipeline (IAnimatable implementation)
  127771. */
  127772. animations: Animation[];
  127773. /**
  127774. * Private members
  127775. */
  127776. private _scene;
  127777. private _currentDepthOfFieldSource;
  127778. private _basePostProcess;
  127779. private _fixedExposure;
  127780. private _currentExposure;
  127781. private _hdrAutoExposure;
  127782. private _hdrCurrentLuminance;
  127783. private _motionStrength;
  127784. private _isObjectBasedMotionBlur;
  127785. private _floatTextureType;
  127786. private _camerasToBeAttached;
  127787. private _ratio;
  127788. private _bloomEnabled;
  127789. private _depthOfFieldEnabled;
  127790. private _vlsEnabled;
  127791. private _lensFlareEnabled;
  127792. private _hdrEnabled;
  127793. private _motionBlurEnabled;
  127794. private _fxaaEnabled;
  127795. private _motionBlurSamples;
  127796. private _volumetricLightStepsCount;
  127797. private _samples;
  127798. /**
  127799. * @ignore
  127800. * Specifies if the bloom pipeline is enabled
  127801. */
  127802. BloomEnabled: boolean;
  127803. /**
  127804. * @ignore
  127805. * Specifies if the depth of field pipeline is enabed
  127806. */
  127807. DepthOfFieldEnabled: boolean;
  127808. /**
  127809. * @ignore
  127810. * Specifies if the lens flare pipeline is enabed
  127811. */
  127812. LensFlareEnabled: boolean;
  127813. /**
  127814. * @ignore
  127815. * Specifies if the HDR pipeline is enabled
  127816. */
  127817. HDREnabled: boolean;
  127818. /**
  127819. * @ignore
  127820. * Specifies if the volumetric lights scattering effect is enabled
  127821. */
  127822. VLSEnabled: boolean;
  127823. /**
  127824. * @ignore
  127825. * Specifies if the motion blur effect is enabled
  127826. */
  127827. MotionBlurEnabled: boolean;
  127828. /**
  127829. * Specifies if anti-aliasing is enabled
  127830. */
  127831. fxaaEnabled: boolean;
  127832. /**
  127833. * Specifies the number of steps used to calculate the volumetric lights
  127834. * Typically in interval [50, 200]
  127835. */
  127836. volumetricLightStepsCount: number;
  127837. /**
  127838. * Specifies the number of samples used for the motion blur effect
  127839. * Typically in interval [16, 64]
  127840. */
  127841. motionBlurSamples: number;
  127842. /**
  127843. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  127844. */
  127845. samples: number;
  127846. /**
  127847. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127848. * @constructor
  127849. * @param name The rendering pipeline name
  127850. * @param scene The scene linked to this pipeline
  127851. * @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)
  127852. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  127853. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127854. */
  127855. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  127856. private _buildPipeline;
  127857. private _createDownSampleX4PostProcess;
  127858. private _createBrightPassPostProcess;
  127859. private _createBlurPostProcesses;
  127860. private _createTextureAdderPostProcess;
  127861. private _createVolumetricLightPostProcess;
  127862. private _createLuminancePostProcesses;
  127863. private _createHdrPostProcess;
  127864. private _createLensFlarePostProcess;
  127865. private _createDepthOfFieldPostProcess;
  127866. private _createMotionBlurPostProcess;
  127867. private _getDepthTexture;
  127868. private _disposePostProcesses;
  127869. /**
  127870. * Dispose of the pipeline and stop all post processes
  127871. */
  127872. dispose(): void;
  127873. /**
  127874. * Serialize the rendering pipeline (Used when exporting)
  127875. * @returns the serialized object
  127876. */
  127877. serialize(): any;
  127878. /**
  127879. * Parse the serialized pipeline
  127880. * @param source Source pipeline.
  127881. * @param scene The scene to load the pipeline to.
  127882. * @param rootUrl The URL of the serialized pipeline.
  127883. * @returns An instantiated pipeline from the serialized object.
  127884. */
  127885. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  127886. /**
  127887. * Luminance steps
  127888. */
  127889. static LuminanceSteps: number;
  127890. }
  127891. }
  127892. declare module BABYLON {
  127893. /** @hidden */
  127894. export var tonemapPixelShader: {
  127895. name: string;
  127896. shader: string;
  127897. };
  127898. }
  127899. declare module BABYLON {
  127900. /** Defines operator used for tonemapping */
  127901. export enum TonemappingOperator {
  127902. /** Hable */
  127903. Hable = 0,
  127904. /** Reinhard */
  127905. Reinhard = 1,
  127906. /** HejiDawson */
  127907. HejiDawson = 2,
  127908. /** Photographic */
  127909. Photographic = 3
  127910. }
  127911. /**
  127912. * Defines a post process to apply tone mapping
  127913. */
  127914. export class TonemapPostProcess extends PostProcess {
  127915. private _operator;
  127916. /** Defines the required exposure adjustement */
  127917. exposureAdjustment: number;
  127918. /**
  127919. * Creates a new TonemapPostProcess
  127920. * @param name defines the name of the postprocess
  127921. * @param _operator defines the operator to use
  127922. * @param exposureAdjustment defines the required exposure adjustement
  127923. * @param camera defines the camera to use (can be null)
  127924. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  127925. * @param engine defines the hosting engine (can be ignore if camera is set)
  127926. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  127927. */
  127928. constructor(name: string, _operator: TonemappingOperator,
  127929. /** Defines the required exposure adjustement */
  127930. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  127931. }
  127932. }
  127933. declare module BABYLON {
  127934. /** @hidden */
  127935. export var depthVertexShader: {
  127936. name: string;
  127937. shader: string;
  127938. };
  127939. }
  127940. declare module BABYLON {
  127941. /** @hidden */
  127942. export var volumetricLightScatteringPixelShader: {
  127943. name: string;
  127944. shader: string;
  127945. };
  127946. }
  127947. declare module BABYLON {
  127948. /** @hidden */
  127949. export var volumetricLightScatteringPassVertexShader: {
  127950. name: string;
  127951. shader: string;
  127952. };
  127953. }
  127954. declare module BABYLON {
  127955. /** @hidden */
  127956. export var volumetricLightScatteringPassPixelShader: {
  127957. name: string;
  127958. shader: string;
  127959. };
  127960. }
  127961. declare module BABYLON {
  127962. /**
  127963. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  127964. */
  127965. export class VolumetricLightScatteringPostProcess extends PostProcess {
  127966. private _volumetricLightScatteringPass;
  127967. private _volumetricLightScatteringRTT;
  127968. private _viewPort;
  127969. private _screenCoordinates;
  127970. private _cachedDefines;
  127971. /**
  127972. * If not undefined, the mesh position is computed from the attached node position
  127973. */
  127974. attachedNode: {
  127975. position: Vector3;
  127976. };
  127977. /**
  127978. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  127979. */
  127980. customMeshPosition: Vector3;
  127981. /**
  127982. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  127983. */
  127984. useCustomMeshPosition: boolean;
  127985. /**
  127986. * If the post-process should inverse the light scattering direction
  127987. */
  127988. invert: boolean;
  127989. /**
  127990. * The internal mesh used by the post-process
  127991. */
  127992. mesh: Mesh;
  127993. /**
  127994. * @hidden
  127995. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  127996. */
  127997. useDiffuseColor: boolean;
  127998. /**
  127999. * Array containing the excluded meshes not rendered in the internal pass
  128000. */
  128001. excludedMeshes: AbstractMesh[];
  128002. /**
  128003. * Controls the overall intensity of the post-process
  128004. */
  128005. exposure: number;
  128006. /**
  128007. * Dissipates each sample's contribution in range [0, 1]
  128008. */
  128009. decay: number;
  128010. /**
  128011. * Controls the overall intensity of each sample
  128012. */
  128013. weight: number;
  128014. /**
  128015. * Controls the density of each sample
  128016. */
  128017. density: number;
  128018. /**
  128019. * @constructor
  128020. * @param name The post-process name
  128021. * @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)
  128022. * @param camera The camera that the post-process will be attached to
  128023. * @param mesh The mesh used to create the light scattering
  128024. * @param samples The post-process quality, default 100
  128025. * @param samplingModeThe post-process filtering mode
  128026. * @param engine The babylon engine
  128027. * @param reusable If the post-process is reusable
  128028. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  128029. */
  128030. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  128031. /**
  128032. * Returns the string "VolumetricLightScatteringPostProcess"
  128033. * @returns "VolumetricLightScatteringPostProcess"
  128034. */
  128035. getClassName(): string;
  128036. private _isReady;
  128037. /**
  128038. * Sets the new light position for light scattering effect
  128039. * @param position The new custom light position
  128040. */
  128041. setCustomMeshPosition(position: Vector3): void;
  128042. /**
  128043. * Returns the light position for light scattering effect
  128044. * @return Vector3 The custom light position
  128045. */
  128046. getCustomMeshPosition(): Vector3;
  128047. /**
  128048. * Disposes the internal assets and detaches the post-process from the camera
  128049. */
  128050. dispose(camera: Camera): void;
  128051. /**
  128052. * Returns the render target texture used by the post-process
  128053. * @return the render target texture used by the post-process
  128054. */
  128055. getPass(): RenderTargetTexture;
  128056. private _meshExcluded;
  128057. private _createPass;
  128058. private _updateMeshScreenCoordinates;
  128059. /**
  128060. * Creates a default mesh for the Volumeric Light Scattering post-process
  128061. * @param name The mesh name
  128062. * @param scene The scene where to create the mesh
  128063. * @return the default mesh
  128064. */
  128065. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  128066. }
  128067. }
  128068. declare module BABYLON {
  128069. interface Scene {
  128070. /** @hidden (Backing field) */
  128071. _boundingBoxRenderer: BoundingBoxRenderer;
  128072. /** @hidden (Backing field) */
  128073. _forceShowBoundingBoxes: boolean;
  128074. /**
  128075. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  128076. */
  128077. forceShowBoundingBoxes: boolean;
  128078. /**
  128079. * Gets the bounding box renderer associated with the scene
  128080. * @returns a BoundingBoxRenderer
  128081. */
  128082. getBoundingBoxRenderer(): BoundingBoxRenderer;
  128083. }
  128084. interface AbstractMesh {
  128085. /** @hidden (Backing field) */
  128086. _showBoundingBox: boolean;
  128087. /**
  128088. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  128089. */
  128090. showBoundingBox: boolean;
  128091. }
  128092. /**
  128093. * Component responsible of rendering the bounding box of the meshes in a scene.
  128094. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  128095. */
  128096. export class BoundingBoxRenderer implements ISceneComponent {
  128097. /**
  128098. * The component name helpfull to identify the component in the list of scene components.
  128099. */
  128100. readonly name: string;
  128101. /**
  128102. * The scene the component belongs to.
  128103. */
  128104. scene: Scene;
  128105. /**
  128106. * Color of the bounding box lines placed in front of an object
  128107. */
  128108. frontColor: Color3;
  128109. /**
  128110. * Color of the bounding box lines placed behind an object
  128111. */
  128112. backColor: Color3;
  128113. /**
  128114. * Defines if the renderer should show the back lines or not
  128115. */
  128116. showBackLines: boolean;
  128117. /**
  128118. * @hidden
  128119. */
  128120. renderList: SmartArray<BoundingBox>;
  128121. private _colorShader;
  128122. private _vertexBuffers;
  128123. private _indexBuffer;
  128124. private _fillIndexBuffer;
  128125. private _fillIndexData;
  128126. /**
  128127. * Instantiates a new bounding box renderer in a scene.
  128128. * @param scene the scene the renderer renders in
  128129. */
  128130. constructor(scene: Scene);
  128131. /**
  128132. * Registers the component in a given scene
  128133. */
  128134. register(): void;
  128135. private _evaluateSubMesh;
  128136. private _activeMesh;
  128137. private _prepareRessources;
  128138. private _createIndexBuffer;
  128139. /**
  128140. * Rebuilds the elements related to this component in case of
  128141. * context lost for instance.
  128142. */
  128143. rebuild(): void;
  128144. /**
  128145. * @hidden
  128146. */
  128147. reset(): void;
  128148. /**
  128149. * Render the bounding boxes of a specific rendering group
  128150. * @param renderingGroupId defines the rendering group to render
  128151. */
  128152. render(renderingGroupId: number): void;
  128153. /**
  128154. * In case of occlusion queries, we can render the occlusion bounding box through this method
  128155. * @param mesh Define the mesh to render the occlusion bounding box for
  128156. */
  128157. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  128158. /**
  128159. * Dispose and release the resources attached to this renderer.
  128160. */
  128161. dispose(): void;
  128162. }
  128163. }
  128164. declare module BABYLON {
  128165. /** @hidden */
  128166. export var depthPixelShader: {
  128167. name: string;
  128168. shader: string;
  128169. };
  128170. }
  128171. declare module BABYLON {
  128172. /**
  128173. * This represents a depth renderer in Babylon.
  128174. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  128175. */
  128176. export class DepthRenderer {
  128177. private _scene;
  128178. private _depthMap;
  128179. private _effect;
  128180. private readonly _storeNonLinearDepth;
  128181. private readonly _clearColor;
  128182. /** Get if the depth renderer is using packed depth or not */
  128183. readonly isPacked: boolean;
  128184. private _cachedDefines;
  128185. private _camera;
  128186. /**
  128187. * Specifiess that the depth renderer will only be used within
  128188. * the camera it is created for.
  128189. * This can help forcing its rendering during the camera processing.
  128190. */
  128191. useOnlyInActiveCamera: boolean;
  128192. /** @hidden */
  128193. static _SceneComponentInitialization: (scene: Scene) => void;
  128194. /**
  128195. * Instantiates a depth renderer
  128196. * @param scene The scene the renderer belongs to
  128197. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  128198. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  128199. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128200. */
  128201. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  128202. /**
  128203. * Creates the depth rendering effect and checks if the effect is ready.
  128204. * @param subMesh The submesh to be used to render the depth map of
  128205. * @param useInstances If multiple world instances should be used
  128206. * @returns if the depth renderer is ready to render the depth map
  128207. */
  128208. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128209. /**
  128210. * Gets the texture which the depth map will be written to.
  128211. * @returns The depth map texture
  128212. */
  128213. getDepthMap(): RenderTargetTexture;
  128214. /**
  128215. * Disposes of the depth renderer.
  128216. */
  128217. dispose(): void;
  128218. }
  128219. }
  128220. declare module BABYLON {
  128221. interface Scene {
  128222. /** @hidden (Backing field) */
  128223. _depthRenderer: {
  128224. [id: string]: DepthRenderer;
  128225. };
  128226. /**
  128227. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  128228. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  128229. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128230. * @returns the created depth renderer
  128231. */
  128232. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  128233. /**
  128234. * Disables a depth renderer for a given camera
  128235. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  128236. */
  128237. disableDepthRenderer(camera?: Nullable<Camera>): void;
  128238. }
  128239. /**
  128240. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  128241. * in several rendering techniques.
  128242. */
  128243. export class DepthRendererSceneComponent implements ISceneComponent {
  128244. /**
  128245. * The component name helpfull to identify the component in the list of scene components.
  128246. */
  128247. readonly name: string;
  128248. /**
  128249. * The scene the component belongs to.
  128250. */
  128251. scene: Scene;
  128252. /**
  128253. * Creates a new instance of the component for the given scene
  128254. * @param scene Defines the scene to register the component in
  128255. */
  128256. constructor(scene: Scene);
  128257. /**
  128258. * Registers the component in a given scene
  128259. */
  128260. register(): void;
  128261. /**
  128262. * Rebuilds the elements related to this component in case of
  128263. * context lost for instance.
  128264. */
  128265. rebuild(): void;
  128266. /**
  128267. * Disposes the component and the associated ressources
  128268. */
  128269. dispose(): void;
  128270. private _gatherRenderTargets;
  128271. private _gatherActiveCameraRenderTargets;
  128272. }
  128273. }
  128274. declare module BABYLON {
  128275. /** @hidden */
  128276. export var outlinePixelShader: {
  128277. name: string;
  128278. shader: string;
  128279. };
  128280. }
  128281. declare module BABYLON {
  128282. /** @hidden */
  128283. export var outlineVertexShader: {
  128284. name: string;
  128285. shader: string;
  128286. };
  128287. }
  128288. declare module BABYLON {
  128289. interface Scene {
  128290. /** @hidden */
  128291. _outlineRenderer: OutlineRenderer;
  128292. /**
  128293. * Gets the outline renderer associated with the scene
  128294. * @returns a OutlineRenderer
  128295. */
  128296. getOutlineRenderer(): OutlineRenderer;
  128297. }
  128298. interface AbstractMesh {
  128299. /** @hidden (Backing field) */
  128300. _renderOutline: boolean;
  128301. /**
  128302. * Gets or sets a boolean indicating if the outline must be rendered as well
  128303. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  128304. */
  128305. renderOutline: boolean;
  128306. /** @hidden (Backing field) */
  128307. _renderOverlay: boolean;
  128308. /**
  128309. * Gets or sets a boolean indicating if the overlay must be rendered as well
  128310. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  128311. */
  128312. renderOverlay: boolean;
  128313. }
  128314. /**
  128315. * This class is responsible to draw bothe outline/overlay of meshes.
  128316. * It should not be used directly but through the available method on mesh.
  128317. */
  128318. export class OutlineRenderer implements ISceneComponent {
  128319. /**
  128320. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  128321. */
  128322. private static _StencilReference;
  128323. /**
  128324. * The name of the component. Each component must have a unique name.
  128325. */
  128326. name: string;
  128327. /**
  128328. * The scene the component belongs to.
  128329. */
  128330. scene: Scene;
  128331. /**
  128332. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  128333. */
  128334. zOffset: number;
  128335. private _engine;
  128336. private _effect;
  128337. private _cachedDefines;
  128338. private _savedDepthWrite;
  128339. /**
  128340. * Instantiates a new outline renderer. (There could be only one per scene).
  128341. * @param scene Defines the scene it belongs to
  128342. */
  128343. constructor(scene: Scene);
  128344. /**
  128345. * Register the component to one instance of a scene.
  128346. */
  128347. register(): void;
  128348. /**
  128349. * Rebuilds the elements related to this component in case of
  128350. * context lost for instance.
  128351. */
  128352. rebuild(): void;
  128353. /**
  128354. * Disposes the component and the associated ressources.
  128355. */
  128356. dispose(): void;
  128357. /**
  128358. * Renders the outline in the canvas.
  128359. * @param subMesh Defines the sumesh to render
  128360. * @param batch Defines the batch of meshes in case of instances
  128361. * @param useOverlay Defines if the rendering is for the overlay or the outline
  128362. */
  128363. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  128364. /**
  128365. * Returns whether or not the outline renderer is ready for a given submesh.
  128366. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  128367. * @param subMesh Defines the submesh to check readyness for
  128368. * @param useInstances Defines wheter wee are trying to render instances or not
  128369. * @returns true if ready otherwise false
  128370. */
  128371. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128372. private _beforeRenderingMesh;
  128373. private _afterRenderingMesh;
  128374. }
  128375. }
  128376. declare module BABYLON {
  128377. /**
  128378. * Class used to manage multiple sprites of different sizes on the same spritesheet
  128379. * @see http://doc.babylonjs.com/babylon101/sprites
  128380. */
  128381. export class SpritePackedManager extends SpriteManager {
  128382. /** defines the packed manager's name */
  128383. name: string;
  128384. /**
  128385. * Creates a new sprite manager from a packed sprite sheet
  128386. * @param name defines the manager's name
  128387. * @param imgUrl defines the sprite sheet url
  128388. * @param capacity defines the maximum allowed number of sprites
  128389. * @param scene defines the hosting scene
  128390. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  128391. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  128392. * @param samplingMode defines the smapling mode to use with spritesheet
  128393. * @param fromPacked set to true; do not alter
  128394. */
  128395. constructor(
  128396. /** defines the packed manager's name */
  128397. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  128398. }
  128399. }
  128400. declare module BABYLON {
  128401. /**
  128402. * Defines the list of states available for a task inside a AssetsManager
  128403. */
  128404. export enum AssetTaskState {
  128405. /**
  128406. * Initialization
  128407. */
  128408. INIT = 0,
  128409. /**
  128410. * Running
  128411. */
  128412. RUNNING = 1,
  128413. /**
  128414. * Done
  128415. */
  128416. DONE = 2,
  128417. /**
  128418. * Error
  128419. */
  128420. ERROR = 3
  128421. }
  128422. /**
  128423. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  128424. */
  128425. export abstract class AbstractAssetTask {
  128426. /**
  128427. * Task name
  128428. */ name: string;
  128429. /**
  128430. * Callback called when the task is successful
  128431. */
  128432. onSuccess: (task: any) => void;
  128433. /**
  128434. * Callback called when the task is not successful
  128435. */
  128436. onError: (task: any, message?: string, exception?: any) => void;
  128437. /**
  128438. * Creates a new AssetsManager
  128439. * @param name defines the name of the task
  128440. */
  128441. constructor(
  128442. /**
  128443. * Task name
  128444. */ name: string);
  128445. private _isCompleted;
  128446. private _taskState;
  128447. private _errorObject;
  128448. /**
  128449. * Get if the task is completed
  128450. */
  128451. readonly isCompleted: boolean;
  128452. /**
  128453. * Gets the current state of the task
  128454. */
  128455. readonly taskState: AssetTaskState;
  128456. /**
  128457. * Gets the current error object (if task is in error)
  128458. */
  128459. readonly errorObject: {
  128460. message?: string;
  128461. exception?: any;
  128462. };
  128463. /**
  128464. * Internal only
  128465. * @hidden
  128466. */
  128467. _setErrorObject(message?: string, exception?: any): void;
  128468. /**
  128469. * Execute the current task
  128470. * @param scene defines the scene where you want your assets to be loaded
  128471. * @param onSuccess is a callback called when the task is successfully executed
  128472. * @param onError is a callback called if an error occurs
  128473. */
  128474. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128475. /**
  128476. * Execute the current task
  128477. * @param scene defines the scene where you want your assets to be loaded
  128478. * @param onSuccess is a callback called when the task is successfully executed
  128479. * @param onError is a callback called if an error occurs
  128480. */
  128481. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128482. /**
  128483. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  128484. * This can be used with failed tasks that have the reason for failure fixed.
  128485. */
  128486. reset(): void;
  128487. private onErrorCallback;
  128488. private onDoneCallback;
  128489. }
  128490. /**
  128491. * Define the interface used by progress events raised during assets loading
  128492. */
  128493. export interface IAssetsProgressEvent {
  128494. /**
  128495. * Defines the number of remaining tasks to process
  128496. */
  128497. remainingCount: number;
  128498. /**
  128499. * Defines the total number of tasks
  128500. */
  128501. totalCount: number;
  128502. /**
  128503. * Defines the task that was just processed
  128504. */
  128505. task: AbstractAssetTask;
  128506. }
  128507. /**
  128508. * Class used to share progress information about assets loading
  128509. */
  128510. export class AssetsProgressEvent implements IAssetsProgressEvent {
  128511. /**
  128512. * Defines the number of remaining tasks to process
  128513. */
  128514. remainingCount: number;
  128515. /**
  128516. * Defines the total number of tasks
  128517. */
  128518. totalCount: number;
  128519. /**
  128520. * Defines the task that was just processed
  128521. */
  128522. task: AbstractAssetTask;
  128523. /**
  128524. * Creates a AssetsProgressEvent
  128525. * @param remainingCount defines the number of remaining tasks to process
  128526. * @param totalCount defines the total number of tasks
  128527. * @param task defines the task that was just processed
  128528. */
  128529. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  128530. }
  128531. /**
  128532. * Define a task used by AssetsManager to load meshes
  128533. */
  128534. export class MeshAssetTask extends AbstractAssetTask {
  128535. /**
  128536. * Defines the name of the task
  128537. */
  128538. name: string;
  128539. /**
  128540. * Defines the list of mesh's names you want to load
  128541. */
  128542. meshesNames: any;
  128543. /**
  128544. * Defines the root url to use as a base to load your meshes and associated resources
  128545. */
  128546. rootUrl: string;
  128547. /**
  128548. * Defines the filename of the scene to load from
  128549. */
  128550. sceneFilename: string;
  128551. /**
  128552. * Gets the list of loaded meshes
  128553. */
  128554. loadedMeshes: Array<AbstractMesh>;
  128555. /**
  128556. * Gets the list of loaded particle systems
  128557. */
  128558. loadedParticleSystems: Array<IParticleSystem>;
  128559. /**
  128560. * Gets the list of loaded skeletons
  128561. */
  128562. loadedSkeletons: Array<Skeleton>;
  128563. /**
  128564. * Gets the list of loaded animation groups
  128565. */
  128566. loadedAnimationGroups: Array<AnimationGroup>;
  128567. /**
  128568. * Callback called when the task is successful
  128569. */
  128570. onSuccess: (task: MeshAssetTask) => void;
  128571. /**
  128572. * Callback called when the task is successful
  128573. */
  128574. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  128575. /**
  128576. * Creates a new MeshAssetTask
  128577. * @param name defines the name of the task
  128578. * @param meshesNames defines the list of mesh's names you want to load
  128579. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  128580. * @param sceneFilename defines the filename of the scene to load from
  128581. */
  128582. constructor(
  128583. /**
  128584. * Defines the name of the task
  128585. */
  128586. name: string,
  128587. /**
  128588. * Defines the list of mesh's names you want to load
  128589. */
  128590. meshesNames: any,
  128591. /**
  128592. * Defines the root url to use as a base to load your meshes and associated resources
  128593. */
  128594. rootUrl: string,
  128595. /**
  128596. * Defines the filename of the scene to load from
  128597. */
  128598. sceneFilename: string);
  128599. /**
  128600. * Execute the current task
  128601. * @param scene defines the scene where you want your assets to be loaded
  128602. * @param onSuccess is a callback called when the task is successfully executed
  128603. * @param onError is a callback called if an error occurs
  128604. */
  128605. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128606. }
  128607. /**
  128608. * Define a task used by AssetsManager to load text content
  128609. */
  128610. export class TextFileAssetTask extends AbstractAssetTask {
  128611. /**
  128612. * Defines the name of the task
  128613. */
  128614. name: string;
  128615. /**
  128616. * Defines the location of the file to load
  128617. */
  128618. url: string;
  128619. /**
  128620. * Gets the loaded text string
  128621. */
  128622. text: string;
  128623. /**
  128624. * Callback called when the task is successful
  128625. */
  128626. onSuccess: (task: TextFileAssetTask) => void;
  128627. /**
  128628. * Callback called when the task is successful
  128629. */
  128630. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  128631. /**
  128632. * Creates a new TextFileAssetTask object
  128633. * @param name defines the name of the task
  128634. * @param url defines the location of the file to load
  128635. */
  128636. constructor(
  128637. /**
  128638. * Defines the name of the task
  128639. */
  128640. name: string,
  128641. /**
  128642. * Defines the location of the file to load
  128643. */
  128644. url: string);
  128645. /**
  128646. * Execute the current task
  128647. * @param scene defines the scene where you want your assets to be loaded
  128648. * @param onSuccess is a callback called when the task is successfully executed
  128649. * @param onError is a callback called if an error occurs
  128650. */
  128651. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128652. }
  128653. /**
  128654. * Define a task used by AssetsManager to load binary data
  128655. */
  128656. export class BinaryFileAssetTask extends AbstractAssetTask {
  128657. /**
  128658. * Defines the name of the task
  128659. */
  128660. name: string;
  128661. /**
  128662. * Defines the location of the file to load
  128663. */
  128664. url: string;
  128665. /**
  128666. * Gets the lodaded data (as an array buffer)
  128667. */
  128668. data: ArrayBuffer;
  128669. /**
  128670. * Callback called when the task is successful
  128671. */
  128672. onSuccess: (task: BinaryFileAssetTask) => void;
  128673. /**
  128674. * Callback called when the task is successful
  128675. */
  128676. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  128677. /**
  128678. * Creates a new BinaryFileAssetTask object
  128679. * @param name defines the name of the new task
  128680. * @param url defines the location of the file to load
  128681. */
  128682. constructor(
  128683. /**
  128684. * Defines the name of the task
  128685. */
  128686. name: string,
  128687. /**
  128688. * Defines the location of the file to load
  128689. */
  128690. url: string);
  128691. /**
  128692. * Execute the current task
  128693. * @param scene defines the scene where you want your assets to be loaded
  128694. * @param onSuccess is a callback called when the task is successfully executed
  128695. * @param onError is a callback called if an error occurs
  128696. */
  128697. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128698. }
  128699. /**
  128700. * Define a task used by AssetsManager to load images
  128701. */
  128702. export class ImageAssetTask extends AbstractAssetTask {
  128703. /**
  128704. * Defines the name of the task
  128705. */
  128706. name: string;
  128707. /**
  128708. * Defines the location of the image to load
  128709. */
  128710. url: string;
  128711. /**
  128712. * Gets the loaded images
  128713. */
  128714. image: HTMLImageElement;
  128715. /**
  128716. * Callback called when the task is successful
  128717. */
  128718. onSuccess: (task: ImageAssetTask) => void;
  128719. /**
  128720. * Callback called when the task is successful
  128721. */
  128722. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  128723. /**
  128724. * Creates a new ImageAssetTask
  128725. * @param name defines the name of the task
  128726. * @param url defines the location of the image to load
  128727. */
  128728. constructor(
  128729. /**
  128730. * Defines the name of the task
  128731. */
  128732. name: string,
  128733. /**
  128734. * Defines the location of the image to load
  128735. */
  128736. url: string);
  128737. /**
  128738. * Execute the current task
  128739. * @param scene defines the scene where you want your assets to be loaded
  128740. * @param onSuccess is a callback called when the task is successfully executed
  128741. * @param onError is a callback called if an error occurs
  128742. */
  128743. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128744. }
  128745. /**
  128746. * Defines the interface used by texture loading tasks
  128747. */
  128748. export interface ITextureAssetTask<TEX extends BaseTexture> {
  128749. /**
  128750. * Gets the loaded texture
  128751. */
  128752. texture: TEX;
  128753. }
  128754. /**
  128755. * Define a task used by AssetsManager to load 2D textures
  128756. */
  128757. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  128758. /**
  128759. * Defines the name of the task
  128760. */
  128761. name: string;
  128762. /**
  128763. * Defines the location of the file to load
  128764. */
  128765. url: string;
  128766. /**
  128767. * Defines if mipmap should not be generated (default is false)
  128768. */
  128769. noMipmap?: boolean | undefined;
  128770. /**
  128771. * Defines if texture must be inverted on Y axis (default is false)
  128772. */
  128773. invertY?: boolean | undefined;
  128774. /**
  128775. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128776. */
  128777. samplingMode: number;
  128778. /**
  128779. * Gets the loaded texture
  128780. */
  128781. texture: Texture;
  128782. /**
  128783. * Callback called when the task is successful
  128784. */
  128785. onSuccess: (task: TextureAssetTask) => void;
  128786. /**
  128787. * Callback called when the task is successful
  128788. */
  128789. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  128790. /**
  128791. * Creates a new TextureAssetTask object
  128792. * @param name defines the name of the task
  128793. * @param url defines the location of the file to load
  128794. * @param noMipmap defines if mipmap should not be generated (default is false)
  128795. * @param invertY defines if texture must be inverted on Y axis (default is false)
  128796. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128797. */
  128798. constructor(
  128799. /**
  128800. * Defines the name of the task
  128801. */
  128802. name: string,
  128803. /**
  128804. * Defines the location of the file to load
  128805. */
  128806. url: string,
  128807. /**
  128808. * Defines if mipmap should not be generated (default is false)
  128809. */
  128810. noMipmap?: boolean | undefined,
  128811. /**
  128812. * Defines if texture must be inverted on Y axis (default is false)
  128813. */
  128814. invertY?: boolean | undefined,
  128815. /**
  128816. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128817. */
  128818. samplingMode?: number);
  128819. /**
  128820. * Execute the current task
  128821. * @param scene defines the scene where you want your assets to be loaded
  128822. * @param onSuccess is a callback called when the task is successfully executed
  128823. * @param onError is a callback called if an error occurs
  128824. */
  128825. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128826. }
  128827. /**
  128828. * Define a task used by AssetsManager to load cube textures
  128829. */
  128830. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  128831. /**
  128832. * Defines the name of the task
  128833. */
  128834. name: string;
  128835. /**
  128836. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128837. */
  128838. url: string;
  128839. /**
  128840. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128841. */
  128842. extensions?: string[] | undefined;
  128843. /**
  128844. * Defines if mipmaps should not be generated (default is false)
  128845. */
  128846. noMipmap?: boolean | undefined;
  128847. /**
  128848. * Defines the explicit list of files (undefined by default)
  128849. */
  128850. files?: string[] | undefined;
  128851. /**
  128852. * Gets the loaded texture
  128853. */
  128854. texture: CubeTexture;
  128855. /**
  128856. * Callback called when the task is successful
  128857. */
  128858. onSuccess: (task: CubeTextureAssetTask) => void;
  128859. /**
  128860. * Callback called when the task is successful
  128861. */
  128862. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  128863. /**
  128864. * Creates a new CubeTextureAssetTask
  128865. * @param name defines the name of the task
  128866. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128867. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128868. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128869. * @param files defines the explicit list of files (undefined by default)
  128870. */
  128871. constructor(
  128872. /**
  128873. * Defines the name of the task
  128874. */
  128875. name: string,
  128876. /**
  128877. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128878. */
  128879. url: string,
  128880. /**
  128881. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128882. */
  128883. extensions?: string[] | undefined,
  128884. /**
  128885. * Defines if mipmaps should not be generated (default is false)
  128886. */
  128887. noMipmap?: boolean | undefined,
  128888. /**
  128889. * Defines the explicit list of files (undefined by default)
  128890. */
  128891. files?: string[] | undefined);
  128892. /**
  128893. * Execute the current task
  128894. * @param scene defines the scene where you want your assets to be loaded
  128895. * @param onSuccess is a callback called when the task is successfully executed
  128896. * @param onError is a callback called if an error occurs
  128897. */
  128898. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128899. }
  128900. /**
  128901. * Define a task used by AssetsManager to load HDR cube textures
  128902. */
  128903. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  128904. /**
  128905. * Defines the name of the task
  128906. */
  128907. name: string;
  128908. /**
  128909. * Defines the location of the file to load
  128910. */
  128911. url: string;
  128912. /**
  128913. * Defines the desired size (the more it increases the longer the generation will be)
  128914. */
  128915. size: number;
  128916. /**
  128917. * Defines if mipmaps should not be generated (default is false)
  128918. */
  128919. noMipmap: boolean;
  128920. /**
  128921. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128922. */
  128923. generateHarmonics: boolean;
  128924. /**
  128925. * 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)
  128926. */
  128927. gammaSpace: boolean;
  128928. /**
  128929. * Internal Use Only
  128930. */
  128931. reserved: boolean;
  128932. /**
  128933. * Gets the loaded texture
  128934. */
  128935. texture: HDRCubeTexture;
  128936. /**
  128937. * Callback called when the task is successful
  128938. */
  128939. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  128940. /**
  128941. * Callback called when the task is successful
  128942. */
  128943. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  128944. /**
  128945. * Creates a new HDRCubeTextureAssetTask object
  128946. * @param name defines the name of the task
  128947. * @param url defines the location of the file to load
  128948. * @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.
  128949. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128950. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128951. * @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)
  128952. * @param reserved Internal use only
  128953. */
  128954. constructor(
  128955. /**
  128956. * Defines the name of the task
  128957. */
  128958. name: string,
  128959. /**
  128960. * Defines the location of the file to load
  128961. */
  128962. url: string,
  128963. /**
  128964. * Defines the desired size (the more it increases the longer the generation will be)
  128965. */
  128966. size: number,
  128967. /**
  128968. * Defines if mipmaps should not be generated (default is false)
  128969. */
  128970. noMipmap?: boolean,
  128971. /**
  128972. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128973. */
  128974. generateHarmonics?: boolean,
  128975. /**
  128976. * 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)
  128977. */
  128978. gammaSpace?: boolean,
  128979. /**
  128980. * Internal Use Only
  128981. */
  128982. reserved?: boolean);
  128983. /**
  128984. * Execute the current task
  128985. * @param scene defines the scene where you want your assets to be loaded
  128986. * @param onSuccess is a callback called when the task is successfully executed
  128987. * @param onError is a callback called if an error occurs
  128988. */
  128989. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128990. }
  128991. /**
  128992. * Define a task used by AssetsManager to load Equirectangular cube textures
  128993. */
  128994. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  128995. /**
  128996. * Defines the name of the task
  128997. */
  128998. name: string;
  128999. /**
  129000. * Defines the location of the file to load
  129001. */
  129002. url: string;
  129003. /**
  129004. * Defines the desired size (the more it increases the longer the generation will be)
  129005. */
  129006. size: number;
  129007. /**
  129008. * Defines if mipmaps should not be generated (default is false)
  129009. */
  129010. noMipmap: boolean;
  129011. /**
  129012. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  129013. * but the standard material would require them in Gamma space) (default is true)
  129014. */
  129015. gammaSpace: boolean;
  129016. /**
  129017. * Gets the loaded texture
  129018. */
  129019. texture: EquiRectangularCubeTexture;
  129020. /**
  129021. * Callback called when the task is successful
  129022. */
  129023. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  129024. /**
  129025. * Callback called when the task is successful
  129026. */
  129027. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  129028. /**
  129029. * Creates a new EquiRectangularCubeTextureAssetTask object
  129030. * @param name defines the name of the task
  129031. * @param url defines the location of the file to load
  129032. * @param size defines the desired size (the more it increases the longer the generation will be)
  129033. * If the size is omitted this implies you are using a preprocessed cubemap.
  129034. * @param noMipmap defines if mipmaps should not be generated (default is false)
  129035. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  129036. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  129037. * (default is true)
  129038. */
  129039. constructor(
  129040. /**
  129041. * Defines the name of the task
  129042. */
  129043. name: string,
  129044. /**
  129045. * Defines the location of the file to load
  129046. */
  129047. url: string,
  129048. /**
  129049. * Defines the desired size (the more it increases the longer the generation will be)
  129050. */
  129051. size: number,
  129052. /**
  129053. * Defines if mipmaps should not be generated (default is false)
  129054. */
  129055. noMipmap?: boolean,
  129056. /**
  129057. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  129058. * but the standard material would require them in Gamma space) (default is true)
  129059. */
  129060. gammaSpace?: boolean);
  129061. /**
  129062. * Execute the current task
  129063. * @param scene defines the scene where you want your assets to be loaded
  129064. * @param onSuccess is a callback called when the task is successfully executed
  129065. * @param onError is a callback called if an error occurs
  129066. */
  129067. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129068. }
  129069. /**
  129070. * This class can be used to easily import assets into a scene
  129071. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  129072. */
  129073. export class AssetsManager {
  129074. private _scene;
  129075. private _isLoading;
  129076. protected _tasks: AbstractAssetTask[];
  129077. protected _waitingTasksCount: number;
  129078. protected _totalTasksCount: number;
  129079. /**
  129080. * Callback called when all tasks are processed
  129081. */
  129082. onFinish: (tasks: AbstractAssetTask[]) => void;
  129083. /**
  129084. * Callback called when a task is successful
  129085. */
  129086. onTaskSuccess: (task: AbstractAssetTask) => void;
  129087. /**
  129088. * Callback called when a task had an error
  129089. */
  129090. onTaskError: (task: AbstractAssetTask) => void;
  129091. /**
  129092. * Callback called when a task is done (whatever the result is)
  129093. */
  129094. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  129095. /**
  129096. * Observable called when all tasks are processed
  129097. */
  129098. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  129099. /**
  129100. * Observable called when a task had an error
  129101. */
  129102. onTaskErrorObservable: Observable<AbstractAssetTask>;
  129103. /**
  129104. * Observable called when all tasks were executed
  129105. */
  129106. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  129107. /**
  129108. * Observable called when a task is done (whatever the result is)
  129109. */
  129110. onProgressObservable: Observable<IAssetsProgressEvent>;
  129111. /**
  129112. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  129113. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  129114. */
  129115. useDefaultLoadingScreen: boolean;
  129116. /**
  129117. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  129118. * when all assets have been downloaded.
  129119. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  129120. */
  129121. autoHideLoadingUI: boolean;
  129122. /**
  129123. * Creates a new AssetsManager
  129124. * @param scene defines the scene to work on
  129125. */
  129126. constructor(scene: Scene);
  129127. /**
  129128. * Add a MeshAssetTask to the list of active tasks
  129129. * @param taskName defines the name of the new task
  129130. * @param meshesNames defines the name of meshes to load
  129131. * @param rootUrl defines the root url to use to locate files
  129132. * @param sceneFilename defines the filename of the scene file
  129133. * @returns a new MeshAssetTask object
  129134. */
  129135. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  129136. /**
  129137. * Add a TextFileAssetTask to the list of active tasks
  129138. * @param taskName defines the name of the new task
  129139. * @param url defines the url of the file to load
  129140. * @returns a new TextFileAssetTask object
  129141. */
  129142. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  129143. /**
  129144. * Add a BinaryFileAssetTask to the list of active tasks
  129145. * @param taskName defines the name of the new task
  129146. * @param url defines the url of the file to load
  129147. * @returns a new BinaryFileAssetTask object
  129148. */
  129149. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  129150. /**
  129151. * Add a ImageAssetTask to the list of active tasks
  129152. * @param taskName defines the name of the new task
  129153. * @param url defines the url of the file to load
  129154. * @returns a new ImageAssetTask object
  129155. */
  129156. addImageTask(taskName: string, url: string): ImageAssetTask;
  129157. /**
  129158. * Add a TextureAssetTask to the list of active tasks
  129159. * @param taskName defines the name of the new task
  129160. * @param url defines the url of the file to load
  129161. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129162. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  129163. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129164. * @returns a new TextureAssetTask object
  129165. */
  129166. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  129167. /**
  129168. * Add a CubeTextureAssetTask to the list of active tasks
  129169. * @param taskName defines the name of the new task
  129170. * @param url defines the url of the file to load
  129171. * @param extensions defines the extension to use to load the cube map (can be null)
  129172. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129173. * @param files defines the list of files to load (can be null)
  129174. * @returns a new CubeTextureAssetTask object
  129175. */
  129176. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  129177. /**
  129178. *
  129179. * Add a HDRCubeTextureAssetTask to the list of active tasks
  129180. * @param taskName defines the name of the new task
  129181. * @param url defines the url of the file to load
  129182. * @param size defines the size you want for the cubemap (can be null)
  129183. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129184. * @param generateHarmonics defines if you want to automatically generate (true by default)
  129185. * @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)
  129186. * @param reserved Internal use only
  129187. * @returns a new HDRCubeTextureAssetTask object
  129188. */
  129189. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  129190. /**
  129191. *
  129192. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  129193. * @param taskName defines the name of the new task
  129194. * @param url defines the url of the file to load
  129195. * @param size defines the size you want for the cubemap (can be null)
  129196. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129197. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129198. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129199. * @returns a new EquiRectangularCubeTextureAssetTask object
  129200. */
  129201. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  129202. /**
  129203. * Remove a task from the assets manager.
  129204. * @param task the task to remove
  129205. */
  129206. removeTask(task: AbstractAssetTask): void;
  129207. private _decreaseWaitingTasksCount;
  129208. private _runTask;
  129209. /**
  129210. * Reset the AssetsManager and remove all tasks
  129211. * @return the current instance of the AssetsManager
  129212. */
  129213. reset(): AssetsManager;
  129214. /**
  129215. * Start the loading process
  129216. * @return the current instance of the AssetsManager
  129217. */
  129218. load(): AssetsManager;
  129219. /**
  129220. * Start the loading process as an async operation
  129221. * @return a promise returning the list of failed tasks
  129222. */
  129223. loadAsync(): Promise<void>;
  129224. }
  129225. }
  129226. declare module BABYLON {
  129227. /**
  129228. * Wrapper class for promise with external resolve and reject.
  129229. */
  129230. export class Deferred<T> {
  129231. /**
  129232. * The promise associated with this deferred object.
  129233. */
  129234. readonly promise: Promise<T>;
  129235. private _resolve;
  129236. private _reject;
  129237. /**
  129238. * The resolve method of the promise associated with this deferred object.
  129239. */
  129240. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  129241. /**
  129242. * The reject method of the promise associated with this deferred object.
  129243. */
  129244. readonly reject: (reason?: any) => void;
  129245. /**
  129246. * Constructor for this deferred object.
  129247. */
  129248. constructor();
  129249. }
  129250. }
  129251. declare module BABYLON {
  129252. /**
  129253. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  129254. */
  129255. export class MeshExploder {
  129256. private _centerMesh;
  129257. private _meshes;
  129258. private _meshesOrigins;
  129259. private _toCenterVectors;
  129260. private _scaledDirection;
  129261. private _newPosition;
  129262. private _centerPosition;
  129263. /**
  129264. * Explodes meshes from a center mesh.
  129265. * @param meshes The meshes to explode.
  129266. * @param centerMesh The mesh to be center of explosion.
  129267. */
  129268. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  129269. private _setCenterMesh;
  129270. /**
  129271. * Get class name
  129272. * @returns "MeshExploder"
  129273. */
  129274. getClassName(): string;
  129275. /**
  129276. * "Exploded meshes"
  129277. * @returns Array of meshes with the centerMesh at index 0.
  129278. */
  129279. getMeshes(): Array<Mesh>;
  129280. /**
  129281. * Explodes meshes giving a specific direction
  129282. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  129283. */
  129284. explode(direction?: number): void;
  129285. }
  129286. }
  129287. declare module BABYLON {
  129288. /**
  129289. * Class used to help managing file picking and drag'n'drop
  129290. */
  129291. export class FilesInput {
  129292. /**
  129293. * List of files ready to be loaded
  129294. */
  129295. static readonly FilesToLoad: {
  129296. [key: string]: File;
  129297. };
  129298. /**
  129299. * Callback called when a file is processed
  129300. */
  129301. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  129302. private _engine;
  129303. private _currentScene;
  129304. private _sceneLoadedCallback;
  129305. private _progressCallback;
  129306. private _additionalRenderLoopLogicCallback;
  129307. private _textureLoadingCallback;
  129308. private _startingProcessingFilesCallback;
  129309. private _onReloadCallback;
  129310. private _errorCallback;
  129311. private _elementToMonitor;
  129312. private _sceneFileToLoad;
  129313. private _filesToLoad;
  129314. /**
  129315. * Creates a new FilesInput
  129316. * @param engine defines the rendering engine
  129317. * @param scene defines the hosting scene
  129318. * @param sceneLoadedCallback callback called when scene is loaded
  129319. * @param progressCallback callback called to track progress
  129320. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  129321. * @param textureLoadingCallback callback called when a texture is loading
  129322. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  129323. * @param onReloadCallback callback called when a reload is requested
  129324. * @param errorCallback callback call if an error occurs
  129325. */
  129326. 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);
  129327. private _dragEnterHandler;
  129328. private _dragOverHandler;
  129329. private _dropHandler;
  129330. /**
  129331. * Calls this function to listen to drag'n'drop events on a specific DOM element
  129332. * @param elementToMonitor defines the DOM element to track
  129333. */
  129334. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  129335. /**
  129336. * Release all associated resources
  129337. */
  129338. dispose(): void;
  129339. private renderFunction;
  129340. private drag;
  129341. private drop;
  129342. private _traverseFolder;
  129343. private _processFiles;
  129344. /**
  129345. * Load files from a drop event
  129346. * @param event defines the drop event to use as source
  129347. */
  129348. loadFiles(event: any): void;
  129349. private _processReload;
  129350. /**
  129351. * Reload the current scene from the loaded files
  129352. */
  129353. reload(): void;
  129354. }
  129355. }
  129356. declare module BABYLON {
  129357. /**
  129358. * Defines the root class used to create scene optimization to use with SceneOptimizer
  129359. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129360. */
  129361. export class SceneOptimization {
  129362. /**
  129363. * Defines the priority of this optimization (0 by default which means first in the list)
  129364. */
  129365. priority: number;
  129366. /**
  129367. * Gets a string describing the action executed by the current optimization
  129368. * @returns description string
  129369. */
  129370. getDescription(): string;
  129371. /**
  129372. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129373. * @param scene defines the current scene where to apply this optimization
  129374. * @param optimizer defines the current optimizer
  129375. * @returns true if everything that can be done was applied
  129376. */
  129377. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129378. /**
  129379. * Creates the SceneOptimization object
  129380. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129381. * @param desc defines the description associated with the optimization
  129382. */
  129383. constructor(
  129384. /**
  129385. * Defines the priority of this optimization (0 by default which means first in the list)
  129386. */
  129387. priority?: number);
  129388. }
  129389. /**
  129390. * Defines an optimization used to reduce the size of render target textures
  129391. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129392. */
  129393. export class TextureOptimization extends SceneOptimization {
  129394. /**
  129395. * Defines the priority of this optimization (0 by default which means first in the list)
  129396. */
  129397. priority: number;
  129398. /**
  129399. * 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
  129400. */
  129401. maximumSize: number;
  129402. /**
  129403. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129404. */
  129405. step: number;
  129406. /**
  129407. * Gets a string describing the action executed by the current optimization
  129408. * @returns description string
  129409. */
  129410. getDescription(): string;
  129411. /**
  129412. * Creates the TextureOptimization object
  129413. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129414. * @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
  129415. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129416. */
  129417. constructor(
  129418. /**
  129419. * Defines the priority of this optimization (0 by default which means first in the list)
  129420. */
  129421. priority?: number,
  129422. /**
  129423. * 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
  129424. */
  129425. maximumSize?: number,
  129426. /**
  129427. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129428. */
  129429. step?: number);
  129430. /**
  129431. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129432. * @param scene defines the current scene where to apply this optimization
  129433. * @param optimizer defines the current optimizer
  129434. * @returns true if everything that can be done was applied
  129435. */
  129436. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129437. }
  129438. /**
  129439. * Defines an optimization used to increase or decrease the rendering resolution
  129440. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129441. */
  129442. export class HardwareScalingOptimization extends SceneOptimization {
  129443. /**
  129444. * Defines the priority of this optimization (0 by default which means first in the list)
  129445. */
  129446. priority: number;
  129447. /**
  129448. * Defines the maximum scale to use (2 by default)
  129449. */
  129450. maximumScale: number;
  129451. /**
  129452. * Defines the step to use between two passes (0.5 by default)
  129453. */
  129454. step: number;
  129455. private _currentScale;
  129456. private _directionOffset;
  129457. /**
  129458. * Gets a string describing the action executed by the current optimization
  129459. * @return description string
  129460. */
  129461. getDescription(): string;
  129462. /**
  129463. * Creates the HardwareScalingOptimization object
  129464. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129465. * @param maximumScale defines the maximum scale to use (2 by default)
  129466. * @param step defines the step to use between two passes (0.5 by default)
  129467. */
  129468. constructor(
  129469. /**
  129470. * Defines the priority of this optimization (0 by default which means first in the list)
  129471. */
  129472. priority?: number,
  129473. /**
  129474. * Defines the maximum scale to use (2 by default)
  129475. */
  129476. maximumScale?: number,
  129477. /**
  129478. * Defines the step to use between two passes (0.5 by default)
  129479. */
  129480. step?: number);
  129481. /**
  129482. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129483. * @param scene defines the current scene where to apply this optimization
  129484. * @param optimizer defines the current optimizer
  129485. * @returns true if everything that can be done was applied
  129486. */
  129487. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129488. }
  129489. /**
  129490. * Defines an optimization used to remove shadows
  129491. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129492. */
  129493. export class ShadowsOptimization extends SceneOptimization {
  129494. /**
  129495. * Gets a string describing the action executed by the current optimization
  129496. * @return description string
  129497. */
  129498. getDescription(): string;
  129499. /**
  129500. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129501. * @param scene defines the current scene where to apply this optimization
  129502. * @param optimizer defines the current optimizer
  129503. * @returns true if everything that can be done was applied
  129504. */
  129505. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129506. }
  129507. /**
  129508. * Defines an optimization used to turn post-processes off
  129509. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129510. */
  129511. export class PostProcessesOptimization extends SceneOptimization {
  129512. /**
  129513. * Gets a string describing the action executed by the current optimization
  129514. * @return description string
  129515. */
  129516. getDescription(): string;
  129517. /**
  129518. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129519. * @param scene defines the current scene where to apply this optimization
  129520. * @param optimizer defines the current optimizer
  129521. * @returns true if everything that can be done was applied
  129522. */
  129523. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129524. }
  129525. /**
  129526. * Defines an optimization used to turn lens flares off
  129527. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129528. */
  129529. export class LensFlaresOptimization extends SceneOptimization {
  129530. /**
  129531. * Gets a string describing the action executed by the current optimization
  129532. * @return description string
  129533. */
  129534. getDescription(): string;
  129535. /**
  129536. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129537. * @param scene defines the current scene where to apply this optimization
  129538. * @param optimizer defines the current optimizer
  129539. * @returns true if everything that can be done was applied
  129540. */
  129541. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129542. }
  129543. /**
  129544. * Defines an optimization based on user defined callback.
  129545. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129546. */
  129547. export class CustomOptimization extends SceneOptimization {
  129548. /**
  129549. * Callback called to apply the custom optimization.
  129550. */
  129551. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  129552. /**
  129553. * Callback called to get custom description
  129554. */
  129555. onGetDescription: () => string;
  129556. /**
  129557. * Gets a string describing the action executed by the current optimization
  129558. * @returns description string
  129559. */
  129560. getDescription(): string;
  129561. /**
  129562. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129563. * @param scene defines the current scene where to apply this optimization
  129564. * @param optimizer defines the current optimizer
  129565. * @returns true if everything that can be done was applied
  129566. */
  129567. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129568. }
  129569. /**
  129570. * Defines an optimization used to turn particles off
  129571. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129572. */
  129573. export class ParticlesOptimization extends SceneOptimization {
  129574. /**
  129575. * Gets a string describing the action executed by the current optimization
  129576. * @return description string
  129577. */
  129578. getDescription(): string;
  129579. /**
  129580. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129581. * @param scene defines the current scene where to apply this optimization
  129582. * @param optimizer defines the current optimizer
  129583. * @returns true if everything that can be done was applied
  129584. */
  129585. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129586. }
  129587. /**
  129588. * Defines an optimization used to turn render targets off
  129589. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129590. */
  129591. export class RenderTargetsOptimization extends SceneOptimization {
  129592. /**
  129593. * Gets a string describing the action executed by the current optimization
  129594. * @return description string
  129595. */
  129596. getDescription(): string;
  129597. /**
  129598. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129599. * @param scene defines the current scene where to apply this optimization
  129600. * @param optimizer defines the current optimizer
  129601. * @returns true if everything that can be done was applied
  129602. */
  129603. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129604. }
  129605. /**
  129606. * Defines an optimization used to merge meshes with compatible materials
  129607. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129608. */
  129609. export class MergeMeshesOptimization extends SceneOptimization {
  129610. private static _UpdateSelectionTree;
  129611. /**
  129612. * Gets or sets a boolean which defines if optimization octree has to be updated
  129613. */
  129614. /**
  129615. * Gets or sets a boolean which defines if optimization octree has to be updated
  129616. */
  129617. static UpdateSelectionTree: boolean;
  129618. /**
  129619. * Gets a string describing the action executed by the current optimization
  129620. * @return description string
  129621. */
  129622. getDescription(): string;
  129623. private _canBeMerged;
  129624. /**
  129625. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129626. * @param scene defines the current scene where to apply this optimization
  129627. * @param optimizer defines the current optimizer
  129628. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  129629. * @returns true if everything that can be done was applied
  129630. */
  129631. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  129632. }
  129633. /**
  129634. * Defines a list of options used by SceneOptimizer
  129635. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129636. */
  129637. export class SceneOptimizerOptions {
  129638. /**
  129639. * Defines the target frame rate to reach (60 by default)
  129640. */
  129641. targetFrameRate: number;
  129642. /**
  129643. * Defines the interval between two checkes (2000ms by default)
  129644. */
  129645. trackerDuration: number;
  129646. /**
  129647. * Gets the list of optimizations to apply
  129648. */
  129649. optimizations: SceneOptimization[];
  129650. /**
  129651. * Creates a new list of options used by SceneOptimizer
  129652. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  129653. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  129654. */
  129655. constructor(
  129656. /**
  129657. * Defines the target frame rate to reach (60 by default)
  129658. */
  129659. targetFrameRate?: number,
  129660. /**
  129661. * Defines the interval between two checkes (2000ms by default)
  129662. */
  129663. trackerDuration?: number);
  129664. /**
  129665. * Add a new optimization
  129666. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  129667. * @returns the current SceneOptimizerOptions
  129668. */
  129669. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  129670. /**
  129671. * Add a new custom optimization
  129672. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  129673. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  129674. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129675. * @returns the current SceneOptimizerOptions
  129676. */
  129677. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  129678. /**
  129679. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  129680. * @param targetFrameRate defines the target frame rate (60 by default)
  129681. * @returns a SceneOptimizerOptions object
  129682. */
  129683. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129684. /**
  129685. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  129686. * @param targetFrameRate defines the target frame rate (60 by default)
  129687. * @returns a SceneOptimizerOptions object
  129688. */
  129689. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129690. /**
  129691. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  129692. * @param targetFrameRate defines the target frame rate (60 by default)
  129693. * @returns a SceneOptimizerOptions object
  129694. */
  129695. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129696. }
  129697. /**
  129698. * Class used to run optimizations in order to reach a target frame rate
  129699. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129700. */
  129701. export class SceneOptimizer implements IDisposable {
  129702. private _isRunning;
  129703. private _options;
  129704. private _scene;
  129705. private _currentPriorityLevel;
  129706. private _targetFrameRate;
  129707. private _trackerDuration;
  129708. private _currentFrameRate;
  129709. private _sceneDisposeObserver;
  129710. private _improvementMode;
  129711. /**
  129712. * Defines an observable called when the optimizer reaches the target frame rate
  129713. */
  129714. onSuccessObservable: Observable<SceneOptimizer>;
  129715. /**
  129716. * Defines an observable called when the optimizer enables an optimization
  129717. */
  129718. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  129719. /**
  129720. * Defines an observable called when the optimizer is not able to reach the target frame rate
  129721. */
  129722. onFailureObservable: Observable<SceneOptimizer>;
  129723. /**
  129724. * Gets a boolean indicating if the optimizer is in improvement mode
  129725. */
  129726. readonly isInImprovementMode: boolean;
  129727. /**
  129728. * Gets the current priority level (0 at start)
  129729. */
  129730. readonly currentPriorityLevel: number;
  129731. /**
  129732. * Gets the current frame rate checked by the SceneOptimizer
  129733. */
  129734. readonly currentFrameRate: number;
  129735. /**
  129736. * Gets or sets the current target frame rate (60 by default)
  129737. */
  129738. /**
  129739. * Gets or sets the current target frame rate (60 by default)
  129740. */
  129741. targetFrameRate: number;
  129742. /**
  129743. * Gets or sets the current interval between two checks (every 2000ms by default)
  129744. */
  129745. /**
  129746. * Gets or sets the current interval between two checks (every 2000ms by default)
  129747. */
  129748. trackerDuration: number;
  129749. /**
  129750. * Gets the list of active optimizations
  129751. */
  129752. readonly optimizations: SceneOptimization[];
  129753. /**
  129754. * Creates a new SceneOptimizer
  129755. * @param scene defines the scene to work on
  129756. * @param options defines the options to use with the SceneOptimizer
  129757. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  129758. * @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)
  129759. */
  129760. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  129761. /**
  129762. * Stops the current optimizer
  129763. */
  129764. stop(): void;
  129765. /**
  129766. * Reset the optimizer to initial step (current priority level = 0)
  129767. */
  129768. reset(): void;
  129769. /**
  129770. * Start the optimizer. By default it will try to reach a specific framerate
  129771. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  129772. */
  129773. start(): void;
  129774. private _checkCurrentState;
  129775. /**
  129776. * Release all resources
  129777. */
  129778. dispose(): void;
  129779. /**
  129780. * Helper function to create a SceneOptimizer with one single line of code
  129781. * @param scene defines the scene to work on
  129782. * @param options defines the options to use with the SceneOptimizer
  129783. * @param onSuccess defines a callback to call on success
  129784. * @param onFailure defines a callback to call on failure
  129785. * @returns the new SceneOptimizer object
  129786. */
  129787. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  129788. }
  129789. }
  129790. declare module BABYLON {
  129791. /**
  129792. * Class used to serialize a scene into a string
  129793. */
  129794. export class SceneSerializer {
  129795. /**
  129796. * Clear cache used by a previous serialization
  129797. */
  129798. static ClearCache(): void;
  129799. /**
  129800. * Serialize a scene into a JSON compatible object
  129801. * @param scene defines the scene to serialize
  129802. * @returns a JSON compatible object
  129803. */
  129804. static Serialize(scene: Scene): any;
  129805. /**
  129806. * Serialize a mesh into a JSON compatible object
  129807. * @param toSerialize defines the mesh to serialize
  129808. * @param withParents defines if parents must be serialized as well
  129809. * @param withChildren defines if children must be serialized as well
  129810. * @returns a JSON compatible object
  129811. */
  129812. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  129813. }
  129814. }
  129815. declare module BABYLON {
  129816. /**
  129817. * Class used to host texture specific utilities
  129818. */
  129819. export class TextureTools {
  129820. /**
  129821. * Uses the GPU to create a copy texture rescaled at a given size
  129822. * @param texture Texture to copy from
  129823. * @param width defines the desired width
  129824. * @param height defines the desired height
  129825. * @param useBilinearMode defines if bilinear mode has to be used
  129826. * @return the generated texture
  129827. */
  129828. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  129829. }
  129830. }
  129831. declare module BABYLON {
  129832. /**
  129833. * This represents the different options available for the video capture.
  129834. */
  129835. export interface VideoRecorderOptions {
  129836. /** Defines the mime type of the video. */
  129837. mimeType: string;
  129838. /** Defines the FPS the video should be recorded at. */
  129839. fps: number;
  129840. /** Defines the chunk size for the recording data. */
  129841. recordChunckSize: number;
  129842. /** The audio tracks to attach to the recording. */
  129843. audioTracks?: MediaStreamTrack[];
  129844. }
  129845. /**
  129846. * This can help with recording videos from BabylonJS.
  129847. * This is based on the available WebRTC functionalities of the browser.
  129848. *
  129849. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  129850. */
  129851. export class VideoRecorder {
  129852. private static readonly _defaultOptions;
  129853. /**
  129854. * Returns whether or not the VideoRecorder is available in your browser.
  129855. * @param engine Defines the Babylon Engine.
  129856. * @returns true if supported otherwise false.
  129857. */
  129858. static IsSupported(engine: Engine): boolean;
  129859. private readonly _options;
  129860. private _canvas;
  129861. private _mediaRecorder;
  129862. private _recordedChunks;
  129863. private _fileName;
  129864. private _resolve;
  129865. private _reject;
  129866. /**
  129867. * True when a recording is already in progress.
  129868. */
  129869. readonly isRecording: boolean;
  129870. /**
  129871. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  129872. * @param engine Defines the BabylonJS Engine you wish to record.
  129873. * @param options Defines options that can be used to customize the capture.
  129874. */
  129875. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  129876. /**
  129877. * Stops the current recording before the default capture timeout passed in the startRecording function.
  129878. */
  129879. stopRecording(): void;
  129880. /**
  129881. * Starts recording the canvas for a max duration specified in parameters.
  129882. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  129883. * If null no automatic download will start and you can rely on the promise to get the data back.
  129884. * @param maxDuration Defines the maximum recording time in seconds.
  129885. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  129886. * @return A promise callback at the end of the recording with the video data in Blob.
  129887. */
  129888. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  129889. /**
  129890. * Releases internal resources used during the recording.
  129891. */
  129892. dispose(): void;
  129893. private _handleDataAvailable;
  129894. private _handleError;
  129895. private _handleStop;
  129896. }
  129897. }
  129898. declare module BABYLON {
  129899. /**
  129900. * Class containing a set of static utilities functions for screenshots
  129901. */
  129902. export class ScreenshotTools {
  129903. /**
  129904. * Captures a screenshot of the current rendering
  129905. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129906. * @param engine defines the rendering engine
  129907. * @param camera defines the source camera
  129908. * @param size This parameter can be set to a single number or to an object with the
  129909. * following (optional) properties: precision, width, height. If a single number is passed,
  129910. * it will be used for both width and height. If an object is passed, the screenshot size
  129911. * will be derived from the parameters. The precision property is a multiplier allowing
  129912. * rendering at a higher or lower resolution
  129913. * @param successCallback defines the callback receives a single parameter which contains the
  129914. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129915. * src parameter of an <img> to display it
  129916. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129917. * Check your browser for supported MIME types
  129918. */
  129919. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  129920. /**
  129921. * Captures a screenshot of the current rendering
  129922. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129923. * @param engine defines the rendering engine
  129924. * @param camera defines the source camera
  129925. * @param size This parameter can be set to a single number or to an object with the
  129926. * following (optional) properties: precision, width, height. If a single number is passed,
  129927. * it will be used for both width and height. If an object is passed, the screenshot size
  129928. * will be derived from the parameters. The precision property is a multiplier allowing
  129929. * rendering at a higher or lower resolution
  129930. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129931. * Check your browser for supported MIME types
  129932. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129933. * to the src parameter of an <img> to display it
  129934. */
  129935. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  129936. /**
  129937. * Generates an image screenshot from the specified camera.
  129938. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129939. * @param engine The engine to use for rendering
  129940. * @param camera The camera to use for rendering
  129941. * @param size This parameter can be set to a single number or to an object with the
  129942. * following (optional) properties: precision, width, height. If a single number is passed,
  129943. * it will be used for both width and height. If an object is passed, the screenshot size
  129944. * will be derived from the parameters. The precision property is a multiplier allowing
  129945. * rendering at a higher or lower resolution
  129946. * @param successCallback The callback receives a single parameter which contains the
  129947. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129948. * src parameter of an <img> to display it
  129949. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129950. * Check your browser for supported MIME types
  129951. * @param samples Texture samples (default: 1)
  129952. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129953. * @param fileName A name for for the downloaded file.
  129954. */
  129955. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  129956. /**
  129957. * Generates an image screenshot from the specified camera.
  129958. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129959. * @param engine The engine to use for rendering
  129960. * @param camera The camera to use for rendering
  129961. * @param size This parameter can be set to a single number or to an object with the
  129962. * following (optional) properties: precision, width, height. If a single number is passed,
  129963. * it will be used for both width and height. If an object is passed, the screenshot size
  129964. * will be derived from the parameters. The precision property is a multiplier allowing
  129965. * rendering at a higher or lower resolution
  129966. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129967. * Check your browser for supported MIME types
  129968. * @param samples Texture samples (default: 1)
  129969. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129970. * @param fileName A name for for the downloaded file.
  129971. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129972. * to the src parameter of an <img> to display it
  129973. */
  129974. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  129975. /**
  129976. * Gets height and width for screenshot size
  129977. * @private
  129978. */
  129979. private static _getScreenshotSize;
  129980. }
  129981. }
  129982. declare module BABYLON {
  129983. /**
  129984. * A cursor which tracks a point on a path
  129985. */
  129986. export class PathCursor {
  129987. private path;
  129988. /**
  129989. * Stores path cursor callbacks for when an onchange event is triggered
  129990. */
  129991. private _onchange;
  129992. /**
  129993. * The value of the path cursor
  129994. */
  129995. value: number;
  129996. /**
  129997. * The animation array of the path cursor
  129998. */
  129999. animations: Animation[];
  130000. /**
  130001. * Initializes the path cursor
  130002. * @param path The path to track
  130003. */
  130004. constructor(path: Path2);
  130005. /**
  130006. * Gets the cursor point on the path
  130007. * @returns A point on the path cursor at the cursor location
  130008. */
  130009. getPoint(): Vector3;
  130010. /**
  130011. * Moves the cursor ahead by the step amount
  130012. * @param step The amount to move the cursor forward
  130013. * @returns This path cursor
  130014. */
  130015. moveAhead(step?: number): PathCursor;
  130016. /**
  130017. * Moves the cursor behind by the step amount
  130018. * @param step The amount to move the cursor back
  130019. * @returns This path cursor
  130020. */
  130021. moveBack(step?: number): PathCursor;
  130022. /**
  130023. * Moves the cursor by the step amount
  130024. * If the step amount is greater than one, an exception is thrown
  130025. * @param step The amount to move the cursor
  130026. * @returns This path cursor
  130027. */
  130028. move(step: number): PathCursor;
  130029. /**
  130030. * Ensures that the value is limited between zero and one
  130031. * @returns This path cursor
  130032. */
  130033. private ensureLimits;
  130034. /**
  130035. * Runs onchange callbacks on change (used by the animation engine)
  130036. * @returns This path cursor
  130037. */
  130038. private raiseOnChange;
  130039. /**
  130040. * Executes a function on change
  130041. * @param f A path cursor onchange callback
  130042. * @returns This path cursor
  130043. */
  130044. onchange(f: (cursor: PathCursor) => void): PathCursor;
  130045. }
  130046. }
  130047. declare module BABYLON {
  130048. /** @hidden */
  130049. export var blurPixelShader: {
  130050. name: string;
  130051. shader: string;
  130052. };
  130053. }
  130054. declare module BABYLON {
  130055. /** @hidden */
  130056. export var pointCloudVertexDeclaration: {
  130057. name: string;
  130058. shader: string;
  130059. };
  130060. }
  130061. // Mixins
  130062. interface Window {
  130063. mozIndexedDB: IDBFactory;
  130064. webkitIndexedDB: IDBFactory;
  130065. msIndexedDB: IDBFactory;
  130066. webkitURL: typeof URL;
  130067. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  130068. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  130069. WebGLRenderingContext: WebGLRenderingContext;
  130070. MSGesture: MSGesture;
  130071. CANNON: any;
  130072. AudioContext: AudioContext;
  130073. webkitAudioContext: AudioContext;
  130074. PointerEvent: any;
  130075. Math: Math;
  130076. Uint8Array: Uint8ArrayConstructor;
  130077. Float32Array: Float32ArrayConstructor;
  130078. mozURL: typeof URL;
  130079. msURL: typeof URL;
  130080. VRFrameData: any; // WebVR, from specs 1.1
  130081. DracoDecoderModule: any;
  130082. setImmediate(handler: (...args: any[]) => void): number;
  130083. }
  130084. interface HTMLCanvasElement {
  130085. requestPointerLock(): void;
  130086. msRequestPointerLock?(): void;
  130087. mozRequestPointerLock?(): void;
  130088. webkitRequestPointerLock?(): void;
  130089. /** Track wether a record is in progress */
  130090. isRecording: boolean;
  130091. /** Capture Stream method defined by some browsers */
  130092. captureStream(fps?: number): MediaStream;
  130093. }
  130094. interface CanvasRenderingContext2D {
  130095. msImageSmoothingEnabled: boolean;
  130096. }
  130097. interface MouseEvent {
  130098. mozMovementX: number;
  130099. mozMovementY: number;
  130100. webkitMovementX: number;
  130101. webkitMovementY: number;
  130102. msMovementX: number;
  130103. msMovementY: number;
  130104. }
  130105. interface Navigator {
  130106. mozGetVRDevices: (any: any) => any;
  130107. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130108. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130109. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130110. webkitGetGamepads(): Gamepad[];
  130111. msGetGamepads(): Gamepad[];
  130112. webkitGamepads(): Gamepad[];
  130113. }
  130114. interface HTMLVideoElement {
  130115. mozSrcObject: any;
  130116. }
  130117. interface Math {
  130118. fround(x: number): number;
  130119. imul(a: number, b: number): number;
  130120. }
  130121. interface WebGLRenderingContext {
  130122. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  130123. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  130124. vertexAttribDivisor(index: number, divisor: number): void;
  130125. createVertexArray(): any;
  130126. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  130127. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  130128. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  130129. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  130130. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  130131. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  130132. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  130133. // Queries
  130134. createQuery(): WebGLQuery;
  130135. deleteQuery(query: WebGLQuery): void;
  130136. beginQuery(target: number, query: WebGLQuery): void;
  130137. endQuery(target: number): void;
  130138. getQueryParameter(query: WebGLQuery, pname: number): any;
  130139. getQuery(target: number, pname: number): any;
  130140. MAX_SAMPLES: number;
  130141. RGBA8: number;
  130142. READ_FRAMEBUFFER: number;
  130143. DRAW_FRAMEBUFFER: number;
  130144. UNIFORM_BUFFER: number;
  130145. HALF_FLOAT_OES: number;
  130146. RGBA16F: number;
  130147. RGBA32F: number;
  130148. R32F: number;
  130149. RG32F: number;
  130150. RGB32F: number;
  130151. R16F: number;
  130152. RG16F: number;
  130153. RGB16F: number;
  130154. RED: number;
  130155. RG: number;
  130156. R8: number;
  130157. RG8: number;
  130158. UNSIGNED_INT_24_8: number;
  130159. DEPTH24_STENCIL8: number;
  130160. MIN: number;
  130161. MAX: number;
  130162. /* Multiple Render Targets */
  130163. drawBuffers(buffers: number[]): void;
  130164. readBuffer(src: number): void;
  130165. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  130166. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  130167. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  130168. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  130169. // Occlusion Query
  130170. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  130171. ANY_SAMPLES_PASSED: number;
  130172. QUERY_RESULT_AVAILABLE: number;
  130173. QUERY_RESULT: number;
  130174. }
  130175. interface WebGLProgram {
  130176. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  130177. }
  130178. interface EXT_disjoint_timer_query {
  130179. QUERY_COUNTER_BITS_EXT: number;
  130180. TIME_ELAPSED_EXT: number;
  130181. TIMESTAMP_EXT: number;
  130182. GPU_DISJOINT_EXT: number;
  130183. QUERY_RESULT_EXT: number;
  130184. QUERY_RESULT_AVAILABLE_EXT: number;
  130185. queryCounterEXT(query: WebGLQuery, target: number): void;
  130186. createQueryEXT(): WebGLQuery;
  130187. beginQueryEXT(target: number, query: WebGLQuery): void;
  130188. endQueryEXT(target: number): void;
  130189. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  130190. deleteQueryEXT(query: WebGLQuery): void;
  130191. }
  130192. interface WebGLUniformLocation {
  130193. _currentState: any;
  130194. }
  130195. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  130196. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  130197. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  130198. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130199. interface WebGLRenderingContext {
  130200. readonly RASTERIZER_DISCARD: number;
  130201. readonly DEPTH_COMPONENT24: number;
  130202. readonly TEXTURE_3D: number;
  130203. readonly TEXTURE_2D_ARRAY: number;
  130204. readonly TEXTURE_COMPARE_FUNC: number;
  130205. readonly TEXTURE_COMPARE_MODE: number;
  130206. readonly COMPARE_REF_TO_TEXTURE: number;
  130207. readonly TEXTURE_WRAP_R: number;
  130208. readonly HALF_FLOAT: number;
  130209. readonly RGB8: number;
  130210. readonly RED_INTEGER: number;
  130211. readonly RG_INTEGER: number;
  130212. readonly RGB_INTEGER: number;
  130213. readonly RGBA_INTEGER: number;
  130214. readonly R8_SNORM: number;
  130215. readonly RG8_SNORM: number;
  130216. readonly RGB8_SNORM: number;
  130217. readonly RGBA8_SNORM: number;
  130218. readonly R8I: number;
  130219. readonly RG8I: number;
  130220. readonly RGB8I: number;
  130221. readonly RGBA8I: number;
  130222. readonly R8UI: number;
  130223. readonly RG8UI: number;
  130224. readonly RGB8UI: number;
  130225. readonly RGBA8UI: number;
  130226. readonly R16I: number;
  130227. readonly RG16I: number;
  130228. readonly RGB16I: number;
  130229. readonly RGBA16I: number;
  130230. readonly R16UI: number;
  130231. readonly RG16UI: number;
  130232. readonly RGB16UI: number;
  130233. readonly RGBA16UI: number;
  130234. readonly R32I: number;
  130235. readonly RG32I: number;
  130236. readonly RGB32I: number;
  130237. readonly RGBA32I: number;
  130238. readonly R32UI: number;
  130239. readonly RG32UI: number;
  130240. readonly RGB32UI: number;
  130241. readonly RGBA32UI: number;
  130242. readonly RGB10_A2UI: number;
  130243. readonly R11F_G11F_B10F: number;
  130244. readonly RGB9_E5: number;
  130245. readonly RGB10_A2: number;
  130246. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  130247. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  130248. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  130249. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  130250. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  130251. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  130252. 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;
  130253. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  130254. readonly TRANSFORM_FEEDBACK: number;
  130255. readonly INTERLEAVED_ATTRIBS: number;
  130256. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  130257. createTransformFeedback(): WebGLTransformFeedback;
  130258. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  130259. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  130260. beginTransformFeedback(primitiveMode: number): void;
  130261. endTransformFeedback(): void;
  130262. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  130263. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130264. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130265. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130266. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  130267. }
  130268. interface ImageBitmap {
  130269. readonly width: number;
  130270. readonly height: number;
  130271. close(): void;
  130272. }
  130273. interface WebGLQuery extends WebGLObject {
  130274. }
  130275. declare var WebGLQuery: {
  130276. prototype: WebGLQuery;
  130277. new(): WebGLQuery;
  130278. };
  130279. interface WebGLSampler extends WebGLObject {
  130280. }
  130281. declare var WebGLSampler: {
  130282. prototype: WebGLSampler;
  130283. new(): WebGLSampler;
  130284. };
  130285. interface WebGLSync extends WebGLObject {
  130286. }
  130287. declare var WebGLSync: {
  130288. prototype: WebGLSync;
  130289. new(): WebGLSync;
  130290. };
  130291. interface WebGLTransformFeedback extends WebGLObject {
  130292. }
  130293. declare var WebGLTransformFeedback: {
  130294. prototype: WebGLTransformFeedback;
  130295. new(): WebGLTransformFeedback;
  130296. };
  130297. interface WebGLVertexArrayObject extends WebGLObject {
  130298. }
  130299. declare var WebGLVertexArrayObject: {
  130300. prototype: WebGLVertexArrayObject;
  130301. new(): WebGLVertexArrayObject;
  130302. };
  130303. // Type definitions for WebVR API
  130304. // Project: https://w3c.github.io/webvr/
  130305. // Definitions by: six a <https://github.com/lostfictions>
  130306. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130307. interface VRDisplay extends EventTarget {
  130308. /**
  130309. * Dictionary of capabilities describing the VRDisplay.
  130310. */
  130311. readonly capabilities: VRDisplayCapabilities;
  130312. /**
  130313. * z-depth defining the far plane of the eye view frustum
  130314. * enables mapping of values in the render target depth
  130315. * attachment to scene coordinates. Initially set to 10000.0.
  130316. */
  130317. depthFar: number;
  130318. /**
  130319. * z-depth defining the near plane of the eye view frustum
  130320. * enables mapping of values in the render target depth
  130321. * attachment to scene coordinates. Initially set to 0.01.
  130322. */
  130323. depthNear: number;
  130324. /**
  130325. * An identifier for this distinct VRDisplay. Used as an
  130326. * association point in the Gamepad API.
  130327. */
  130328. readonly displayId: number;
  130329. /**
  130330. * A display name, a user-readable name identifying it.
  130331. */
  130332. readonly displayName: string;
  130333. readonly isConnected: boolean;
  130334. readonly isPresenting: boolean;
  130335. /**
  130336. * If this VRDisplay supports room-scale experiences, the optional
  130337. * stage attribute contains details on the room-scale parameters.
  130338. */
  130339. readonly stageParameters: VRStageParameters | null;
  130340. /**
  130341. * Passing the value returned by `requestAnimationFrame` to
  130342. * `cancelAnimationFrame` will unregister the callback.
  130343. * @param handle Define the hanle of the request to cancel
  130344. */
  130345. cancelAnimationFrame(handle: number): void;
  130346. /**
  130347. * Stops presenting to the VRDisplay.
  130348. * @returns a promise to know when it stopped
  130349. */
  130350. exitPresent(): Promise<void>;
  130351. /**
  130352. * Return the current VREyeParameters for the given eye.
  130353. * @param whichEye Define the eye we want the parameter for
  130354. * @returns the eye parameters
  130355. */
  130356. getEyeParameters(whichEye: string): VREyeParameters;
  130357. /**
  130358. * Populates the passed VRFrameData with the information required to render
  130359. * the current frame.
  130360. * @param frameData Define the data structure to populate
  130361. * @returns true if ok otherwise false
  130362. */
  130363. getFrameData(frameData: VRFrameData): boolean;
  130364. /**
  130365. * Get the layers currently being presented.
  130366. * @returns the list of VR layers
  130367. */
  130368. getLayers(): VRLayer[];
  130369. /**
  130370. * Return a VRPose containing the future predicted pose of the VRDisplay
  130371. * when the current frame will be presented. The value returned will not
  130372. * change until JavaScript has returned control to the browser.
  130373. *
  130374. * The VRPose will contain the position, orientation, velocity,
  130375. * and acceleration of each of these properties.
  130376. * @returns the pose object
  130377. */
  130378. getPose(): VRPose;
  130379. /**
  130380. * Return the current instantaneous pose of the VRDisplay, with no
  130381. * prediction applied.
  130382. * @returns the current instantaneous pose
  130383. */
  130384. getImmediatePose(): VRPose;
  130385. /**
  130386. * The callback passed to `requestAnimationFrame` will be called
  130387. * any time a new frame should be rendered. When the VRDisplay is
  130388. * presenting the callback will be called at the native refresh
  130389. * rate of the HMD. When not presenting this function acts
  130390. * identically to how window.requestAnimationFrame acts. Content should
  130391. * make no assumptions of frame rate or vsync behavior as the HMD runs
  130392. * asynchronously from other displays and at differing refresh rates.
  130393. * @param callback Define the eaction to run next frame
  130394. * @returns the request handle it
  130395. */
  130396. requestAnimationFrame(callback: FrameRequestCallback): number;
  130397. /**
  130398. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  130399. * Repeat calls while already presenting will update the VRLayers being displayed.
  130400. * @param layers Define the list of layer to present
  130401. * @returns a promise to know when the request has been fulfilled
  130402. */
  130403. requestPresent(layers: VRLayer[]): Promise<void>;
  130404. /**
  130405. * Reset the pose for this display, treating its current position and
  130406. * orientation as the "origin/zero" values. VRPose.position,
  130407. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  130408. * updated when calling resetPose(). This should be called in only
  130409. * sitting-space experiences.
  130410. */
  130411. resetPose(): void;
  130412. /**
  130413. * The VRLayer provided to the VRDisplay will be captured and presented
  130414. * in the HMD. Calling this function has the same effect on the source
  130415. * canvas as any other operation that uses its source image, and canvases
  130416. * created without preserveDrawingBuffer set to true will be cleared.
  130417. * @param pose Define the pose to submit
  130418. */
  130419. submitFrame(pose?: VRPose): void;
  130420. }
  130421. declare var VRDisplay: {
  130422. prototype: VRDisplay;
  130423. new(): VRDisplay;
  130424. };
  130425. interface VRLayer {
  130426. leftBounds?: number[] | Float32Array | null;
  130427. rightBounds?: number[] | Float32Array | null;
  130428. source?: HTMLCanvasElement | null;
  130429. }
  130430. interface VRDisplayCapabilities {
  130431. readonly canPresent: boolean;
  130432. readonly hasExternalDisplay: boolean;
  130433. readonly hasOrientation: boolean;
  130434. readonly hasPosition: boolean;
  130435. readonly maxLayers: number;
  130436. }
  130437. interface VREyeParameters {
  130438. /** @deprecated */
  130439. readonly fieldOfView: VRFieldOfView;
  130440. readonly offset: Float32Array;
  130441. readonly renderHeight: number;
  130442. readonly renderWidth: number;
  130443. }
  130444. interface VRFieldOfView {
  130445. readonly downDegrees: number;
  130446. readonly leftDegrees: number;
  130447. readonly rightDegrees: number;
  130448. readonly upDegrees: number;
  130449. }
  130450. interface VRFrameData {
  130451. readonly leftProjectionMatrix: Float32Array;
  130452. readonly leftViewMatrix: Float32Array;
  130453. readonly pose: VRPose;
  130454. readonly rightProjectionMatrix: Float32Array;
  130455. readonly rightViewMatrix: Float32Array;
  130456. readonly timestamp: number;
  130457. }
  130458. interface VRPose {
  130459. readonly angularAcceleration: Float32Array | null;
  130460. readonly angularVelocity: Float32Array | null;
  130461. readonly linearAcceleration: Float32Array | null;
  130462. readonly linearVelocity: Float32Array | null;
  130463. readonly orientation: Float32Array | null;
  130464. readonly position: Float32Array | null;
  130465. readonly timestamp: number;
  130466. }
  130467. interface VRStageParameters {
  130468. sittingToStandingTransform?: Float32Array;
  130469. sizeX?: number;
  130470. sizeY?: number;
  130471. }
  130472. interface Navigator {
  130473. getVRDisplays(): Promise<VRDisplay[]>;
  130474. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  130475. }
  130476. interface Window {
  130477. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  130478. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  130479. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  130480. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130481. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130482. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  130483. }
  130484. interface Gamepad {
  130485. readonly displayId: number;
  130486. }
  130487. type XRSessionMode =
  130488. | "inline"
  130489. | "immersive-vr"
  130490. | "immersive-ar";
  130491. type XRReferenceSpaceType =
  130492. | "viewer"
  130493. | "local"
  130494. | "local-floor"
  130495. | "bounded-floor"
  130496. | "unbounded";
  130497. type XREnvironmentBlendMode =
  130498. | "opaque"
  130499. | "additive"
  130500. | "alpha-blend";
  130501. type XRVisibilityState =
  130502. | "visible"
  130503. | "visible-blurred"
  130504. | "hidden";
  130505. type XRHandedness =
  130506. | "none"
  130507. | "left"
  130508. | "right";
  130509. type XRTargetRayMode =
  130510. | "gaze"
  130511. | "tracked-pointer"
  130512. | "screen";
  130513. type XREye =
  130514. | "none"
  130515. | "left"
  130516. | "right";
  130517. interface XRSpace extends EventTarget {
  130518. }
  130519. interface XRRenderState {
  130520. depthNear?: number;
  130521. depthFar?: number;
  130522. inlineVerticalFieldOfView?: number;
  130523. baseLayer?: XRWebGLLayer;
  130524. }
  130525. interface XRInputSource {
  130526. handedness: XRHandedness;
  130527. targetRayMode: XRTargetRayMode;
  130528. targetRaySpace: XRSpace;
  130529. gripSpace: XRSpace | undefined;
  130530. gamepad: Gamepad | undefined;
  130531. profiles: Array<string>;
  130532. }
  130533. interface XRSession {
  130534. addEventListener: Function;
  130535. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130536. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  130537. requestAnimationFrame: Function;
  130538. end(): Promise<void>;
  130539. renderState: XRRenderState;
  130540. inputSources: Array<XRInputSource>;
  130541. }
  130542. interface XRReferenceSpace extends XRSpace {
  130543. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  130544. onreset: any;
  130545. }
  130546. interface XRFrame {
  130547. session: XRSession;
  130548. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  130549. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  130550. }
  130551. interface XRViewerPose extends XRPose {
  130552. views: Array<XRView>;
  130553. }
  130554. interface XRPose {
  130555. transform: XRRigidTransform;
  130556. emulatedPosition: boolean;
  130557. }
  130558. declare var XRWebGLLayer: {
  130559. prototype: XRWebGLLayer;
  130560. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  130561. };
  130562. interface XRWebGLLayer {
  130563. framebuffer: WebGLFramebuffer;
  130564. framebufferWidth: number;
  130565. framebufferHeight: number;
  130566. getViewport: Function;
  130567. }
  130568. interface XRRigidTransform {
  130569. position: DOMPointReadOnly;
  130570. orientation: DOMPointReadOnly;
  130571. matrix: Float32Array;
  130572. inverse: XRRigidTransform;
  130573. }
  130574. interface XRView {
  130575. eye: XREye;
  130576. projectionMatrix: Float32Array;
  130577. transform: XRRigidTransform;
  130578. }
  130579. interface XRInputSourceChangeEvent {
  130580. session: XRSession;
  130581. removed: Array<XRInputSource>;
  130582. added: Array<XRInputSource>;
  130583. }